diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-10 20:52:40 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-10 20:52:40 +0000 |
commit | 9be525e4d7fd9ebb64150d32c367124f160776ba (patch) | |
tree | 415124dad5b1254d2212086daa537013145c0aa9 | |
parent | e73ff37bc4f4be60b4bb476c58041d739004ab87 (diff) | |
download | chromium_src-9be525e4d7fd9ebb64150d32c367124f160776ba.zip chromium_src-9be525e4d7fd9ebb64150d32c367124f160776ba.tar.gz chromium_src-9be525e4d7fd9ebb64150d32c367124f160776ba.tar.bz2 |
app_shell: Fix PrefsTabHelper dependency of ExtensionHost
The default preference values are fine for app_shell's pages (as they are
for content_shell, which doesn't use PrefsTabHelper). Delegate out the
creation of PrefsTabHelper so we only create them in Chrome.
With this patch app_shell can launch a renderer before crashing.
BUG=332435
TEST=browser_tests, manual testing that extensions still work
Review URL: https://codereview.chromium.org/132993002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244236 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 21 insertions, 2 deletions
diff --git a/apps/shell/shell_extensions_browser_client.cc b/apps/shell/shell_extensions_browser_client.cc index 67af2ac..f745200 100644 --- a/apps/shell/shell_extensions_browser_client.cc +++ b/apps/shell/shell_extensions_browser_client.cc @@ -98,6 +98,10 @@ bool ShellExtensionsBrowserClient::IsBackgroundPageAllowed( return true; } +void ShellExtensionsBrowserClient::OnExtensionHostCreated( + content::WebContents* web_contents) { +} + bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) { // TODO(jamescook): We might want to tell extensions when app_shell updates. return false; diff --git a/apps/shell/shell_extensions_browser_client.h b/apps/shell/shell_extensions_browser_client.h index 61d7d7d..86781b5 100644 --- a/apps/shell/shell_extensions_browser_client.h +++ b/apps/shell/shell_extensions_browser_client.h @@ -39,6 +39,8 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { const OVERRIDE; virtual bool IsBackgroundPageAllowed(content::BrowserContext* context) const OVERRIDE; + virtual void OnExtensionHostCreated(content::WebContents* web_contents) + OVERRIDE; virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE; virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE; virtual bool IsRunningInForcedAppMode() OVERRIDE; diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc index da56988..e85e244 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_client.cc +++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc @@ -16,6 +16,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" #include "chrome/browser/ui/browser_finder.h" +#include "chrome/browser/ui/prefs/prefs_tab_helper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/pref_names.h" @@ -110,6 +111,11 @@ bool ChromeExtensionsBrowserClient::IsBackgroundPageAllowed( return true; } +void ChromeExtensionsBrowserClient::OnExtensionHostCreated( + content::WebContents* web_contents) { + PrefsTabHelper::CreateForWebContents(web_contents); +} + bool ChromeExtensionsBrowserClient::DidVersionUpdate( content::BrowserContext* context) { Profile* profile = static_cast<Profile*>(context); diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.h b/chrome/browser/extensions/chrome_extensions_browser_client.h index c90bc72..4552699 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_client.h +++ b/chrome/browser/extensions/chrome_extensions_browser_client.h @@ -50,6 +50,8 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient { content::BrowserContext* context) const OVERRIDE; virtual bool IsBackgroundPageAllowed( content::BrowserContext* context) const OVERRIDE; + virtual void OnExtensionHostCreated(content::WebContents* web_contents) + OVERRIDE; virtual bool DidVersionUpdate(content::BrowserContext* context) OVERRIDE; virtual scoped_ptr<AppSorting> CreateAppSorting() OVERRIDE; virtual bool IsRunningInForcedAppMode() OVERRIDE; diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 6ca2501..bafcf21 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -21,7 +21,6 @@ #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/extensions/extension_web_contents_observer.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h" -#include "chrome/browser/ui/prefs/prefs_tab_helper.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_messages.h" @@ -142,7 +141,6 @@ ExtensionHost::ExtensionHost(const Extension* extension, SetViewType(host_contents_.get(), host_type); ExtensionWebContentsObserver::CreateForWebContents(host_contents()); - PrefsTabHelper::CreateForWebContents(host_contents()); render_view_host_ = host_contents_->GetRenderViewHost(); @@ -150,6 +148,8 @@ ExtensionHost::ExtensionHost(const Extension* extension, // be the same extension that this points to. registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, content::Source<BrowserContext>(browser_context_)); + + ExtensionsBrowserClient::Get()->OnExtensionHostCreated(host_contents()); } ExtensionHost::~ExtensionHost() { diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h index 306515f..46405a0 100644 --- a/extensions/browser/extensions_browser_client.h +++ b/extensions/browser/extensions_browser_client.h @@ -16,6 +16,7 @@ class PrefService; namespace content { class BrowserContext; class JavaScriptDialogManager; +class WebContents; } namespace extensions { @@ -75,6 +76,10 @@ class ExtensionsBrowserClient { virtual bool IsBackgroundPageAllowed( content::BrowserContext* context) const = 0; + // Called after the hosting |web_contents| for an extension is created. The + // implementation may wish to add preference observers to |web_contents|. + virtual void OnExtensionHostCreated(content::WebContents* web_contents) = 0; + // Returns true if the client version has updated since the last run. Called // once each time the extensions system is loaded per browser_context. The // implementation may wish to use the BrowserContext to record the current |