summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 23:33:42 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 23:33:42 +0000
commit75e7bacc1e8f88f049b8608698148d5ee1fd11cc (patch)
tree818a57c87409447ebb2a10ceb22aadbb466d1576
parente30ecf719e306c7d6c85784da1eb78e38127995a (diff)
downloadchromium_src-75e7bacc1e8f88f049b8608698148d5ee1fd11cc.zip
chromium_src-75e7bacc1e8f88f049b8608698148d5ee1fd11cc.tar.gz
chromium_src-75e7bacc1e8f88f049b8608698148d5ee1fd11cc.tar.bz2
Revert 232456 "Convert ExtensionProcessManager to BrowserContext..."
> Convert ExtensionProcessManager to BrowserContext, part 1 > > Part of moving ExtensionProcessManager to src/extensions. > * Introduce more test coverage > * Convert most usage of Profile to BrowserContext > * Separate out "master" vs. incognito profiles/contexts > * Move switches into extensions/common/switches.h > > BUG=313481 > TEST=unit_tests ExtensionProcessManager* and browser_tests ExtensionProcessManager* > R=miket@chromium.org > > Review URL: https://codereview.chromium.org/52983004 TBR=jamescook@chromium.org Review URL: https://codereview.chromium.org/47653004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232513 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/apps/app_browsertest_util.cc5
-rw-r--r--chrome/browser/extensions/api/runtime/runtime_api.cc4
-rw-r--r--chrome/browser/extensions/api/runtime/runtime_api.h6
-rw-r--r--chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc8
-rw-r--r--chrome/browser/extensions/chrome_extensions_browser_client.cc29
-rw-r--r--chrome/browser/extensions/chrome_extensions_browser_client.h4
-rw-r--r--chrome/browser/extensions/extension_context_menu_browsertest.cc8
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc191
-rw-r--r--chrome/browser/extensions/extension_process_manager.h22
-rw-r--r--chrome/browser/extensions/extension_process_manager_browsertest.cc92
-rw-r--r--chrome/browser/extensions/extension_process_manager_unittest.cc87
-rw-r--r--chrome/browser/extensions/lazy_background_page_apitest.cc8
-rw-r--r--chrome/browser/extensions/notifications_apitest.cc8
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/chrome_switches.cc8
-rw-r--r--chrome/common/chrome_switches.h2
-rw-r--r--extensions/browser/extensions_browser_client.h11
-rw-r--r--extensions/browser/lazy_background_task_queue_unittest.cc2
-rw-r--r--extensions/common/switches.cc8
-rw-r--r--extensions/common/switches.h2
20 files changed, 127 insertions, 379 deletions
diff --git a/chrome/browser/apps/app_browsertest_util.cc b/chrome/browser/apps/app_browsertest_util.cc
index 9a04d3c..24a161c 100644
--- a/chrome/browser/apps/app_browsertest_util.cc
+++ b/chrome/browser/apps/app_browsertest_util.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/application_launch.h"
+#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
@@ -36,8 +37,8 @@ void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) {
ExtensionBrowserTest::SetUpCommandLine(command_line);
// Make event pages get suspended quicker.
- command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1");
+ command_line->AppendSwitchASCII(::switches::kEventPageIdleTime, "1");
+ command_line->AppendSwitchASCII(::switches::kEventPageSuspendingTime, "1");
}
// static
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc
index 3411a03..185c2ce 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.cc
+++ b/chrome/browser/extensions/api/runtime/runtime_api.cc
@@ -132,9 +132,7 @@ std::string GetUninstallUrl(ExtensionPrefs* prefs,
// static
void RuntimeEventRouter::DispatchOnStartupEvent(
- content::BrowserContext* context, const std::string& extension_id) {
- // TODO(jamescook): Convert to BrowserContext all the way down.
- Profile* profile = static_cast<Profile*>(context);
+ Profile* profile, const std::string& extension_id) {
DispatchOnStartupEventImpl(profile, extension_id, true, NULL);
}
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.h b/chrome/browser/extensions/api/runtime/runtime_api.h
index 8884984..b917ba4 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.h
+++ b/chrome/browser/extensions/api/runtime/runtime_api.h
@@ -18,10 +18,6 @@ namespace base {
class Version;
}
-namespace content {
-class BrowserContext;
-}
-
namespace extensions {
class Extension;
class ExtensionHost;
@@ -29,7 +25,7 @@ class ExtensionHost;
class RuntimeEventRouter {
public:
// Dispatches the onStartup event to all currently-loaded extensions.
- static void DispatchOnStartupEvent(content::BrowserContext* context,
+ static void DispatchOnStartupEvent(Profile* profile,
const std::string& extension_id);
// Dispatches the onInstalled event to the given extension.
diff --git a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
index 4268a39..5b923ca 100644
--- a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
+++ b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
@@ -11,8 +11,8 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/lazy_background_page_test_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
-#include "extensions/common/switches.h"
class SystemIndicatorApiTest : public ExtensionApiTest {
public:
@@ -20,10 +20,8 @@ class SystemIndicatorApiTest : public ExtensionApiTest {
ExtensionApiTest::SetUpCommandLine(command_line);
// Set shorter delays to prevent test timeouts in tests that need to wait
// for the event page to unload.
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageSuspendingTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1");
}
const extensions::Extension* LoadExtensionAndWait(
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc
index f2d2c8f..e2ba427 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.cc
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc
@@ -4,12 +4,8 @@
#include "chrome/browser/extensions/chrome_extensions_browser_client.h"
-#include "base/command_line.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/common/chrome_switches.h"
namespace extensions {
@@ -45,31 +41,6 @@ content::BrowserContext* ChromeExtensionsBrowserClient::GetOffTheRecordContext(
return static_cast<Profile*>(context)->GetOffTheRecordProfile();
}
-content::BrowserContext* ChromeExtensionsBrowserClient::GetOriginalContext(
- content::BrowserContext* context) {
- return static_cast<Profile*>(context)->GetOriginalProfile();
-}
-
-bool ChromeExtensionsBrowserClient::DeferLoadingBackgroundHosts(
- content::BrowserContext* context) const {
- Profile* profile = static_cast<Profile*>(context);
-
- // The profile may not be valid yet if it is still being initialized.
- // In that case, defer loading, since it depends on an initialized profile.
- // http://crbug.com/222473
- if (!g_browser_process->profile_manager()->IsValidProfile(profile))
- return true;
-
-#if defined(OS_ANDROID)
- return false;
-#else
- // There are no browser windows open and the browser process was
- // started to show the app launcher.
- return chrome::GetTotalBrowserCountForProfile(profile) == 0 &&
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList);
-#endif
-}
-
// static
ChromeExtensionsBrowserClient* ChromeExtensionsBrowserClient::GetInstance() {
return g_client.Pointer();
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.h b/chrome/browser/extensions/chrome_extensions_browser_client.h
index 13cd64d..ddcc4d7 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.h
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.h
@@ -35,10 +35,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context) OVERRIDE;
virtual content::BrowserContext* GetOffTheRecordContext(
content::BrowserContext* context) OVERRIDE;
- virtual content::BrowserContext* GetOriginalContext(
- content::BrowserContext* context) OVERRIDE;
- virtual bool DeferLoadingBackgroundHosts(
- content::BrowserContext* context) const OVERRIDE;
// Get the LazyInstance for ChromeBrowserClient.
static ChromeExtensionsBrowserClient* GetInstance();
diff --git a/chrome/browser/extensions/extension_context_menu_browsertest.cc b/chrome/browser/extensions/extension_context_menu_browsertest.cc
index 8120edf..5c00310 100644
--- a/chrome/browser/extensions/extension_context_menu_browsertest.cc
+++ b/chrome/browser/extensions/extension_context_menu_browsertest.cc
@@ -14,9 +14,9 @@
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/common/context_menu_params.h"
-#include "extensions/common/switches.h"
#include "net/dns/mock_host_resolver.h"
#include "ui/base/models/menu_model.h"
@@ -608,10 +608,8 @@ class ExtensionContextMenuBrowserLazyTest :
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionContextMenuBrowserTest::SetUpCommandLine(command_line);
// Set shorter delays to prevent test timeouts.
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageIdleTime, "0");
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageSuspendingTime, "0");
+ command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "0");
+ command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "0");
}
};
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index bb44539..a4b2374 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -13,6 +13,7 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/runtime/runtime_api.h"
#include "chrome/browser/extensions/extension_host.h"
@@ -21,7 +22,10 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
@@ -40,15 +44,12 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "content/public/common/renderer_preferences.h"
-#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/view_type_utils.h"
-#include "extensions/common/switches.h"
#if defined(OS_MACOSX)
#include "chrome/browser/extensions/extension_host_mac.h"
#endif
-using content::BrowserContext;
using content::RenderViewHost;
using content::SiteInstance;
using content::WebContents;
@@ -56,8 +57,6 @@ using extensions::BackgroundInfo;
using extensions::BackgroundManifestHandler;
using extensions::Extension;
using extensions::ExtensionHost;
-using extensions::ExtensionsBrowserClient;
-using extensions::ExtensionSystem;
class RenderViewHostDestructionObserver;
DEFINE_WEB_CONTENTS_USER_DATA_KEY(RenderViewHostDestructionObserver);
@@ -73,11 +72,11 @@ std::string GetExtensionID(RenderViewHost* render_view_host) {
return render_view_host->GetSiteInstance()->GetSiteURL().host();
}
-void OnRenderViewHostUnregistered(BrowserContext* context,
+void OnRenderViewHostUnregistered(Profile* profile,
RenderViewHost* render_view_host) {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED,
- content::Source<BrowserContext>(context),
+ content::Source<Profile>(profile),
content::Details<RenderViewHost>(render_view_host));
}
@@ -86,8 +85,7 @@ void OnRenderViewHostUnregistered(BrowserContext* context,
// on whether a given extension uses "split" or "spanning" incognito behavior.
class IncognitoExtensionProcessManager : public ExtensionProcessManager {
public:
- IncognitoExtensionProcessManager(BrowserContext* incognito_context,
- BrowserContext* original_context);
+ explicit IncognitoExtensionProcessManager(Profile* profile);
virtual ~IncognitoExtensionProcessManager();
virtual ExtensionHost* CreateViewHost(
const Extension* extension,
@@ -112,7 +110,6 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager {
static void CreateBackgroundHostForExtensionLoad(
ExtensionProcessManager* manager, const Extension* extension) {
- DVLOG(1) << "CreateBackgroundHostForExtensionLoad";
if (BackgroundInfo::HasPersistentBackgroundPage(extension))
manager->CreateBackgroundHost(extension,
BackgroundInfo::GetBackgroundURL(extension));
@@ -173,63 +170,57 @@ struct ExtensionProcessManager::BackgroundPageData {
//
// static
-ExtensionProcessManager* ExtensionProcessManager::Create(
- BrowserContext* context) {
- if (context->IsOffTheRecord()) {
- BrowserContext* original_context =
- ExtensionsBrowserClient::Get()->GetOriginalContext(context);
- return new IncognitoExtensionProcessManager(context, original_context);
- }
- return new ExtensionProcessManager(context, context);
+ExtensionProcessManager* ExtensionProcessManager::Create(Profile* profile) {
+ return (profile->IsOffTheRecord()) ?
+ new IncognitoExtensionProcessManager(profile) :
+ new ExtensionProcessManager(profile);
}
-ExtensionProcessManager::ExtensionProcessManager(
- BrowserContext* context,
- BrowserContext* original_context)
- : site_instance_(SiteInstance::Create(context)),
+ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
+ : site_instance_(SiteInstance::Create(profile)),
defer_background_host_creation_(false),
+ weak_ptr_factory_(this),
devtools_callback_(base::Bind(
&ExtensionProcessManager::OnDevToolsStateChanged,
- base::Unretained(this))),
- weak_ptr_factory_(this) {
+ base::Unretained(this))) {
+ Profile* original_profile = profile->GetOriginalProfile();
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
- content::Source<BrowserContext>(context));
+ content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
- content::Source<BrowserContext>(context));
+ content::Source<Profile>(profile));
registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
content::NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
- content::Source<BrowserContext>(context));
- if (context->IsOffTheRecord()) {
+ content::Source<Profile>(profile));
+ if (profile->IsOffTheRecord()) {
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(original_profile));
}
event_page_idle_time_ = base::TimeDelta::FromSeconds(10);
unsigned idle_time_sec = 0;
if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- extensions::switches::kEventPageIdleTime), &idle_time_sec)) {
+ switches::kEventPageIdleTime), &idle_time_sec)) {
event_page_idle_time_ = base::TimeDelta::FromSeconds(idle_time_sec);
}
event_page_suspending_time_ = base::TimeDelta::FromSeconds(5);
unsigned suspending_time_sec = 0;
if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- extensions::switches::kEventPageSuspendingTime),
- &suspending_time_sec)) {
- event_page_suspending_time_ =
- base::TimeDelta::FromSeconds(suspending_time_sec);
+ switches::kEventPageSuspendingTime), &suspending_time_sec)) {
+ event_page_suspending_time_ = base::TimeDelta::FromSeconds(
+ suspending_time_sec);
}
content::DevToolsManager::GetInstance()->AddAgentStateCallback(
@@ -258,9 +249,17 @@ void ExtensionProcessManager::EnsureBrowserWhenRequired(
Browser* browser,
extensions::ViewType view_type) {
if (!browser) {
- // A NULL browser may only be given for pop-up views and dialogs.
- DCHECK(view_type == extensions::VIEW_TYPE_EXTENSION_POPUP ||
- view_type == extensions::VIEW_TYPE_EXTENSION_DIALOG);
+#if defined (OS_CHROMEOS)
+ // On ChromeOS we'll only use ExtensionView, which
+ // does not use the browser parameter.
+ // TODO(rkc): Remove all this once we create a new host for
+ // screensaver extensions (crosbug.com/28211).
+ DCHECK(view_type == extensions::VIEW_TYPE_EXTENSION_POPUP ||
+ view_type == extensions::VIEW_TYPE_EXTENSION_DIALOG);
+#else
+ // A NULL browser may only be given for pop-up views.
+ DCHECK(view_type == extensions::VIEW_TYPE_EXTENSION_POPUP);
+#endif
}
}
@@ -269,7 +268,6 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost(
const GURL& url,
Browser* browser,
extensions::ViewType view_type) {
- DVLOG(1) << "CreateViewHost";
DCHECK(extension);
EnsureBrowserWhenRequired(browser, view_type);
ExtensionHost* host =
@@ -287,8 +285,7 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost(
ExtensionHost* ExtensionProcessManager::CreateViewHost(
const GURL& url, Browser* browser, extensions::ViewType view_type) {
EnsureBrowserWhenRequired(browser, view_type);
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service = GetProfile()->GetExtensionService();
if (service) {
std::string extension_id = url.host();
if (url.SchemeIs(chrome::kChromeUIScheme) &&
@@ -330,7 +327,6 @@ ExtensionHost* ExtensionProcessManager::CreateInfobarHost(
ExtensionHost* ExtensionProcessManager::CreateBackgroundHost(
const Extension* extension, const GURL& url) {
- DVLOG(1) << "CreateBackgroundHost " << url.spec();
// Hosted apps are taken care of from BackgroundContentsService. Ignore them
// here.
if (extension->is_hosted_app())
@@ -391,8 +387,8 @@ const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost(
if (!render_view_host->GetSiteInstance())
return NULL;
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(GetProfile())->extension_service();
if (!service)
return NULL;
@@ -406,7 +402,7 @@ void ExtensionProcessManager::UnregisterRenderViewHost(
if (view == all_extension_views_.end())
return;
- OnRenderViewHostUnregistered(GetBrowserContext(), render_view_host);
+ OnRenderViewHostUnregistered(GetProfile(), render_view_host);
extensions::ViewType view_type = view->second;
all_extension_views_.erase(view);
@@ -617,8 +613,7 @@ void ExtensionProcessManager::Observe(
browser->profile() == GetProfile()->GetOffTheRecordProfile()))
break;
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service = GetProfile()->GetExtensionService();
if (!service || !service->is_ready())
break;
@@ -685,7 +680,7 @@ void ExtensionProcessManager::Observe(
// unregister the old RVH so it doesn't count as an active view that would
// keep the event page alive.
WebContents* contents = content::Source<WebContents>(source).ptr();
- if (contents->GetBrowserContext() != GetBrowserContext())
+ if (contents->GetBrowserContext() != GetProfile())
break;
typedef std::pair<RenderViewHost*, RenderViewHost*> RVHPair;
@@ -703,7 +698,7 @@ void ExtensionProcessManager::Observe(
case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: {
WebContents* contents = content::Source<WebContents>(source).ptr();
- if (contents->GetBrowserContext() != GetBrowserContext())
+ if (contents->GetBrowserContext() != GetProfile())
break;
const Extension* extension = GetExtensionForRenderViewHost(
contents->GetRenderViewHost());
@@ -714,7 +709,7 @@ void ExtensionProcessManager::Observe(
// available), so we need to wait until now to notify.
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED,
- content::Source<BrowserContext>(GetBrowserContext()),
+ content::Source<Profile>(GetProfile()),
content::Details<RenderViewHost>(contents->GetRenderViewHost()));
break;
}
@@ -737,8 +732,7 @@ void ExtensionProcessManager::OnDevToolsStateChanged(
RenderViewHost* rvh = agent_host->GetRenderViewHost();
// Ignore unrelated notifications.
if (!rvh ||
- rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() !=
- GetBrowserContext())
+ rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != GetProfile())
return;
if (extensions::GetViewType(WebContents::FromRenderViewHost(rvh)) !=
extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE)
@@ -756,7 +750,6 @@ void ExtensionProcessManager::OnDevToolsStateChanged(
}
void ExtensionProcessManager::CreateBackgroundHostsForProfileStartup() {
- DVLOG(1) << "CreateBackgroundHostsForProfileStartup";
// Don't load background hosts now if the loading should be deferred.
// Instead they will be loaded when a browser window for this profile
// (or an incognito profile from this profile) is ready, or when
@@ -764,52 +757,37 @@ void ExtensionProcessManager::CreateBackgroundHostsForProfileStartup() {
if (DeferLoadingBackgroundHosts())
return;
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
- DCHECK(service);
+ ExtensionService* service = GetProfile()->GetExtensionService();
for (ExtensionSet::const_iterator extension = service->extensions()->begin();
extension != service->extensions()->end(); ++extension) {
CreateBackgroundHostForExtensionLoad(this, extension->get());
extensions::RuntimeEventRouter::DispatchOnStartupEvent(
- GetBrowserContext(), (*extension)->id());
+ GetProfile(), (*extension)->id());
}
// Background pages should only be loaded once. To prevent any further loads
// occurring, we remove the notification listeners.
- BrowserContext* original_context =
- ExtensionsBrowserClient::Get()->GetOriginalContext(GetBrowserContext());
+ Profile* original_profile = GetProfile()->GetOriginalProfile();
registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY,
content::NotificationService::AllSources());
- if (registrar_.IsRegistered(
- this,
- chrome::NOTIFICATION_PROFILE_CREATED,
- content::Source<BrowserContext>(original_context))) {
- registrar_.Remove(this,
- chrome::NOTIFICATION_PROFILE_CREATED,
- content::Source<BrowserContext>(original_context));
- }
- if (registrar_.IsRegistered(
- this,
- chrome::NOTIFICATION_EXTENSIONS_READY,
- content::Source<BrowserContext>(original_context))) {
- registrar_.Remove(this,
- chrome::NOTIFICATION_EXTENSIONS_READY,
- content::Source<BrowserContext>(original_context));
- }
+ if (registrar_.IsRegistered(this, chrome::NOTIFICATION_PROFILE_CREATED,
+ content::Source<Profile>(original_profile)))
+ registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED,
+ content::Source<Profile>(original_profile));
+ if (registrar_.IsRegistered(this, chrome::NOTIFICATION_EXTENSIONS_READY,
+ content::Source<Profile>(original_profile)))
+ registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY,
+ content::Source<Profile>(original_profile));
}
Profile* ExtensionProcessManager::GetProfile() const {
return Profile::FromBrowserContext(site_instance_->GetBrowserContext());
}
-content::BrowserContext* ExtensionProcessManager::GetBrowserContext() const {
- return site_instance_->GetBrowserContext();
-}
-
void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host,
bool is_background) {
- DCHECK_EQ(site_instance_->GetBrowserContext(), host->browser_context());
+ DCHECK_EQ(site_instance_->GetBrowserContext(), host->profile());
if (is_background) {
background_hosts_.insert(host);
@@ -848,11 +826,11 @@ void ExtensionProcessManager::UnregisterExtension(
// decrement the lazy_keepalive_count to negative for the new extension
// instance when they are destroyed. Since we are erasing the background page
// data for the unloaded extension, unregister the RenderViewHosts too.
- BrowserContext* context = GetBrowserContext();
+ Profile* profile = GetProfile();
for (ExtensionRenderViews::iterator it = all_extension_views_.begin();
it != all_extension_views_.end(); ) {
if (GetExtensionID(it->first) == extension_id) {
- OnRenderViewHostUnregistered(context, it->first);
+ OnRenderViewHostUnregistered(profile, it->first);
all_extension_views_.erase(it++);
} else {
++it;
@@ -881,9 +859,18 @@ bool ExtensionProcessManager::DeferLoadingBackgroundHosts() const {
if (defer_background_host_creation_)
return true;
- // The extensions embedder may have special rules about background hosts.
- return ExtensionsBrowserClient::Get()->DeferLoadingBackgroundHosts(
- GetBrowserContext());
+ // The profile may not be valid yet if it is still being initialized.
+ // In that case, defer loading, since it depends on an initialized profile.
+ // http://crbug.com/222473
+ if (!g_browser_process->profile_manager()->IsValidProfile(GetProfile()))
+ return true;
+
+#if defined(OS_ANDROID)
+ return false;
+#else
+ return chrome::GetTotalBrowserCountForProfile(GetProfile()) == 0 &&
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList);
+#endif
}
//
@@ -891,28 +878,27 @@ bool ExtensionProcessManager::DeferLoadingBackgroundHosts() const {
//
IncognitoExtensionProcessManager::IncognitoExtensionProcessManager(
- BrowserContext* incognito_context,
- BrowserContext* original_context)
- : ExtensionProcessManager(incognito_context, original_context),
- original_manager_(extensions::ExtensionSystem::GetForBrowserContext(
- original_context)->process_manager()) {
- DCHECK(incognito_context->IsOffTheRecord());
+ Profile* profile)
+ : ExtensionProcessManager(profile),
+ original_manager_(extensions::ExtensionSystem::Get(
+ profile->GetOriginalProfile())->process_manager()) {
+ DCHECK(profile->IsOffTheRecord());
// The original profile will have its own ExtensionProcessManager to
// load the background pages of the spanning extensions. This process
// manager need only worry about the split mode extensions, which is handled
// in the NOTIFICATION_BROWSER_WINDOW_READY notification handler.
registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(profile->GetOriginalProfile()));
registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED,
- content::Source<BrowserContext>(original_context));
+ content::Source<Profile>(profile->GetOriginalProfile()));
}
IncognitoExtensionProcessManager::~IncognitoExtensionProcessManager() {
// TODO(yoz): This cleanup code belongs in the MenuManager.
// Remove "incognito" "split" mode context menu items.
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(GetProfile())->extension_service();
if (service)
service->menu_manager()->RemoveAllIncognitoContextItems();
}
@@ -952,8 +938,7 @@ ExtensionHost* IncognitoExtensionProcessManager::CreateBackgroundHost(
SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL(
const GURL& url) {
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service = GetProfile()->GetExtensionService();
if (service) {
const Extension* extension =
service->extensions()->GetExtensionOrAppByURL(url);
@@ -968,8 +953,7 @@ SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL(
bool IncognitoExtensionProcessManager::IsIncognitoEnabled(
const Extension* extension) {
// Keep in sync with duplicate in extension_info_map.cc.
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service = GetProfile()->GetExtensionService();
return extension_util::IsIncognitoEnabled(extension->id(), service);
}
@@ -989,8 +973,7 @@ void IncognitoExtensionProcessManager::Observe(
// On Chrome OS, a login screen is implemented as a browser.
// This browser has no extension service. In this case,
// service will be NULL.
- ExtensionService* service = ExtensionSystem::GetForBrowserContext(
- GetBrowserContext())->extension_service();
+ ExtensionService* service = GetProfile()->GetExtensionService();
if (service && service->is_ready())
CreateBackgroundHostsForProfileStartup();
}
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index c24a74b..3239bee 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -23,7 +23,6 @@ class GURL;
class Profile;
namespace content {
-class BrowserContext;
class DevToolsAgentHost;
class RenderViewHost;
class SiteInstance;
@@ -42,7 +41,7 @@ class ExtensionProcessManager : public content::NotificationObserver {
typedef std::set<extensions::ExtensionHost*> ExtensionHostSet;
typedef ExtensionHostSet::const_iterator const_iterator;
- static ExtensionProcessManager* Create(content::BrowserContext* context);
+ static ExtensionProcessManager* Create(Profile* profile);
virtual ~ExtensionProcessManager();
const ExtensionHostSet& background_hosts() const {
@@ -142,10 +141,7 @@ class ExtensionProcessManager : public content::NotificationObserver {
void DeferBackgroundHostCreation(bool defer);
protected:
- // If |context| is incognito pass the master context as |original_context|.
- // Otherwise pass the same context for both.
- ExtensionProcessManager(content::BrowserContext* context,
- content::BrowserContext* original_context);
+ explicit ExtensionProcessManager(Profile* profile);
// Called just after |host| is created so it can be registered in our lists.
void OnExtensionHostCreated(extensions::ExtensionHost* host,
@@ -167,9 +163,6 @@ class ExtensionProcessManager : public content::NotificationObserver {
// related SiteInstances.
Profile* GetProfile() const;
- // Returns the same value as GetProfile() as a BrowserContext.
- content::BrowserContext* GetBrowserContext() const;
-
content::NotificationRegistrar registrar_;
// The set of ExtensionHosts running viewless background extensions.
@@ -181,8 +174,6 @@ class ExtensionProcessManager : public content::NotificationObserver {
scoped_refptr<content::SiteInstance> site_instance_;
private:
- friend class ExtensionProcessManagerTest;
-
// Extra information we keep for each extension's background page.
struct BackgroundPageData;
typedef std::string ExtensionId;
@@ -216,7 +207,10 @@ class ExtensionProcessManager : public content::NotificationObserver {
// Clears background page data for this extension.
void ClearBackgroundPageData(const std::string& extension_id);
- // Returns true if loading background pages should be deferred.
+ // Returns true if loading background pages should be deferred. This is
+ // true if there are no browser windows open and the browser process was
+ // started to show the app launcher, or if DeferBackgroundHostCreation was
+ // called with true, or if the profile is not yet valid.
bool DeferLoadingBackgroundHosts() const;
void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached);
@@ -239,10 +233,10 @@ class ExtensionProcessManager : public content::NotificationObserver {
// If true, then creation of background hosts is suspended.
bool defer_background_host_creation_;
- base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
-
base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_;
+ base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
};
diff --git a/chrome/browser/extensions/extension_process_manager_browsertest.cc b/chrome/browser/extensions/extension_process_manager_browsertest.cc
deleted file mode 100644
index 3b04e7a..0000000
--- a/chrome/browser/extensions/extension_process_manager_browsertest.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2013 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 "chrome/browser/extensions/extension_process_manager.h"
-
-#include "chrome/browser/extensions/browser_action_test_util.h"
-#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/test/test_utils.h"
-
-using extensions::Extension;
-using extensions::ExtensionSystem;
-
-// Exists as a browser test because ExtensionHosts are hard to create without
-// a real browser.
-typedef ExtensionBrowserTest ExtensionProcessManagerBrowserTest;
-
-// Test that basic extension loading creates the appropriate ExtensionHosts
-// and background pages.
-IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest,
- ExtensionHostCreation) {
- ExtensionProcessManager* pm =
- ExtensionSystem::Get(profile())->process_manager();
-
- // Load an extension with a background page.
- scoped_refptr<const Extension> extension =
- LoadExtension(test_data_dir_.AppendASCII("api_test")
- .AppendASCII("browser_action")
- .AppendASCII("none"));
- ASSERT_TRUE(extension.get());
-
- // Process manager gains a background host.
- EXPECT_EQ(1u, pm->background_hosts().size());
- EXPECT_EQ(1u, pm->GetAllViews().size());
- EXPECT_TRUE(pm->GetBackgroundHostForExtension(extension->id()));
- EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()));
- EXPECT_EQ(1u, pm->GetRenderViewHostsForExtension(extension->id()).size());
- EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id()));
- EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get()));
-
- // Unload the extension.
- UnloadExtension(extension->id());
-
- // Background host disappears.
- EXPECT_EQ(0u, pm->background_hosts().size());
- EXPECT_EQ(0u, pm->GetAllViews().size());
- EXPECT_FALSE(pm->GetBackgroundHostForExtension(extension->id()));
- EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()));
- EXPECT_EQ(0u, pm->GetRenderViewHostsForExtension(extension->id()).size());
- EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id()));
- EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get()));
-
- // Load an extension with the ability to open a popup but no background
- // page.
- scoped_refptr<const Extension> popup =
- LoadExtension(test_data_dir_.AppendASCII("api_test")
- .AppendASCII("browser_action")
- .AppendASCII("popup"));
- ASSERT_TRUE(popup);
-
- // No background host was added.
- EXPECT_EQ(0u, pm->background_hosts().size());
- EXPECT_EQ(0u, pm->GetAllViews().size());
- EXPECT_FALSE(pm->GetBackgroundHostForExtension(popup->id()));
- EXPECT_EQ(0u, pm->GetRenderViewHostsForExtension(popup->id()).size());
- EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url()));
- EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id()));
- EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get()));
-
- // Simulate clicking on the action to open a popup.
- BrowserActionTestUtil test_util(browser());
- content::WindowedNotificationObserver frame_observer(
- content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
- content::NotificationService::AllSources());
- // Open popup in the first extension.
- test_util.Press(0);
- frame_observer.Wait();
- ASSERT_TRUE(test_util.HasPopup());
-
- // We now have a view, but still no background hosts.
- EXPECT_EQ(0u, pm->background_hosts().size());
- EXPECT_EQ(1u, pm->GetAllViews().size());
- EXPECT_FALSE(pm->GetBackgroundHostForExtension(popup->id()));
- EXPECT_EQ(1u, pm->GetRenderViewHostsForExtension(popup->id()).size());
- EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url()));
- EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id()));
- EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get()));
-}
diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/extension_process_manager_unittest.cc
index 70a01f8..bdd8d96 100644
--- a/chrome/browser/extensions/extension_process_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_process_manager_unittest.cc
@@ -3,11 +3,8 @@
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_process_manager.h"
-
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,6 +12,8 @@
using content::SiteInstance;
+namespace {
+
// make the test a PlatformTest to setup autorelease pools properly on mac
class ExtensionProcessManagerTest : public testing::Test {
public:
@@ -25,89 +24,9 @@ class ExtensionProcessManagerTest : public testing::Test {
virtual void SetUp() {
ExtensionErrorReporter::GetInstance()->ClearErrors();
}
-
- // Returns true if the notification |type| is registered for |manager| with
- // source |profile|. Pass NULL for |profile| for all sources.
- static bool IsRegistered(ExtensionProcessManager* manager,
- int type,
- TestingProfile* profile) {
- return manager->registrar_.IsRegistered(
- manager, type, content::Source<Profile>(profile));
- }
-
- // Allows access to a protected method.
- static Profile* GetProfile(ExtensionProcessManager* manager) {
- return manager->GetProfile();
- }
};
-// Test that notification registration works properly.
-TEST_F(ExtensionProcessManagerTest, ExtensionNotificationRegistration) {
- // Test for a normal profile.
- scoped_ptr<TestingProfile> original_profile(new TestingProfile);
- scoped_ptr<ExtensionProcessManager> manager1(
- ExtensionProcessManager::Create(original_profile.get()));
-
- EXPECT_EQ(original_profile.get(), GetProfile(manager1.get()));
- EXPECT_EQ(0u, manager1->background_hosts().size());
-
- // It observes some notifications from all sources.
- EXPECT_TRUE(IsRegistered(
- manager1.get(), chrome::NOTIFICATION_BROWSER_WINDOW_READY, NULL));
-
- // It observes other notifications from this profile.
- EXPECT_TRUE(IsRegistered(manager1.get(),
- chrome::NOTIFICATION_EXTENSIONS_READY,
- original_profile.get()));
- EXPECT_TRUE(IsRegistered(manager1.get(),
- chrome::NOTIFICATION_EXTENSION_LOADED,
- original_profile.get()));
- EXPECT_TRUE(IsRegistered(manager1.get(),
- chrome::NOTIFICATION_EXTENSION_UNLOADED,
- original_profile.get()));
- EXPECT_TRUE(IsRegistered(manager1.get(),
- chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
- original_profile.get()));
-
- // Now add an incognito profile associated with the master above.
- TestingProfile::Builder builder;
- builder.SetIncognito();
- scoped_ptr<TestingProfile> incognito_profile = builder.Build();
- incognito_profile->SetOriginalProfile(original_profile.get());
- scoped_ptr<ExtensionProcessManager> manager2(
- ExtensionProcessManager::Create(incognito_profile.get()));
-
- EXPECT_EQ(incognito_profile.get(), GetProfile(manager2.get()));
- EXPECT_EQ(0u, manager2->background_hosts().size());
-
- // Some notifications are observed for the original profile.
- EXPECT_TRUE(IsRegistered(manager2.get(),
- chrome::NOTIFICATION_EXTENSION_LOADED,
- original_profile.get()));
-
- // Some notifications are observed for the incognito profile.
- EXPECT_TRUE(IsRegistered(manager2.get(),
- chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
- incognito_profile.get()));
-
- // Some notifications are observed for both incognito and original.
- EXPECT_TRUE(IsRegistered(manager2.get(),
- chrome::NOTIFICATION_PROFILE_DESTROYED,
- original_profile.get()));
- EXPECT_TRUE(IsRegistered(manager2.get(),
- chrome::NOTIFICATION_PROFILE_DESTROYED,
- incognito_profile.get()));
-
- // Some are not observed at all.
- EXPECT_FALSE(IsRegistered(manager2.get(),
- chrome::NOTIFICATION_EXTENSIONS_READY,
- original_profile.get()));
-
- // This notification is observed for incognito profiles only.
- EXPECT_TRUE(IsRegistered(manager2.get(),
- chrome::NOTIFICATION_PROFILE_DESTROYED,
- incognito_profile.get()));
-}
+} // namespace
// Test that extensions get grouped in the right SiteInstance (and therefore
// process) based on their URLs.
diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc
index bb99cf1..df1bf3d 100644
--- a/chrome/browser/extensions/lazy_background_page_apitest.cc
+++ b/chrome/browser/extensions/lazy_background_page_apitest.cc
@@ -23,13 +23,13 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
-#include "extensions/common/switches.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
@@ -81,10 +81,8 @@ class LazyBackgroundPageApiTest : public ExtensionApiTest {
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionApiTest::SetUpCommandLine(command_line);
// Set shorter delays to prevent test timeouts.
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageSuspendingTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1");
}
// Loads the extension, which temporarily starts the lazy background page
diff --git a/chrome/browser/extensions/notifications_apitest.cc b/chrome/browser/extensions/notifications_apitest.cc
index dab664a..10d95b6 100644
--- a/chrome/browser/extensions/notifications_apitest.cc
+++ b/chrome/browser/extensions/notifications_apitest.cc
@@ -10,8 +10,8 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/lazy_background_page_test_util.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
-#include "extensions/common/switches.h"
#include "ui/message_center/message_center_switches.h"
#include "ui/message_center/message_center_util.h"
@@ -20,10 +20,8 @@ class NotificationIdleTest : public ExtensionApiTest {
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionApiTest::SetUpCommandLine(command_line);
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(
- extensions::switches::kEventPageSuspendingTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1");
}
const extensions::Extension* LoadExtensionAndWait(
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index be23e7c..0dca3f2 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1251,7 +1251,6 @@
'browser/extensions/extension_loading_browsertest.cc',
'browser/extensions/extension_messages_apitest.cc',
'browser/extensions/extension_override_apitest.cc',
- 'browser/extensions/extension_process_manager_browsertest.cc',
'browser/extensions/extension_resource_request_policy_apitest.cc',
'browser/extensions/extension_startup_browsertest.cc',
'browser/extensions/extension_storage_apitest.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index a39e514..8a16560 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -813,6 +813,14 @@ const char kEnableWebSocketOverSpdy[] = "enable-websocket-over-spdy";
// numbers.
const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports";
+// The time in seconds that an extension event page can be idle before it
+// is shut down.
+const char kEventPageIdleTime[] = "event-page-idle-time";
+
+// The time in seconds that an extension event page has between being notified
+// of its impending unload and that unload happening.
+const char kEventPageSuspendingTime[] = "event-page-unloading-time";
+
// Marks a renderer as extension process.
const char kExtensionProcess[] = "extension-process";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index af35c66..f91d696c 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -229,6 +229,8 @@ extern const char kEnableUnrestrictedSSL3Fallback[];
extern const char kEnableUserAlternateProtocolPorts[];
extern const char kEnableWatchdog[];
extern const char kEnableWebSocketOverSpdy[];
+extern const char kEventPageIdleTime[];
+extern const char kEventPageSuspendingTime[];
extern const char kExplicitlyAllowedPorts[];
extern const char kExtensionProcess[];
extern const char kExtensionsUpdateFrequency[];
diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h
index dd78811..4810836 100644
--- a/extensions/browser/extensions_browser_client.h
+++ b/extensions/browser/extensions_browser_client.h
@@ -29,7 +29,7 @@ class ExtensionsBrowserClient {
virtual bool IsSameContext(content::BrowserContext* first,
content::BrowserContext* second) = 0;
- // Returns true if |context| has an off-the-record context associated with it.
+ // Returns true if |context| has an off-the-record content associated with it.
virtual bool HasOffTheRecordContext(content::BrowserContext* context) = 0;
// Returns the off-the-record context associated with |context|. If |context|
@@ -39,15 +39,6 @@ class ExtensionsBrowserClient {
virtual content::BrowserContext* GetOffTheRecordContext(
content::BrowserContext* context) = 0;
- // Return the original "recording" context. This method returns |context| if
- // |context| is not incognito.
- virtual content::BrowserContext* GetOriginalContext(
- content::BrowserContext* context) = 0;
-
- // Returns true if loading background pages should be deferred.
- virtual bool DeferLoadingBackgroundHosts(
- content::BrowserContext* context) const = 0;
-
// Returns the single instance of |this|.
static ExtensionsBrowserClient* Get();
diff --git a/extensions/browser/lazy_background_task_queue_unittest.cc b/extensions/browser/lazy_background_task_queue_unittest.cc
index da2e5bc..27d8471 100644
--- a/extensions/browser/lazy_background_task_queue_unittest.cc
+++ b/extensions/browser/lazy_background_task_queue_unittest.cc
@@ -21,7 +21,7 @@ namespace extensions {
class TestExtensionProcessManager : public ExtensionProcessManager {
public:
explicit TestExtensionProcessManager(Profile* profile)
- : ExtensionProcessManager(profile, profile->GetOriginalProfile()),
+ : ExtensionProcessManager(profile),
create_count_(0) {}
virtual ~TestExtensionProcessManager() {}
diff --git a/extensions/common/switches.cc b/extensions/common/switches.cc
index 674bb03..3c8ab10 100644
--- a/extensions/common/switches.cc
+++ b/extensions/common/switches.cc
@@ -26,14 +26,6 @@ const char kEnableExperimentalExtensionApis[] =
// them in the chrome:extensions page.
const char kErrorConsole[] = "error-console";
-// The time in seconds that an extension event page can be idle before it
-// is shut down.
-const char kEventPageIdleTime[] = "event-page-idle-time";
-
-// The time in seconds that an extension event page has between being notified
-// of its impending unload and that unload happening.
-const char kEventPageSuspendingTime[] = "event-page-unloading-time";
-
// Enables extensions running scripts on chrome:// URLs.
// Extensions still need to explicitly request access to chrome:// URLs in the
// manifest.
diff --git a/extensions/common/switches.h b/extensions/common/switches.h
index e6ff310..43cc0f1 100644
--- a/extensions/common/switches.h
+++ b/extensions/common/switches.h
@@ -15,8 +15,6 @@ extern const char kAllowLegacyExtensionManifests[];
extern const char kAllowScriptingGallery[];
extern const char kEnableExperimentalExtensionApis[];
extern const char kErrorConsole[];
-extern const char kEventPageIdleTime[];
-extern const char kEventPageSuspendingTime[];
extern const char kExtensionsOnChromeURLs[];
extern const char kShowComponentExtensionOptions[];