Enable creating window with existing web contents.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 20 Apr 2013 05:42:39 +0000 (13:42 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 20 Apr 2013 05:42:39 +0000 (13:42 +0800)
browser/api/atom_api_window.cc
browser/native_window.cc
browser/native_window.h
browser/native_window_mac.h
browser/native_window_mac.mm
vendor/brightray

index 1ac41dd..7f86cbf 100644 (file)
@@ -5,7 +5,6 @@
 #include "browser/api/atom_api_window.h"
 
 #include "base/values.h"
-#include "browser/atom_browser_context.h"
 #include "browser/native_window.h"
 #include "common/v8_value_converter_impl.h"
 #include "content/public/browser/navigation_entry.h"
@@ -33,7 +32,7 @@ v8::Handle<v8::String> UTF16ToV8String(const string16& s) {
 
 Window::Window(v8::Handle<v8::Object> wrapper, base::DictionaryValue* options)
     : EventEmitter(wrapper),
-      window_(NativeWindow::Create(AtomBrowserContext::Get(), options)) {
+      window_(NativeWindow::Create(options)) {
   window_->InitFromOptions(options);
   window_->AddObserver(this);
 }
index c769107..2dbcfd8 100644 (file)
@@ -11,6 +11,7 @@
 #include "brightray/browser/browser_context.h"
 #include "brightray/browser/inspectable_web_contents.h"
 #include "brightray/browser/inspectable_web_contents_view.h"
+#include "browser/atom_browser_context.h"
 #include "content/public/browser/navigation_entry.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_source.h"
@@ -24,12 +25,10 @@ using content::NavigationEntry;
 
 namespace atom {
 
-NativeWindow::NativeWindow(content::BrowserContext* browser_context,
+NativeWindow::NativeWindow(content::WebContents* web_contents,
                            base::DictionaryValue* options)
-    : inspectable_web_contents_(brightray::InspectableWebContents::Create(
-          content::WebContents::CreateParams(browser_context))) {
-  content::WebContents* web_contents = GetWebContents();
-
+    : inspectable_web_contents_(
+          brightray::InspectableWebContents::Create(web_contents)) {
   web_contents->SetDelegate(this);
 
   // Add window as an observer of the web contents.
@@ -40,6 +39,12 @@ NativeWindow::NativeWindow(content::BrowserContext* browser_context,
 NativeWindow::~NativeWindow() {
 }
 
+// static
+NativeWindow* NativeWindow::Create(base::DictionaryValue* options) {
+  content::WebContents::CreateParams create_params(AtomBrowserContext::Get());
+  return Create(content::WebContents::Create(create_params), options);
+}
+
 void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
   // Setup window from options.
   int x, y;
index 239406a..de12f0f 100644 (file)
@@ -42,9 +42,13 @@ class NativeWindow : public content::WebContentsDelegate,
  public:
   virtual ~NativeWindow();
 
-  static NativeWindow* Create(content::BrowserContext* browser_context,
+  // Create window with existing WebContents.
+  static NativeWindow* Create(content::WebContents* web_contents,
                               base::DictionaryValue* options);
 
+  // Create window with new WebContents.
+  static NativeWindow* Create(base::DictionaryValue* options);
+
   void InitFromOptions(base::DictionaryValue* options);
 
   virtual void Close() = 0;
@@ -90,7 +94,7 @@ class NativeWindow : public content::WebContentsDelegate,
   }
 
  protected:
-  explicit NativeWindow(content::BrowserContext* browser_context,
+  explicit NativeWindow(content::WebContents* web_contents,
                         base::DictionaryValue* options);
 
   brightray::InspectableWebContents* inspectable_web_contents() const {
index 2f9190f..87f5d9e 100644 (file)
@@ -14,7 +14,7 @@ namespace atom {
 
 class NativeWindowMac : public NativeWindow {
  public:
-  explicit NativeWindowMac(content::BrowserContext* browser_context,
+  explicit NativeWindowMac(content::WebContents* web_contents,
                            base::DictionaryValue* options);
   virtual ~NativeWindowMac();
 
index 8e72cf7..f22989b 100644 (file)
@@ -43,9 +43,9 @@
 
 namespace atom {
 
-NativeWindowMac::NativeWindowMac(content::BrowserContext* browser_context,
+NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
                                  base::DictionaryValue* options)
-    : NativeWindow(browser_context, options),
+    : NativeWindow(web_contents, options),
       is_fullscreen_(false),
       is_kiosk_(false),
       attention_request_id_(0) {
@@ -350,9 +350,9 @@ void NativeWindowMac::UninstallView() {
 }
 
 // static
-NativeWindow* NativeWindow::Create(content::BrowserContext* browser_context,
+NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
                                    base::DictionaryValue* options) {
-  return new NativeWindowMac(browser_context, options);
+  return new NativeWindowMac(web_contents, options);
 }
 
 }  // namespace atom
index be62b66..5e5ac16 160000 (submodule)
@@ -1 +1 @@
-Subproject commit be62b66f9a11660610ef08e6cd65d4f669d71e7f
+Subproject commit 5e5ac169db77ab49507ff474e54d73ab3e74ce38