summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-20 19:25:48 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-20 19:25:48 +0000
commit1ce1597337ec9459598cc84a6bc3831c2ea3dfac (patch)
tree348d72c015790f799959ab9e958d8254c705af5a /apps
parent998e64060cece98794221895e561970be9a248d0 (diff)
downloadchromium_src-1ce1597337ec9459598cc84a6bc3831c2ea3dfac.zip
chromium_src-1ce1597337ec9459598cc84a6bc3831c2ea3dfac.tar.gz
chromium_src-1ce1597337ec9459598cc84a6bc3831c2ea3dfac.tar.bz2
Split ExtensionWebContentsObserver into base and Chrome implementations
This allows app_shell to use a simplified ExtensionWebContentsObserver while Chrome maintains its more complex version. * Move ExtensionWebContentsObserver to src/extensions * Introduce ChromeExtensionWebContentsObserver * Delegate out observer creation from ExtensionHost Removing this dependency on Chrome will allow ExtensionHost to move into src/extensions and break another app_shell -> Chrome dependency. BUG=321341 TEST=browser_tests ErrorConsole* and Extension* TBR=stevenjb@chromium.org for mechanical changes to chrome/browser/chromeos TBR=msw@chromium.org for mechanical changes to chrome/browser/ui Review URL: https://codereview.chromium.org/205243004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r--apps/DEPS2
-rw-r--r--apps/app_window.cc6
-rw-r--r--apps/apps.gypi2
-rw-r--r--apps/shell/browser/shell_extension_web_contents_observer.cc18
-rw-r--r--apps/shell/browser/shell_extension_web_contents_observer.h29
-rw-r--r--apps/shell/browser/shell_extensions_browser_client.cc10
6 files changed, 62 insertions, 5 deletions
diff --git a/apps/DEPS b/apps/DEPS
index 8837d35..2ef3863 100644
--- a/apps/DEPS
+++ b/apps/DEPS
@@ -28,10 +28,10 @@ include_rules = [
"+chrome/browser/extensions/api/app_runtime/app_runtime_api.h",
"+chrome/browser/extensions/api/file_handlers/app_file_handler_util.h",
"+chrome/browser/extensions/api/file_system/file_system_api.h",
+ "+chrome/browser/extensions/chrome_extension_web_contents_observer.h",
"+chrome/browser/extensions/extension_function_dispatcher.h",
"+chrome/browser/extensions/extension_icon_image.h",
"+chrome/browser/extensions/extension_host.h",
- "+chrome/browser/extensions/extension_web_contents_observer.h",
"+chrome/browser/extensions/suggest_permission_util.h",
"+chrome/browser/extensions/unpacked_installer.h",
"+chrome/common/extensions/api/app_runtime.h",
diff --git a/apps/app_window.cc b/apps/app_window.cc
index bc69973..b339cf2 100644
--- a/apps/app_window.cc
+++ b/apps/app_window.cc
@@ -16,7 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/extension_web_contents_observer.h"
+#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
#include "chrome/browser/extensions/suggest_permission_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
@@ -256,7 +256,9 @@ void AppWindow::Init(const GURL& url,
}
delegate_->InitWebContents(web_contents);
WebContentsModalDialogManager::CreateForWebContents(web_contents);
- extensions::ExtensionWebContentsObserver::CreateForWebContents(web_contents);
+ // TODO(jamescook): Delegate out this creation.
+ extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
+ web_contents);
web_contents->SetDelegate(this);
WebContentsModalDialogManager::FromWebContents(web_contents)
diff --git a/apps/apps.gypi b/apps/apps.gypi
index edb2b0a..65d1e0d 100644
--- a/apps/apps.gypi
+++ b/apps/apps.gypi
@@ -194,6 +194,8 @@
'shell/browser/shell_extension_system.h',
'shell/browser/shell_extension_system_factory.cc',
'shell/browser/shell_extension_system_factory.h',
+ 'shell/browser/shell_extension_web_contents_observer.cc',
+ 'shell/browser/shell_extension_web_contents_observer.h',
'shell/browser/shell_extensions_browser_client.cc',
'shell/browser/shell_extensions_browser_client.h',
'shell/browser/web_view_window.cc',
diff --git a/apps/shell/browser/shell_extension_web_contents_observer.cc b/apps/shell/browser/shell_extension_web_contents_observer.cc
new file mode 100644
index 0000000..0c8c29e
--- /dev/null
+++ b/apps/shell/browser/shell_extension_web_contents_observer.cc
@@ -0,0 +1,18 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "apps/shell/browser/shell_extension_web_contents_observer.h"
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(
+ extensions::ShellExtensionWebContentsObserver);
+
+namespace extensions {
+
+ShellExtensionWebContentsObserver::ShellExtensionWebContentsObserver(
+ content::WebContents* web_contents)
+ : ExtensionWebContentsObserver(web_contents) {}
+
+ShellExtensionWebContentsObserver::~ShellExtensionWebContentsObserver() {}
+
+} // namespace extensions
diff --git a/apps/shell/browser/shell_extension_web_contents_observer.h b/apps/shell/browser/shell_extension_web_contents_observer.h
new file mode 100644
index 0000000..aa703eb
--- /dev/null
+++ b/apps/shell/browser/shell_extension_web_contents_observer.h
@@ -0,0 +1,29 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APPS_SHELL_BROWSER_SHELL_EXTENSION_WEB_CONTENTS_OBSERVER_H_
+#define APPS_SHELL_BROWSER_SHELL_EXTENSION_WEB_CONTENTS_OBSERVER_H_
+
+#include "content/public/browser/web_contents_user_data.h"
+#include "extensions/browser/extension_web_contents_observer.h"
+
+namespace extensions {
+
+// The app_shell version of ExtensionWebContentsObserver.
+class ShellExtensionWebContentsObserver
+ : public ExtensionWebContentsObserver,
+ public content::WebContentsUserData<ShellExtensionWebContentsObserver> {
+ private:
+ friend class content::WebContentsUserData<ShellExtensionWebContentsObserver>;
+
+ explicit ShellExtensionWebContentsObserver(
+ content::WebContents* web_contents);
+ virtual ~ShellExtensionWebContentsObserver();
+
+ DISALLOW_COPY_AND_ASSIGN(ShellExtensionWebContentsObserver);
+};
+
+} // namespace extensions
+
+#endif // APPS_SHELL_BROWSER_SHELL_EXTENSION_WEB_CONTENTS_OBSERVER_H_
diff --git a/apps/shell/browser/shell_extensions_browser_client.cc b/apps/shell/browser/shell_extensions_browser_client.cc
index 0480fa6..13321ec 100644
--- a/apps/shell/browser/shell_extensions_browser_client.cc
+++ b/apps/shell/browser/shell_extensions_browser_client.cc
@@ -6,6 +6,7 @@
#include "apps/shell/browser/shell_app_sorting.h"
#include "apps/shell/browser/shell_extension_system_factory.h"
+#include "apps/shell/browser/shell_extension_web_contents_observer.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_factory.h"
#include "base/prefs/testing_pref_store.h"
@@ -28,7 +29,7 @@ void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
ExtensionPrefs::RegisterProfilePrefs(registry);
}
-// An ExtensionHostDelegate that does nothing.
+// A minimal ExtensionHostDelegate.
class ShellExtensionHostDelegate : public ExtensionHostDelegate {
public:
ShellExtensionHostDelegate() {}
@@ -36,7 +37,7 @@ class ShellExtensionHostDelegate : public ExtensionHostDelegate {
// ExtensionHostDelegate implementation.
virtual void OnExtensionHostCreated(content::WebContents* web_contents)
- OVERRIDE {}
+ OVERRIDE;
virtual void OnRenderViewCreatedForBackgroundPage(ExtensionHost* host)
OVERRIDE {}
@@ -68,6 +69,11 @@ class ShellExtensionHostDelegate : public ExtensionHostDelegate {
}
};
+void ShellExtensionHostDelegate::OnExtensionHostCreated(
+ content::WebContents* web_contents) {
+ ShellExtensionWebContentsObserver::CreateForWebContents(web_contents);
+}
+
} // namespace
ShellExtensionsBrowserClient::ShellExtensionsBrowserClient(