From 7f581973c35a2bc1ff1461c3c0eed16a1d203386 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 20 Apr 2013 13:56:01 +0800 Subject: [PATCH] Implement window.open. --- browser/native_window.cc | 18 ++++++++++++++++++ browser/native_window.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/browser/native_window.cc b/browser/native_window.cc index 2dbcfd8..91e53b7 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -107,6 +107,24 @@ content::WebContents* NativeWindow::GetWebContents() const { return inspectable_web_contents_->GetWebContents(); } +// Window opened by window.open. +void NativeWindow::WebContentsCreated( + content::WebContents* source_contents, + int64 source_frame_id, + const string16& frame_name, + const GURL& target_url, + content::WebContents* new_contents) { + LOG(WARNING) << "Please use node-style Window API to create window, " + "using window.open has very strict constrains."; + + scoped_ptr options(new base::DictionaryValue); + options->SetInteger(switches::kWidth, 800); + options->SetInteger(switches::kHeight, 600); + + NativeWindow* window = Create(new_contents, options.get()); + window->InitFromOptions(options.get()); +} + void NativeWindow::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { diff --git a/browser/native_window.h b/browser/native_window.h index de12f0f..40be890 100644 --- a/browser/native_window.h +++ b/browser/native_window.h @@ -101,6 +101,13 @@ class NativeWindow : public content::WebContentsDelegate, return inspectable_web_contents_.get(); } + // Implementations of content::WebContentsDelegate. + virtual void WebContentsCreated(content::WebContents* source_contents, + int64 source_frame_id, + const string16& frame_name, + const GURL& target_url, + content::WebContents* new_contents) OVERRIDE; + // Implementations of content::NotificationObserver virtual void Observe(int type, const content::NotificationSource& source, -- 2.7.4