]> khamidou — GitHub mirrors - electron.git/commitdiff
Add CommonWebContentsDelegate
authorCheng Zhao <zcbenz@gmail.com>
Fri, 5 Jun 2015 05:49:12 +0000 (13:49 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 5 Jun 2015 05:49:24 +0000 (13:49 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/browser/common_web_contents_delegate.cc [new file with mode: 0644]
atom/browser/common_web_contents_delegate.h [new file with mode: 0644]
atom/browser/native_window.cc
atom/browser/native_window.h
filenames.gypi

index ac96a64d494870b59ac505e6fcf7f7702114ed62..02ac372f876aa5d9ff6b1cb9d944a6569a939963 100644 (file)
@@ -109,7 +109,8 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
 }  // namespace
 
 WebContents::WebContents(content::WebContents* web_contents)
-    : content::WebContentsObserver(web_contents),
+    : CommonWebContentsDelegate(false),
+      content::WebContentsObserver(web_contents),
       guest_instance_id_(-1),
       guest_opaque_(true),
       guest_host_(nullptr),
@@ -118,7 +119,8 @@ WebContents::WebContents(content::WebContents* web_contents)
 }
 
 WebContents::WebContents(const mate::Dictionary& options)
-    : guest_instance_id_(-1),
+    : CommonWebContentsDelegate(true),
+      guest_instance_id_(-1),
       guest_opaque_(true),
       guest_host_(nullptr),
       auto_size_enabled_(false),
index 14de69fc90317e298eca6ccdb21d464757fed08d..97a433ed36ced9db418b3e9ce4aa62a571bfd18b 100644 (file)
@@ -9,7 +9,7 @@
 #include <vector>
 
 #include "atom/browser/api/event_emitter.h"
-#include "brightray/browser/default_web_contents_delegate.h"
+#include "atom/browser/common_web_contents_delegate.h"
 #include "content/public/browser/browser_plugin_guest_delegate.h"
 #include "content/public/common/favicon_url.h"
 #include "content/public/browser/web_contents_delegate.h"
@@ -51,7 +51,7 @@ struct SetSizeParams {
 
 class WebContents : public mate::EventEmitter,
                     public content::BrowserPluginGuestDelegate,
-                    public brightray::DefaultWebContentsDelegate,
+                    public CommonWebContentsDelegate,
                     public content::WebContentsObserver,
                     public content::GpuDataManagerObserver {
  public:
diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc
new file mode 100644 (file)
index 0000000..46e8723
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/common_web_contents_delegate.h"
+
+namespace atom {
+
+CommonWebContentsDelegate::CommonWebContentsDelegate(bool is_guest)
+    : is_guest_(is_guest) {
+}
+
+CommonWebContentsDelegate::~CommonWebContentsDelegate() {
+}
+
+}  // namespace atom
diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h
new file mode 100644 (file)
index 0000000..f449bf2
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_COMMON_WEB_CONTENTS_DELEGATE_H_
+#define ATOM_BROWSER_COMMON_WEB_CONTENTS_DELEGATE_H_
+
+#include "brightray/browser/default_web_contents_delegate.h"
+
+namespace atom {
+
+class CommonWebContentsDelegate : public brightray::DefaultWebContentsDelegate {
+ public:
+  explicit CommonWebContentsDelegate(bool is_guest);
+  virtual ~CommonWebContentsDelegate();
+
+  bool is_guest() const { return is_guest_; };
+
+ private:
+  const bool is_guest_;
+
+  DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate);
+};
+
+}  // namespace atom
+
+#endif  // ATOM_BROWSER_COMMON_WEB_CONTENTS_DELEGATE_H_
index c254ed96042fa4c9c57cc68a1d8c77d5a74cd63c..6c11e97e96a6098297e44762334cc646f6d516c1 100644 (file)
@@ -151,7 +151,8 @@ base::DictionaryValue* CreateFileSystemValue(
 
 NativeWindow::NativeWindow(content::WebContents* web_contents,
                            const mate::Dictionary& options)
-    : content::WebContentsObserver(web_contents),
+    : CommonWebContentsDelegate(false),
+      content::WebContentsObserver(web_contents),
       has_frame_(true),
       transparent_(false),
       enable_larger_than_screen_(false),
index fb614bad2bdebd4bf2c247072d386af29095ec9f..2cfbe135ef676c16e8ac7f52c53c8855c574ec6c 100644 (file)
@@ -9,13 +9,13 @@
 #include <string>
 #include <vector>
 
+#include "atom/browser/common_web_contents_delegate.h"
 #include "atom/browser/native_window_observer.h"
 #include "atom/browser/ui/accelerator_util.h"
 #include "base/cancelable_callback.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
-#include "brightray/browser/default_web_contents_delegate.h"
 #include "brightray/browser/inspectable_web_contents_delegate.h"
 #include "brightray/browser/inspectable_web_contents_impl.h"
 #include "content/public/browser/notification_registrar.h"
@@ -54,7 +54,7 @@ class AtomJavaScriptDialogManager;
 struct DraggableRegion;
 class WebDialogHelper;
 
-class NativeWindow : public brightray::DefaultWebContentsDelegate,
+class NativeWindow : public CommonWebContentsDelegate,
                      public brightray::InspectableWebContentsDelegate,
                      public content::WebContentsObserver,
                      public content::NotificationObserver {
index 2bef38832548c159ede80ff58b340603ad7d98ae..6ece2ba634c7389bc81da06f307d3fda1af05409 100644 (file)
       'atom/browser/browser_mac.mm',
       'atom/browser/browser_win.cc',
       'atom/browser/browser_observer.h',
+      'atom/browser/common_web_contents_delegate.cc',
+      'atom/browser/common_web_contents_delegate.h',
       'atom/browser/javascript_environment.cc',
       'atom/browser/javascript_environment.h',
       'atom/browser/mac/atom_application.h',