}
};
+template<>
+struct Converter<WindowOpenDisposition> {
+ static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
+ WindowOpenDisposition val) {
+ std::string disposition = "other";
+ switch (val) {
+ case CURRENT_TAB: disposition = "default"; break;
+ case NEW_FOREGROUND_TAB: disposition = "foreground-tab"; break;
+ case NEW_BACKGROUND_TAB: disposition = "background-tab"; break;
+ case NEW_POPUP: case NEW_WINDOW: disposition = "new-window"; break;
+ default: break;
+ }
+ return mate::ConvertToV8(isolate, disposition);
+ }
+};
+
} // namespace mate
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace) {
- Emit("-new-window",
- target_url,
- frame_name,
- static_cast<int>(NEW_FOREGROUND_TAB));
+ Emit("new-window", target_url, frame_name, NEW_FOREGROUND_TAB);
return false;
}
content::WebContents* source,
const content::OpenURLParams& params) {
if (params.disposition != CURRENT_TAB) {
- Emit("-new-window", params.url, "", static_cast<int>(params.disposition));
+ Emit("new-window", params.url, "", params.disposition);
return nullptr;
}
const GURL& target_url,
const std::string& partition_id,
WindowOpenDisposition disposition) {
- Emit("-new-window", target_url, frame_name, static_cast<int>(disposition));
+ Emit("-new-window", target_url, frame_name);
}
void Window::WillNavigate(bool* prevent_default, const GURL& url) {
do (name, method) ->
webContents[name] = -> method.apply controller, arguments
- # Translate |disposition| to string for 'new-window' event.
- webContents.on '-new-window', (args..., disposition) ->
- disposition =
- switch disposition
- when 2 then 'default'
- when 4 then 'foreground-tab'
- when 5 then 'background-tab'
- when 6, 7 then 'new-window'
- else 'other'
- @emit 'new-window', args..., disposition
-
# Tell the rpc server that a render view has been deleted and we need to
# release all objects owned by it.
webContents.on 'render-view-deleted', (event, processId, routingId) ->
# Routed window.open messages.
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) ->
[url, frameName, options] = args
- event.sender.emit '-new-window', event, url, frameName, 7
+ event.sender.emit 'new-window', event, url, frameName, 'new-window'
if event.sender.isGuest() or event.defaultPrevented
event.returnValue = null
else