Add CommonWebContentsDelegate

This commit is contained in:
Cheng Zhao 2015-06-05 13:49:12 +08:00
parent e8f33f51fb
commit 19d742de37
7 changed files with 55 additions and 7 deletions

View 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),

View 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:

View file

@ -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

View file

@ -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_

View 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),

View 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 {

View file

@ -123,6 +123,8 @@
'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',