diff options
75 files changed, 388 insertions, 395 deletions
diff --git a/apps/launcher.cc b/apps/launcher.cc index 603ffb5..9e0f6cf 100644 --- a/apps/launcher.cc +++ b/apps/launcher.cc @@ -18,7 +18,6 @@ #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_prefs.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" @@ -30,6 +29,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" #include "net/base/mime_util.h" #include "net/base/net_util.h" #include "url/gurl.h" @@ -270,7 +270,7 @@ class PlatformAppPathLauncher return; } - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = ExtensionSystem::Get(profile_)->process_manager(); ExtensionHost* host = process_manager->GetBackgroundHostForExtension(extension_->id()); diff --git a/apps/shell_window.cc b/apps/shell_window.cc index 7eff4ce..ed41645 100644 --- a/apps/shell_window.cc +++ b/apps/shell_window.cc @@ -12,7 +12,6 @@ #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_web_contents_observer.h" #include "chrome/browser/extensions/suggest_permission_util.h" @@ -34,6 +33,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "content/public/common/media_stream_request.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "third_party/skia/include/core/SkRegion.h" #include "ui/gfx/screen.h" diff --git a/chrome/browser/apps/window_controls_browsertest.cc b/chrome/browser/apps/window_controls_browsertest.cc index 4d534a8..7da2e46 100644 --- a/chrome/browser/apps/window_controls_browsertest.cc +++ b/chrome/browser/apps/window_controls_browsertest.cc @@ -3,12 +3,12 @@ // found in the LICENSE file. #include "chrome/browser/apps/app_browsertest_util.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/web_contents_view.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/browser/process_manager.h" class WindowControlsTest : public extensions::PlatformAppBrowserTest { protected: @@ -22,7 +22,7 @@ class WindowControlsTest : public extensions::PlatformAppBrowserTest { content::WebContents* WindowControlsTest::GetWebContentsForExtensionWindow( const extensions::Extension* extension) { - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profile())->process_manager(); // Lookup render view host for background page. @@ -32,9 +32,9 @@ content::WebContents* WindowControlsTest::GetWebContentsForExtensionWindow( extension_host->render_view_host(); // Go through all active views, looking for the first window of the extension - const ExtensionProcessManager::ViewSet all_views = + const extensions::ProcessManager::ViewSet all_views = process_manager->GetAllViews(); - ExtensionProcessManager::ViewSet::const_iterator it = all_views.begin(); + extensions::ProcessManager::ViewSet::const_iterator it = all_views.begin(); for (; it != all_views.end(); ++it) { content::RenderViewHost* host = *it; diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index b6db935..b692a77 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -32,7 +32,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_tab_util.h" @@ -77,6 +76,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/process_type.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/manifest.h" #include "extensions/common/view_type.h" #include "ui/gfx/codec/png_codec.h" @@ -522,9 +522,9 @@ void TabCountChangeObserver::CheckTabCount() { delete this; } -bool DidExtensionViewsStopLoading(ExtensionProcessManager* manager) { - ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); - for (ExtensionProcessManager::ViewSet::const_iterator iter = +bool DidExtensionViewsStopLoading(extensions::ProcessManager* manager) { + extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); + for (extensions::ProcessManager::ViewSet::const_iterator iter = all_views.begin(); iter != all_views.end(); ++iter) { if ((*iter)->IsLoading()) @@ -591,7 +591,7 @@ void ExtensionUninstallObserver::Observe( } ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver( - ExtensionProcessManager* manager, ExtensionService* service, + extensions::ProcessManager* manager, ExtensionService* service, AutomationProvider* automation, IPC::Message* reply_message) : manager_(manager), service_(service), @@ -691,7 +691,7 @@ void ExtensionUnloadNotificationObserver::Observe( } ExtensionsUpdatedObserver::ExtensionsUpdatedObserver( - ExtensionProcessManager* manager, AutomationProvider* automation, + extensions::ProcessManager* manager, AutomationProvider* automation, IPC::Message* reply_message) : manager_(manager), automation_(automation->AsWeakPtr()), reply_message_(reply_message), updater_finished_(false) { diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index f7dd78b..03b7808 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -53,7 +53,6 @@ class AutomationProvider; class BalloonCollection; class Browser; -class ExtensionProcessManager; class ExtensionService; class Notification; class Profile; @@ -78,6 +77,7 @@ class WebContents; namespace extensions { class Extension; +class ProcessManager; } namespace history { @@ -347,7 +347,7 @@ class ExtensionReadyNotificationObserver : public content::NotificationObserver { public: // Creates an observer that replies using the JSON automation interface. - ExtensionReadyNotificationObserver(ExtensionProcessManager* manager, + ExtensionReadyNotificationObserver(extensions::ProcessManager* manager, ExtensionService* service, AutomationProvider* automation, IPC::Message* reply_message); @@ -362,7 +362,7 @@ class ExtensionReadyNotificationObserver void Init(); content::NotificationRegistrar registrar_; - ExtensionProcessManager* manager_; + extensions::ProcessManager* manager_; ExtensionService* service_; base::WeakPtr<AutomationProvider> automation_; scoped_ptr<IPC::Message> reply_message_; @@ -399,7 +399,7 @@ class ExtensionUnloadNotificationObserver // observer waits until all updated extensions have actually been loaded. class ExtensionsUpdatedObserver : public content::NotificationObserver { public: - ExtensionsUpdatedObserver(ExtensionProcessManager* manager, + ExtensionsUpdatedObserver(extensions::ProcessManager* manager, AutomationProvider* automation, IPC::Message* reply_message); virtual ~ExtensionsUpdatedObserver(); @@ -416,7 +416,7 @@ class ExtensionsUpdatedObserver : public content::NotificationObserver { void MaybeReply(); content::NotificationRegistrar registrar_; - ExtensionProcessManager* manager_; + extensions::ProcessManager* manager_; base::WeakPtr<AutomationProvider> automation_; scoped_ptr<IPC::Message> reply_message_; bool updater_finished_; diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 7b42e6c..3d162eb 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -17,7 +17,6 @@ #include "base/values.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/automation/automation_provider_json.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" @@ -34,6 +33,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_constants.h" diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 389e86f..b05a8bc 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -54,7 +54,6 @@ #include "chrome/browser/extensions/extension_action.h" #include "chrome/browser/extensions/extension_action_manager.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_tab_util.h" @@ -138,6 +137,7 @@ #include "content/public/common/geoposition.h" #include "content/public/common/ssl_status.h" #include "content/public/common/webplugininfo.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "extensions/common/permissions/permission_set.h" #include "extensions/common/url_pattern.h" @@ -2259,13 +2259,13 @@ void TestingAutomationProvider::GetBrowserInfo( ProfileManager* profile_manager = g_browser_process->profile_manager(); std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); for (size_t i = 0; i < profiles.size(); ++i) { - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profiles[i])->process_manager(); if (!process_manager) continue; - const ExtensionProcessManager::ViewSet view_set = + const extensions::ProcessManager::ViewSet view_set = process_manager->GetAllViews(); - for (ExtensionProcessManager::ViewSet::const_iterator jt = + for (extensions::ProcessManager::ViewSet::const_iterator jt = view_set.begin(); jt != view_set.end(); ++jt) { content::RenderViewHost* render_view_host = *jt; @@ -3443,7 +3443,7 @@ void TestingAutomationProvider::InstallExtension( ExtensionService* service = extensions::ExtensionSystem::Get( browser->profile())->extension_service(); - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser->profile())->process_manager(); if (service && manager) { // The observer will delete itself when done. @@ -3656,7 +3656,7 @@ void TestingAutomationProvider::SetExtensionStateById( ExtensionService* service = extensions::ExtensionSystem::Get( browser->profile())->extension_service(); - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser->profile())->process_manager(); if (!service) { AutomationJSONReply(this, reply_message) @@ -3887,7 +3887,7 @@ void TestingAutomationProvider::UpdateExtensionsNow( return; } - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser->profile())->process_manager(); if (!manager) { AutomationJSONReply(this, reply_message).SendError( diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index f12cd1e..b994e24 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -36,7 +36,6 @@ #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_info_map.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_web_ui.h" @@ -130,6 +129,7 @@ #include "content/public/common/child_process_host.h" #include "content/public/common/content_descriptors.h" #include "content/public/common/url_utils.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "extensions/common/constants.h" #include "extensions/common/switches.h" @@ -1222,9 +1222,9 @@ bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( std::vector<Profile*> profiles = g_browser_process->profile_manager()-> GetLoadedProfiles(); for (size_t i = 0; i < profiles.size(); ++i) { - ExtensionProcessManager* epm = + extensions::ProcessManager* epm = extensions::ExtensionSystem::Get(profiles[i])->process_manager(); - for (ExtensionProcessManager::const_iterator iter = + for (extensions::ProcessManager::const_iterator iter = epm->background_hosts().begin(); iter != epm->background_hosts().end(); ++iter) { const extensions::ExtensionHost* host = *iter; diff --git a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc index 6d7956f..e805607 100644 --- a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc +++ b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc @@ -50,7 +50,7 @@ int ExtractProcessFromExtensionId(Profile* profile, const std::string& extension_id) { GURL extension_url = Extension::GetBaseURLFromExtensionId(extension_id); - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(profile)->process_manager(); SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url); diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc index f7867e9..b609723 100644 --- a/chrome/browser/devtools/devtools_sanity_browsertest.cc +++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc @@ -245,11 +245,11 @@ class DevToolsExtensionTest : public DevToolsSanityTest, base::MessageLoop::current()->PostDelayedTask( FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())-> process_manager(); - ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); - for (ExtensionProcessManager::ViewSet::const_iterator iter = + extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); + for (extensions::ProcessManager::ViewSet::const_iterator iter = all_views.begin(); iter != all_views.end();) { if (!(*iter)->IsLoading()) diff --git a/chrome/browser/extensions/alert_apitest.cc b/chrome/browser/extensions/alert_apitest.cc index f91d9b8..8d55c18 100644 --- a/chrome/browser/extensions/alert_apitest.cc +++ b/chrome/browser/extensions/alert_apitest.cc @@ -5,7 +5,6 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" @@ -13,6 +12,7 @@ #include "chrome/common/extensions/extension.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/render_view_host.h" +#include "extensions/browser/process_manager.h" IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlertBasic) { ASSERT_TRUE(RunExtensionTest("alert")) << message_; diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc index fb46466..3dba5f2 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc @@ -473,7 +473,7 @@ ItemInspectViewList DeveloperPrivateGetItemsInfoFunction:: ItemInspectViewList result; // Get the extension process's active views. - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = ExtensionSystem::Get(GetProfile())->process_manager(); GetInspectablePagesForExtensionProcess( extension, diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc index 7eaae89..5840e05 100644 --- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc @@ -612,7 +612,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DISABLED_CloseBackgroundPage) { const Extension* extension = GetSingleLoadedExtension(); // There is a background page and a browser action with no badge text. - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); ASSERT_TRUE(manager->GetBackgroundHostForExtension(extension->id())); ExtensionAction* action = GetBrowserAction(*extension); diff --git a/chrome/browser/extensions/api/management/management_browsertest.cc b/chrome/browser/extensions/api/management/management_browsertest.cc index f0036ff..b76c39b 100644 --- a/chrome/browser/extensions/api/management/management_browsertest.cc +++ b/chrome/browser/extensions/api/management/management_browsertest.cc @@ -46,7 +46,7 @@ class ExtensionManagementTest : public ExtensionBrowserTest { // Test that the extension's version from the manifest and reported by the // background page is correct. This is to ensure that the processes are in // sync with the Extension. - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())-> process_manager(); extensions::ExtensionHost* ext_host = @@ -138,7 +138,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_InstallRequiresConfirm) { // Tests that disabling and re-enabling an extension works. IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) { - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); ExtensionService* service = extensions::ExtensionSystem::Get( browser()->profile())->extension_service(); diff --git a/chrome/browser/extensions/api/messaging/extension_message_port.cc b/chrome/browser/extensions/api/messaging/extension_message_port.cc index 9e0ca61..a04237d 100644 --- a/chrome/browser/extensions/api/messaging/extension_message_port.cc +++ b/chrome/browser/extensions/api/messaging/extension_message_port.cc @@ -5,12 +5,12 @@ #include "chrome/browser/extensions/api/messaging/extension_message_port.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/background_info.h" #include "chrome/common/extensions/extension_messages.h" #include "content/public/browser/render_process_host.h" +#include "extensions/browser/process_manager.h" namespace extensions { @@ -56,7 +56,7 @@ void ExtensionMessagePort::DispatchOnMessage(const Message& message, void ExtensionMessagePort::IncrementLazyKeepaliveCount() { Profile* profile = Profile::FromBrowserContext(process_->GetBrowserContext()); - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = ExtensionSystem::Get(profile)->process_manager(); ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension())) @@ -70,7 +70,7 @@ void ExtensionMessagePort::IncrementLazyKeepaliveCount() { void ExtensionMessagePort::DecrementLazyKeepaliveCount() { Profile* profile = Profile::FromBrowserContext(process_->GetBrowserContext()); - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = ExtensionSystem::Get(profile)->process_manager(); ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); if (host && host == background_host_ptr_) diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc index fb557c3..7cf8190 100644 --- a/chrome/browser/extensions/api/messaging/message_service.cc +++ b/chrome/browser/extensions/api/messaging/message_service.cc @@ -17,7 +17,6 @@ #include "chrome/browser/extensions/api/messaging/incognito_connectability.h" #include "chrome/browser/extensions/api/messaging/native_message_port.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_tab_util.h" @@ -37,6 +36,7 @@ #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_handlers/incognito_info.h" #include "net/base/completion_callback.h" diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc index 3411a03..21fa8ae0 100644 --- a/chrome/browser/extensions/api/runtime/runtime_api.cc +++ b/chrome/browser/extensions/api/runtime/runtime_api.cc @@ -13,7 +13,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/updater/extension_updater.h" @@ -31,6 +30,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/error_utils.h" #include "url/gurl.h" #include "webkit/browser/fileapi/isolated_context.h" 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..b8bdaf2 100644 --- a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc +++ b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc @@ -7,11 +7,11 @@ #include "chrome/browser/extensions/extension_action.h" #include "chrome/browser/extensions/extension_action_manager.h" #include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/browser/extensions/extension_process_manager.h" #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/extensions/extension.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/switches.h" class SystemIndicatorApiTest : public ExtensionApiTest { @@ -60,7 +60,7 @@ IN_PROC_BROWSER_TEST_F(SystemIndicatorApiTest, SystemIndicator) { ASSERT_TRUE(extension) << message_; // Lazy Background Page has been shut down. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); diff --git a/chrome/browser/extensions/api/system_storage/system_storage_eject_apitest.cc b/chrome/browser/extensions/api/system_storage/system_storage_eject_apitest.cc index f366321..8e67fe6 100644 --- a/chrome/browser/extensions/api/system_storage/system_storage_eject_apitest.cc +++ b/chrome/browser/extensions/api/system_storage/system_storage_eject_apitest.cc @@ -10,7 +10,6 @@ #include "chrome/browser/extensions/api/system_storage/storage_api_test_util.h" #include "chrome/browser/extensions/api/system_storage/storage_info_provider.h" #include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/storage_monitor/storage_info.h" @@ -19,6 +18,7 @@ #include "chrome/common/extensions/extension.h" #include "content/public/browser/render_view_host.h" #include "content/public/test/test_utils.h" +#include "extensions/browser/process_manager.h" namespace { diff --git a/chrome/browser/extensions/browsertest_util.cc b/chrome/browser/extensions/browsertest_util.cc index 7a09359..b65be05 100644 --- a/chrome/browser/extensions/browsertest_util.cc +++ b/chrome/browser/extensions/browsertest_util.cc @@ -5,9 +5,9 @@ #include "chrome/browser/extensions/browsertest_util.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/browser/process_manager.h" #include "testing/gtest/include/gtest/gtest.h" namespace extensions { @@ -16,7 +16,7 @@ namespace browsertest_util { std::string ExecuteScriptInBackgroundPage(Profile* profile, const std::string& extension_id, const std::string& script) { - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(profile)->process_manager(); extensions::ExtensionHost* host = manager->GetBackgroundHostForExtension(extension_id); diff --git a/chrome/browser/extensions/chrome_notification_observer.cc b/chrome/browser/extensions/chrome_notification_observer.cc index 9327e52..af7f796 100644 --- a/chrome/browser/extensions/chrome_notification_observer.cc +++ b/chrome/browser/extensions/chrome_notification_observer.cc @@ -6,16 +6,16 @@ #include "base/logging.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "content/public/browser/notification_service.h" +#include "extensions/browser/process_manager.h" namespace extensions { ChromeNotificationObserver::ChromeNotificationObserver() { - // Notifications for ExtensionProcessManager + // Notifications for extensions::ProcessManager registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, content::NotificationService::AllSources()); } @@ -29,7 +29,7 @@ void ChromeNotificationObserver::OnBrowserWindowReady(Browser* browser) { // Inform the process manager for this profile that the window is ready. // We continue to observe the notification in case browser windows open for // a related incognito profile or other regular profiles. - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = ExtensionSystem::Get(profile)->process_manager(); if (!manager) // Tests may not have a process manager. return; @@ -42,7 +42,7 @@ void ChromeNotificationObserver::OnBrowserWindowReady(Browser* browser) { // non-incognito window opened. if (profile->IsOffTheRecord()) { Profile* original_profile = profile->GetOriginalProfile(); - ExtensionProcessManager* original_manager = + extensions::ProcessManager* original_manager = ExtensionSystem::Get(original_profile)->process_manager(); DCHECK(original_manager); DCHECK_EQ(original_profile, original_manager->GetBrowserContext()); diff --git a/chrome/browser/extensions/devtools_util.cc b/chrome/browser/extensions/devtools_util.cc index 987fe9e..5b35dfd 100644 --- a/chrome/browser/extensions/devtools_util.cc +++ b/chrome/browser/extensions/devtools_util.cc @@ -6,11 +6,11 @@ #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" #include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" namespace extensions { namespace devtools_util { diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc index abd05d0..8995bfa 100644 --- a/chrome/browser/extensions/event_router.cc +++ b/chrome/browser/extensions/event_router.cc @@ -19,7 +19,6 @@ #include "chrome/browser/extensions/api/web_request/web_request_api.h" #include "chrome/browser/extensions/event_names.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_util.h" @@ -35,6 +34,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" #include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/extension_api.h" #include "extensions/common/extension_urls.h" #include "extensions/common/manifest_handlers/incognito_info.h" @@ -699,7 +699,7 @@ void EventRouter::IncrementInFlightEvents(Profile* profile, // Only increment in-flight events if the lazy background page is active, // because that's the only time we'll get an ACK. if (BackgroundInfo::HasLazyBackgroundPage(extension)) { - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = ExtensionSystem::Get(profile)->process_manager(); ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id()); if (host) @@ -709,7 +709,7 @@ void EventRouter::IncrementInFlightEvents(Profile* profile, void EventRouter::OnEventAck(Profile* profile, const std::string& extension_id) { - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = ExtensionSystem::Get(profile)->process_manager(); ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id); // The event ACK is routed to the background host, so this should never be diff --git a/chrome/browser/extensions/extension_bindings_apitest.cc b/chrome/browser/extensions/extension_bindings_apitest.cc index 2fbaeb8..fb5c114 100644 --- a/chrome/browser/extensions/extension_bindings_apitest.cc +++ b/chrome/browser/extensions/extension_bindings_apitest.cc @@ -7,12 +7,12 @@ #include "chrome/browser/extensions/api/permissions/permissions_api.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/browser/process_manager.h" namespace extensions { namespace { @@ -42,7 +42,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) { test_data_dir_.AppendASCII("browsertest").AppendASCII("last_error"))); // Get the ExtensionHost that is hosting our background page. - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 7497884..d64b755 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -557,15 +557,17 @@ void ExtensionBrowserTest::NavigateInRenderer(content::WebContents* contents, } extensions::ExtensionHost* ExtensionBrowserTest::FindHostWithPath( - ExtensionProcessManager* manager, + extensions::ProcessManager* manager, const std::string& path, int expected_hosts) { extensions::ExtensionHost* host = NULL; int num_hosts = 0; - ExtensionProcessManager::ExtensionHostSet background_hosts = + extensions::ProcessManager::ExtensionHostSet background_hosts = manager->background_hosts(); - for (ExtensionProcessManager::const_iterator iter = background_hosts.begin(); - iter != background_hosts.end(); ++iter) { + for (extensions::ProcessManager::const_iterator iter = + background_hosts.begin(); + iter != background_hosts.end(); + ++iter) { if ((*iter)->GetURL().path() == path) { EXPECT_FALSE(host); host = *iter; diff --git a/chrome/browser/extensions/extension_browsertest.h b/chrome/browser/extensions/extension_browsertest.h index ff930ea..d1183cf 100644 --- a/chrome/browser/extensions/extension_browsertest.h +++ b/chrome/browser/extensions/extension_browsertest.h @@ -22,11 +22,14 @@ #include "content/public/browser/web_contents.h" #include "extensions/common/manifest.h" -class ExtensionProcessManager; class ExtensionService; class ExtensionSet; class Profile; +namespace extensions { +class ProcessManager; +} + // Base class for extension browser tests. Provides utilities for loading, // unloading, and installing extensions. class ExtensionBrowserTest : virtual public InProcessBrowserTest { @@ -262,9 +265,11 @@ class ExtensionBrowserTest : virtual public InProcessBrowserTest { // Looks for an ExtensionHost whose URL has the given path component // (including leading slash). Also verifies that the expected number of hosts // are loaded. - extensions::ExtensionHost* FindHostWithPath(ExtensionProcessManager* manager, - const std::string& path, - int expected_hosts); + extensions::ExtensionHost* FindHostWithPath( + extensions::ProcessManager* manager, + const std::string& path, + int expected_hosts); + // Returns // extensions::browsertest_util::ExecuteScriptInBackgroundPage(profile(), // extension_id, script). diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc index 4ee676a..f5eac57 100644 --- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc +++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc @@ -5,7 +5,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/notifications/balloon.h" @@ -24,6 +23,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/result_codes.h" +#include "extensions/browser/process_manager.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_switches.h" #include "ui/message_center/message_center_util.h" @@ -51,7 +51,7 @@ class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { return browser()->profile()->GetExtensionService(); } - ExtensionProcessManager* GetExtensionProcessManager() { + extensions::ProcessManager* GetProcessManager() { return extensions::ExtensionSystem::Get(browser()->profile())-> process_manager(); } @@ -60,14 +60,14 @@ class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { const Extension* extension = GetExtensionService()->GetExtensionById(extension_id, false); ASSERT_TRUE(extension); - extensions::ExtensionHost* extension_host = GetExtensionProcessManager()-> + extensions::ExtensionHost* extension_host = GetProcessManager()-> GetBackgroundHostForExtension(extension_id); ASSERT_TRUE(extension_host); base::KillProcess(extension_host->render_process_host()->GetHandle(), content::RESULT_CODE_KILLED, false); ASSERT_TRUE(WaitForExtensionCrash(extension_id)); - ASSERT_FALSE(GetExtensionProcessManager()-> + ASSERT_FALSE(GetProcessManager()-> GetBackgroundHostForExtension(extension_id)); // Wait for extension crash balloon to appear. @@ -78,12 +78,12 @@ class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { const Extension* extension = GetExtensionService()->extensions()->GetByID(extension_id); ASSERT_TRUE(extension); - extensions::ExtensionHost* extension_host = GetExtensionProcessManager()-> + extensions::ExtensionHost* extension_host = GetProcessManager()-> GetBackgroundHostForExtension(extension_id); ASSERT_TRUE(extension_host); - ExtensionProcessManager::ViewSet all_views = - GetExtensionProcessManager()->GetAllViews(); - ExtensionProcessManager::ViewSet::const_iterator it = + extensions::ProcessManager::ViewSet all_views = + GetProcessManager()->GetAllViews(); + extensions::ProcessManager::ViewSet::const_iterator it = all_views.find(extension_host->host_contents()->GetRenderViewHost()); ASSERT_FALSE(it == all_views.end()); ASSERT_TRUE(extension_host->IsRenderViewLive()); diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 9fc3be3..d05bcc8 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -322,7 +322,7 @@ void ExtensionFunctionDispatcher::DispatchWithCallback( // TODO(yzshen): There is some shared logic between this method and // DispatchOnIOThread(). It is nice to deduplicate. ExtensionService* service = profile()->GetExtensionService(); - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profile())->process_manager(); extensions::ProcessMap* process_map = service->process_map(); if (!service || !process_map) diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 4379dcb..77aee96 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -18,7 +18,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/error_console/error_console.h" #include "chrome/browser/extensions/event_router.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_tab_util.h" @@ -52,6 +51,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "extensions/browser/extension_error.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "extensions/common/extension_urls.h" #include "grit/browser_resources.h" @@ -480,15 +480,13 @@ void ExtensionHost::CloseContents(WebContents* contents) { } void ExtensionHost::WillRunJavaScriptDialog() { - ExtensionProcessManager* pm = - ExtensionSystem::Get(profile_)->process_manager(); + ProcessManager* pm = ExtensionSystem::Get(profile_)->process_manager(); if (pm) pm->IncrementLazyKeepaliveCount(extension()); } void ExtensionHost::DidCloseJavaScriptDialog() { - ExtensionProcessManager* pm = - ExtensionSystem::Get(profile_)->process_manager(); + ProcessManager* pm = ExtensionSystem::Get(profile_)->process_manager(); if (pm) pm->DecrementLazyKeepaliveCount(extension()); } @@ -573,15 +571,13 @@ void ExtensionHost::OnEventAck() { } void ExtensionHost::OnIncrementLazyKeepaliveCount() { - ExtensionProcessManager* pm = - ExtensionSystem::Get(profile_)->process_manager(); + ProcessManager* pm = ExtensionSystem::Get(profile_)->process_manager(); if (pm) pm->IncrementLazyKeepaliveCount(extension()); } void ExtensionHost::OnDecrementLazyKeepaliveCount() { - ExtensionProcessManager* pm = - ExtensionSystem::Get(profile_)->process_manager(); + ProcessManager* pm = ExtensionSystem::Get(profile_)->process_manager(); if (pm) pm->DecrementLazyKeepaliveCount(extension()); } diff --git a/chrome/browser/extensions/extension_host_factory.cc b/chrome/browser/extensions/extension_host_factory.cc index 96c86f3..bf464c2 100644 --- a/chrome/browser/extensions/extension_host_factory.cc +++ b/chrome/browser/extensions/extension_host_factory.cc @@ -5,13 +5,13 @@ #include "chrome/browser/extensions/extension_host_factory.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/url_constants.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/manifest_handlers/incognito_info.h" #include "extensions/common/view_type.h" @@ -34,7 +34,7 @@ ExtensionHost* CreateViewHostForExtension(const Extension* extension, DCHECK(profile); // A NULL browser may only be given for dialogs. DCHECK(browser || view_type == VIEW_TYPE_EXTENSION_DIALOG); - ExtensionProcessManager* pm = + ProcessManager* pm = ExtensionSystem::Get(profile)->process_manager(); content::SiteInstance* site_instance = pm->GetSiteInstanceForURL(url); ExtensionHost* host = diff --git a/chrome/browser/extensions/extension_info_map.cc b/chrome/browser/extensions/extension_info_map.cc index 4d4fb22..26361cf 100644 --- a/chrome/browser/extensions/extension_info_map.cc +++ b/chrome/browser/extensions/extension_info_map.cc @@ -90,7 +90,7 @@ base::Time ExtensionInfoMap::GetInstallTime( bool ExtensionInfoMap::IsIncognitoEnabled( const std::string& extension_id) const { - // Keep in sync with duplicate in extension_process_manager.cc. + // Keep in sync with duplicate in extensions/browser/process_manager.cc. ExtraDataMap::const_iterator iter = extra_data_.find(extension_id); if (iter != extra_data_.end()) return iter->second.incognito_enabled; diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 60520c9..ec17272 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -44,7 +44,6 @@ #include "chrome/browser/extensions/extension_error_ui.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_install_ui.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_sorting.h" #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/extensions/extension_sync_service.h" @@ -91,6 +90,7 @@ #include "content/public/browser/site_instance.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/url_data_source.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/constants.h" #include "extensions/common/error_utils.h" #include "extensions/common/extensions_client.h" @@ -690,7 +690,7 @@ void ExtensionService::ReloadExtension(const std::string extension_id) { // the inspector and hang onto a cookie for it, so that we can reattach // later. // TODO(yoz): this is not incognito-safe! - ExtensionProcessManager* manager = system_->process_manager(); + extensions::ProcessManager* manager = system_->process_manager(); extensions::ExtensionHost* host = manager->GetBackgroundHostForExtension(extension_id); if (host && DevToolsAgentHost::HasFor(host->render_view_host())) { @@ -2652,7 +2652,7 @@ bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { } bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { - ExtensionProcessManager* process_manager = system_->process_manager(); + extensions::ProcessManager* process_manager = system_->process_manager(); DCHECK(process_manager); extensions::ExtensionHost* host = process_manager->GetBackgroundHostForExtension(extension_id); diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h index b6c03a5..1d07aee 100644 --- a/chrome/browser/extensions/extension_service.h +++ b/chrome/browser/extensions/extension_service.h @@ -22,7 +22,6 @@ #include "chrome/browser/extensions/extension_function_histogram_value.h" #include "chrome/browser/extensions/extension_icon_manager.h" #include "chrome/browser/extensions/extension_prefs.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_sync_service.h" #include "chrome/browser/extensions/extensions_quota_service.h" #include "chrome/browser/extensions/external_provider_interface.h" @@ -39,6 +38,7 @@ #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/manifest.h" #include "extensions/common/one_shot_event.h" diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index ce4aded..e4258f7 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -573,10 +573,10 @@ void ExtensionServiceTestBase::InitializeEmptyExtensionService() { InitializeExtensionService(CreateDefaultInitParams()); } -void ExtensionServiceTestBase::InitializeExtensionProcessManager() { +void ExtensionServiceTestBase::InitializeProcessManager() { static_cast<extensions::TestExtensionSystem*>( ExtensionSystem::Get(profile_.get()))-> - CreateExtensionProcessManager(); + CreateProcessManager(); } void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() { @@ -3031,7 +3031,7 @@ TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) { InitPluginService(); InitializeEmptyExtensionService(); - InitializeExtensionProcessManager(); + InitializeProcessManager(); service_->set_show_extensions_prompts(true); // Start by canceling any install prompts. @@ -3986,7 +3986,7 @@ TEST_F(ExtensionServiceTest, ReloadExtensions) { // Tests reloading an extension. TEST_F(ExtensionServiceTest, ReloadExtension) { InitializeEmptyExtensionService(); - InitializeExtensionProcessManager(); + InitializeProcessManager(); // Simple extension that should install without error. const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; @@ -5440,7 +5440,7 @@ TEST_F(ExtensionServiceTest, GetSyncDataFilter) { TEST_F(ExtensionServiceTest, GetSyncExtensionDataUserSettings) { InitializeEmptyExtensionService(); - InitializeExtensionProcessManager(); + InitializeProcessManager(); InitializeExtensionSyncService(); InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); const Extension* extension = service_->GetInstalledExtension(good_crx); @@ -5740,7 +5740,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataWrongType) { TEST_F(ExtensionServiceTest, ProcessSyncDataSettings) { InitializeEmptyExtensionService(); - InitializeExtensionProcessManager(); + InitializeProcessManager(); InitializeExtensionSyncService(); TestSyncProcessorStub processor; extension_sync_service_->MergeDataAndStartSyncing( diff --git a/chrome/browser/extensions/extension_service_unittest.h b/chrome/browser/extensions/extension_service_unittest.h index f58bdc4..44a1d43 100644 --- a/chrome/browser/extensions/extension_service_unittest.h +++ b/chrome/browser/extensions/extension_service_unittest.h @@ -54,7 +54,7 @@ class ExtensionServiceTestBase : public testing::Test { void InitializeEmptyExtensionService(); - void InitializeExtensionProcessManager(); + void InitializeProcessManager(); void InitializeExtensionServiceWithUpdater(); diff --git a/chrome/browser/extensions/extension_system.cc b/chrome/browser/extensions/extension_system.cc index b7099d2..f5a4ae5 100644 --- a/chrome/browser/extensions/extension_system.cc +++ b/chrome/browser/extensions/extension_system.cc @@ -21,7 +21,6 @@ #include "chrome/browser/extensions/extension_pref_value_map.h" #include "chrome/browser/extensions/extension_pref_value_map_factory.h" #include "chrome/browser/extensions/extension_prefs.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/browser/extensions/extension_util.h" @@ -43,6 +42,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/url_data_source.h" #include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/constants.h" #include "extensions/common/manifest.h" @@ -307,7 +307,7 @@ ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) shared_ = ExtensionSystemSharedFactory::GetForProfile(profile); if (profile->IsOffTheRecord()) { - extension_process_manager_.reset(ExtensionProcessManager::Create(profile)); + process_manager_.reset(ProcessManager::Create(profile)); } else { shared_->InitPrefs(); } @@ -317,7 +317,7 @@ ExtensionSystemImpl::~ExtensionSystemImpl() { } void ExtensionSystemImpl::Shutdown() { - extension_process_manager_.reset(); + process_manager_.reset(); } void ExtensionSystemImpl::InitForRegularProfile( @@ -327,13 +327,12 @@ void ExtensionSystemImpl::InitForRegularProfile( if (user_script_master() || extension_service()) return; // Already initialized. - // The ExtensionInfoMap needs to be created before the - // ExtensionProcessManager. + // The ExtensionInfoMap needs to be created before the ProcessManager. shared_->info_map(); - extension_process_manager_.reset(ExtensionProcessManager::Create(profile_)); + process_manager_.reset(ProcessManager::Create(profile_)); - extension_process_manager_->DeferBackgroundHostCreation( + process_manager_->DeferBackgroundHostCreation( defer_background_creation); shared_->Init(extensions_enabled); @@ -351,8 +350,8 @@ UserScriptMaster* ExtensionSystemImpl::user_script_master() { return shared_->user_script_master(); } -ExtensionProcessManager* ExtensionSystemImpl::process_manager() { - return extension_process_manager_.get(); +ProcessManager* ExtensionSystemImpl::process_manager() { + return process_manager_.get(); } StateStore* ExtensionSystemImpl::state_store() { diff --git a/chrome/browser/extensions/extension_system.h b/chrome/browser/extensions/extension_system.h index 663c176..93be7be 100644 --- a/chrome/browser/extensions/extension_system.h +++ b/chrome/browser/extensions/extension_system.h @@ -14,7 +14,6 @@ #include "extensions/common/one_shot_event.h" class ExtensionInfoMap; -class ExtensionProcessManager; class ExtensionService; class Profile; @@ -39,6 +38,7 @@ class ExtensionWarningService; class LazyBackgroundTaskQueue; class ManagementPolicy; class NavigationObserver; +class ProcessManager; class StandardManagementPolicyProvider; class StateStore; class UserScriptMaster; @@ -68,8 +68,8 @@ class ExtensionSystem : public BrowserContextKeyedService { // Component extensions are always enabled, external and user extensions // are controlled by |extensions_enabled|. If |defer_background_creation| is // true, then creation of background extension RenderViews will be deferred - // until ExtensionProcessManager::DeferBackgroundHostCreation is called with - // |defer| set to false. + // until extensions::ProcessManager::DeferBackgroundHostCreation is called + // with |defer| set to false. virtual void InitForRegularProfile(bool extensions_enabled, bool defer_background_creation) = 0; @@ -84,8 +84,8 @@ class ExtensionSystem : public BrowserContextKeyedService { // The UserScriptMaster is created at startup. virtual UserScriptMaster* user_script_master() = 0; - // The ExtensionProcessManager is created at startup. - virtual ExtensionProcessManager* process_manager() = 0; + // The ProcessManager is created at startup. + virtual ProcessManager* process_manager() = 0; // The StateStore is created at startup. virtual StateStore* state_store() = 0; @@ -149,7 +149,7 @@ class ExtensionSystemImpl : public ExtensionSystem { virtual ExtensionService* extension_service() OVERRIDE; // shared virtual ManagementPolicy* management_policy() OVERRIDE; // shared virtual UserScriptMaster* user_script_master() OVERRIDE; // shared - virtual ExtensionProcessManager* process_manager() OVERRIDE; + virtual ProcessManager* process_manager() OVERRIDE; virtual StateStore* state_store() OVERRIDE; // shared virtual StateStore* rules_store() OVERRIDE; // shared virtual LazyBackgroundTaskQueue* lazy_background_task_queue() @@ -221,7 +221,7 @@ class ExtensionSystemImpl : public ExtensionSystem { // ExtensionService depends on StateStore and Blacklist. scoped_ptr<ExtensionService> extension_service_; scoped_ptr<ManagementPolicy> management_policy_; - // extension_info_map_ needs to outlive extension_process_manager_. + // extension_info_map_ needs to outlive process_manager_. scoped_refptr<ExtensionInfoMap> extension_info_map_; scoped_ptr<ExtensionWarningService> extension_warning_service_; scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; @@ -239,11 +239,11 @@ class ExtensionSystemImpl : public ExtensionSystem { Shared* shared_; - // |extension_process_manager_| must be destroyed before the Profile's - // |io_data_|. While |extension_process_manager_| still lives, we handle - // incoming resource requests from extension processes and those require - // access to the ResourceContext owned by |io_data_|. - scoped_ptr<ExtensionProcessManager> extension_process_manager_; + // |process_manager_| must be destroyed before the Profile's |io_data_|. While + // |process_manager_| still lives, we handle incoming resource requests from + // extension processes and those require access to the ResourceContext owned + // by |io_data_|. + scoped_ptr<ProcessManager> process_manager_; DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); }; diff --git a/chrome/browser/extensions/extension_test_notification_observer.cc b/chrome/browser/extensions/extension_test_notification_observer.cc index f8b7a6d..77c140d 100644 --- a/chrome/browser/extensions/extension_test_notification_observer.cc +++ b/chrome/browser/extensions/extension_test_notification_observer.cc @@ -4,7 +4,6 @@ #include "chrome/browser/extensions/extension_test_notification_observer.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile_manager.h" @@ -15,6 +14,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host.h" #include "content/public/test/test_utils.h" +#include "extensions/browser/process_manager.h" using extensions::Extension; @@ -99,10 +99,10 @@ bool ExtensionTestNotificationObserver::WaitForPageActionVisibilityChangeTo( } bool ExtensionTestNotificationObserver::WaitForExtensionViewsToLoad() { - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(GetProfile())->process_manager(); - ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); - for (ExtensionProcessManager::ViewSet::const_iterator iter = + extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); + for (extensions::ProcessManager::ViewSet::const_iterator iter = all_views.begin(); iter != all_views.end();) { if (!(*iter)->IsLoading()) { diff --git a/chrome/browser/extensions/gpu_browsertest.cc b/chrome/browser/extensions/gpu_browsertest.cc index ff34a35..b22722a 100644 --- a/chrome/browser/extensions/gpu_browsertest.cc +++ b/chrome/browser/extensions/gpu_browsertest.cc @@ -8,10 +8,10 @@ #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/ui/browser.h" #include "content/public/browser/render_view_host.h" +#include "extensions/browser/process_manager.h" #include "webkit/common/webpreferences.h" // Tests that GPU acceleration is disabled for extension background @@ -22,7 +22,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) { .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") .AppendASCII("1.0.0.0"))); - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); extensions::ExtensionHost* host = FindHostWithPath(manager, "/backgroundpage.html", 1); diff --git a/chrome/browser/extensions/gtalk_extension_browsertest.cc b/chrome/browser/extensions/gtalk_extension_browsertest.cc index 694765d..b2c720f 100644 --- a/chrome/browser/extensions/gtalk_extension_browsertest.cc +++ b/chrome/browser/extensions/gtalk_extension_browsertest.cc @@ -7,7 +7,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" @@ -18,6 +17,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/browser/process_manager.h" using content::RenderViewHost; using content::WebContents; @@ -25,7 +25,7 @@ using extensions::Extension; class GtalkExtensionTest : public ExtensionBrowserTest { protected: - ExtensionProcessManager* GetExtensionProcessManager() { + extensions::ProcessManager* GetProcessManager() { return extensions::ExtensionSystem::Get(browser()->profile())-> process_manager(); } @@ -54,10 +54,10 @@ class GtalkExtensionTest : public ExtensionBrowserTest { } std::vector<RenderViewHost*> GetMatchingViews(std::string url_query) { - ExtensionProcessManager* manager = GetExtensionProcessManager(); - ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); + extensions::ProcessManager* manager = GetProcessManager(); + extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); std::vector<RenderViewHost*> matching_views; - for (ExtensionProcessManager::ViewSet::const_iterator iter = + for (extensions::ProcessManager::ViewSet::const_iterator iter = all_views.begin(); iter != all_views.end(); ++iter) { WebContents* web_contents = WebContents::FromRenderViewHost(*iter); std::string url = web_contents->GetURL().spec(); diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc index bb99cf1..f526a74 100644 --- a/chrome/browser/extensions/lazy_background_page_apitest.cc +++ b/chrome/browser/extensions/lazy_background_page_apitest.cc @@ -104,7 +104,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BrowserActionCreateTab) { ASSERT_TRUE(LoadExtensionAndWait("browser_action_create_tab")); // Lazy Background Page doesn't exist yet. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); int num_tabs_before = browser()->tab_strip_model()->count(); @@ -128,7 +128,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, ASSERT_TRUE(LoadExtensionAndWait("browser_action_with_callback")); // Lazy Background Page doesn't exist yet. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); int num_tabs_before = browser()->tab_strip_model()->count(); @@ -151,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, BroadcastEvent) { ASSERT_TRUE(extension); // Lazy Background Page doesn't exist yet. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); int num_page_actions = browser()->window()->GetLocationBar()-> @@ -182,7 +182,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Filters) { ASSERT_TRUE(extension); // Lazy Background Page doesn't exist yet. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); @@ -201,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnInstalled) { EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); // Lazy Background Page has been shut down. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); } @@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForView) { // Lazy Background Page still exists, because the extension created a new tab // to an extension page. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); @@ -252,7 +252,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, WaitForRequest) { EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); // Lazy Background Page still exists, because the extension started a request. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); extensions::ExtensionHost* host = pm->GetBackgroundHostForExtension(last_loaded_extension_id()); @@ -293,7 +293,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, MAYBE_WaitForNTP) { // Lazy Background Page still exists, because the extension created a new tab // to an extension page. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); @@ -329,9 +329,9 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, MAYBE_IncognitoSplitMode) { } // Lazy Background Page doesn't exist yet. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); - ExtensionProcessManager* pmi = + extensions::ProcessManager* pmi = extensions::ExtensionSystem::Get(incognito_browser->profile())-> process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); @@ -388,7 +388,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, Messaging) { ASSERT_TRUE(LoadExtensionAndWait("messaging")); // Lazy Background Page doesn't exist yet. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); EXPECT_EQ(1, browser()->tab_strip_model()->count()); @@ -420,7 +420,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnUnload) { ASSERT_TRUE(LoadExtensionAndWait("on_unload")); // Lazy Background Page has been shut down. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); @@ -483,7 +483,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, UpdateExtensionsPage) { // Lazy Background Page still exists, because the extension created a new tab // to an extension page. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); EXPECT_TRUE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); diff --git a/chrome/browser/extensions/notifications_apitest.cc b/chrome/browser/extensions/notifications_apitest.cc index dab664a..b86ffd0 100644 --- a/chrome/browser/extensions/notifications_apitest.cc +++ b/chrome/browser/extensions/notifications_apitest.cc @@ -4,13 +4,13 @@ #include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/extensions/lazy_background_page_test_util.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/profiles/profile.h" #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/extensions/extension.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/switches.h" #include "ui/message_center/message_center_switches.h" #include "ui/message_center/message_center_util.h" @@ -77,7 +77,7 @@ IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) { ASSERT_TRUE(extension) << message_; // Lazy Background Page has been shut down. - ExtensionProcessManager* pm = + extensions::ProcessManager* pm = extensions::ExtensionSystem::Get(profile())->process_manager(); EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); } diff --git a/chrome/browser/extensions/process_management_browsertest.cc b/chrome/browser/extensions/process_management_browsertest.cc index e607d26..de2e749 100644 --- a/chrome/browser/extensions/process_management_browsertest.cc +++ b/chrome/browser/extensions/process_management_browsertest.cc @@ -5,7 +5,6 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" @@ -18,6 +17,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/switches.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" @@ -140,7 +140,7 @@ IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ProcessOverflow) { browser()->tab_strip_model()->GetWebContentsAt(8)->GetRenderProcessHost(); // Get extension processes. - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(browser()->profile())-> process_manager(); content::RenderProcessHost* extension1_host = @@ -232,9 +232,9 @@ IN_PROC_BROWSER_TEST_F(ProcessManagementTest, MAYBE_ExtensionProcessBalancing) { std::set<int> process_ids; Profile* profile = browser()->profile(); - ExtensionProcessManager* epm = extensions::ExtensionSystem::Get(profile)-> + extensions::ProcessManager* epm = extensions::ExtensionSystem::Get(profile)-> process_manager(); - for (ExtensionProcessManager::const_iterator iter = + for (extensions::ProcessManager::const_iterator iter = epm->background_hosts().begin(); iter != epm->background_hosts().end(); ++iter) { process_ids.insert((*iter)->render_process_host()->GetID()); diff --git a/chrome/browser/extensions/extension_process_manager_browsertest.cc b/chrome/browser/extensions/process_manager_browsertest.cc index b4de778..af7c908 100644 --- a/chrome/browser/extensions/extension_process_manager_browsertest.cc +++ b/chrome/browser/extensions/process_manager_browsertest.cc @@ -2,7 +2,7 @@ // 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 "extensions/browser/process_manager.h" #include "chrome/browser/extensions/browser_action_test_util.h" #include "chrome/browser/extensions/extension_browsertest.h" @@ -12,19 +12,17 @@ #include "content/public/browser/notification_service.h" #include "content/public/test/test_utils.h" -using extensions::Extension; -using extensions::ExtensionSystem; +namespace extensions { // Exists as a browser test because ExtensionHosts are hard to create without // a real browser. -typedef ExtensionBrowserTest ExtensionProcessManagerBrowserTest; +typedef ExtensionBrowserTest ProcessManagerBrowserTest; // Test that basic extension loading creates the appropriate ExtensionHosts // and background pages. -IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest, +IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, ExtensionHostCreation) { - ExtensionProcessManager* pm = - ExtensionSystem::Get(profile())->process_manager(); + ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); // We start with no background hosts. ASSERT_EQ(0u, pm->background_hosts().size()); @@ -63,10 +61,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest, // background page and that clicking on the action creates the appropriate // ExtensionHost. // Disabled due to flake, see http://crbug.com/315242 -IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest, +IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, DISABLED_PopupHostCreation) { - ExtensionProcessManager* pm = - ExtensionSystem::Get(profile())->process_manager(); + ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); // Load an extension with the ability to open a popup but no background // page. @@ -104,3 +101,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest, EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id())); EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get())); } + +} // namespace extensions diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/process_manager_unittest.cc index c8ca541..9ad05db 100644 --- a/chrome/browser/extensions/extension_process_manager_unittest.cc +++ b/chrome/browser/extensions/process_manager_unittest.cc @@ -2,7 +2,7 @@ // 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 "extensions/browser/process_manager.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_error_reporter.h" @@ -15,8 +15,15 @@ using content::SiteInstance; +namespace extensions { + +// TODO(jamescook): Convert this from TestingProfile to TestBrowserContext and +// move to extensions/browser. This is dependent on ExtensionPrefs being +// converted and ExtensionSystem being converted or eliminated. +// http://crbug.com/315855 + // make the test a PlatformTest to setup autorelease pools properly on mac -class ExtensionProcessManagerTest : public testing::Test { +class ProcessManagerTest : public testing::Test { public: static void SetUpTestCase() { ExtensionErrorReporter::Init(false); // no noisy errors @@ -28,20 +35,20 @@ class ExtensionProcessManagerTest : public testing::Test { // 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) { + static bool IsRegistered(ProcessManager* manager, + int type, + TestingProfile* profile) { return manager->registrar_.IsRegistered( manager, type, content::Source<Profile>(profile)); } }; // Test that notification registration works properly. -TEST_F(ExtensionProcessManagerTest, ExtensionNotificationRegistration) { +TEST_F(ProcessManagerTest, ExtensionNotificationRegistration) { // Test for a normal profile. scoped_ptr<TestingProfile> original_profile(new TestingProfile); - scoped_ptr<ExtensionProcessManager> manager1( - ExtensionProcessManager::Create(original_profile.get())); + scoped_ptr<ProcessManager> manager1( + ProcessManager::Create(original_profile.get())); EXPECT_EQ(original_profile.get(), manager1->GetBrowserContext()); EXPECT_EQ(0u, manager1->background_hosts().size()); @@ -65,8 +72,8 @@ TEST_F(ExtensionProcessManagerTest, ExtensionNotificationRegistration) { builder.SetIncognito(); scoped_ptr<TestingProfile> incognito_profile = builder.Build(); incognito_profile->SetOriginalProfile(original_profile.get()); - scoped_ptr<ExtensionProcessManager> manager2( - ExtensionProcessManager::Create(incognito_profile.get())); + scoped_ptr<ProcessManager> manager2( + ProcessManager::Create(incognito_profile.get())); EXPECT_EQ(incognito_profile.get(), manager2->GetBrowserContext()); EXPECT_EQ(0u, manager2->background_hosts().size()); @@ -102,17 +109,15 @@ TEST_F(ExtensionProcessManagerTest, ExtensionNotificationRegistration) { // Test that extensions get grouped in the right SiteInstance (and therefore // process) based on their URLs. -TEST_F(ExtensionProcessManagerTest, ProcessGrouping) { +TEST_F(ProcessManagerTest, ProcessGrouping) { // Extensions in different profiles should always be different SiteInstances. // Note: we don't initialize these, since we're not testing that // functionality. This means we can get away with a NULL UserScriptMaster. TestingProfile profile1; - scoped_ptr<ExtensionProcessManager> manager1( - ExtensionProcessManager::Create(&profile1)); + scoped_ptr<ProcessManager> manager1(ProcessManager::Create(&profile1)); TestingProfile profile2; - scoped_ptr<ExtensionProcessManager> manager2( - ExtensionProcessManager::Create(&profile2)); + scoped_ptr<ProcessManager> manager2(ProcessManager::Create(&profile2)); // Extensions with common origins ("scheme://id/") should be grouped in the // same SiteInstance. @@ -134,3 +139,5 @@ TEST_F(ExtensionProcessManagerTest, ProcessGrouping) { manager2->GetSiteInstanceForURL(ext1_url1); EXPECT_NE(site11, other_profile_site); } + +} // namespace extensions diff --git a/chrome/browser/extensions/process_map.h b/chrome/browser/extensions/process_map.h index 73439ad..440e7a9 100644 --- a/chrome/browser/extensions/process_map.h +++ b/chrome/browser/extensions/process_map.h @@ -53,7 +53,7 @@ namespace extensions { // extensions (not hosted apps), and you are on the UI thread, and you don't // care about incognito version of this extension (or vice versa if you're in // an incognito profile) then use -// ExtensionProcessManager::GetSiteInstanceForURL()->[Has|Get]Process(). +// extensions::ProcessManager::GetSiteInstanceForURL()->[Has|Get]Process(). // // 3. The process ids contained in this class are *not limited* to the Profile // you got this map from. They can also be associated with that profile's diff --git a/chrome/browser/extensions/suggest_permission_util.cc b/chrome/browser/extensions/suggest_permission_util.cc index cd9e1db..7eb1e10 100644 --- a/chrome/browser/extensions/suggest_permission_util.cc +++ b/chrome/browser/extensions/suggest_permission_util.cc @@ -4,12 +4,12 @@ #include "chrome/browser/extensions/suggest_permission_util.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_messages.h" #include "content/public/browser/render_view_host.h" #include "content/public/common/console_message_level.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/permissions/permissions_info.h" using content::CONSOLE_MESSAGE_LEVEL_WARNING; @@ -47,7 +47,7 @@ void SuggestAPIPermissionInDevToolsConsole(APIPermission::ID permission, void SuggestAPIPermissionInDevToolsConsole(APIPermission::ID permission, const Extension* extension, Profile* profile) { - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profile)->process_manager(); std::set<content::RenderViewHost*> views = diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc index a628a9f..e6d448d 100644 --- a/chrome/browser/extensions/test_extension_system.cc +++ b/chrome/browser/extensions/test_extension_system.cc @@ -14,7 +14,6 @@ #include "chrome/browser/extensions/extension_pref_value_map_factory.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_prefs_factory.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/management_policy.h" @@ -25,6 +24,7 @@ #include "chrome/browser/value_store/testing_value_store.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/browser_thread.h" +#include "extensions/browser/process_manager.h" using content::BrowserThread; @@ -41,16 +41,15 @@ TestExtensionSystem::~TestExtensionSystem() { } void TestExtensionSystem::Shutdown() { - extension_process_manager_.reset(); + process_manager_.reset(); } -void TestExtensionSystem::CreateExtensionProcessManager() { - extension_process_manager_.reset(ExtensionProcessManager::Create(profile_)); +void TestExtensionSystem::CreateProcessManager() { + process_manager_.reset(ProcessManager::Create(profile_)); } -void TestExtensionSystem::SetExtensionProcessManager( - ExtensionProcessManager* manager) { - extension_process_manager_.reset(manager); +void TestExtensionSystem::SetProcessManager(ProcessManager* manager) { + process_manager_.reset(manager); } ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs( @@ -121,8 +120,8 @@ UserScriptMaster* TestExtensionSystem::user_script_master() { return NULL; } -ExtensionProcessManager* TestExtensionSystem::process_manager() { - return extension_process_manager_.get(); +ProcessManager* TestExtensionSystem::process_manager() { + return process_manager_.get(); } StateStore* TestExtensionSystem::state_store() { diff --git a/chrome/browser/extensions/test_extension_system.h b/chrome/browser/extensions/test_extension_system.h index cab117b..7c5cc9a 100644 --- a/chrome/browser/extensions/test_extension_system.h +++ b/chrome/browser/extensions/test_extension_system.h @@ -44,13 +44,12 @@ class TestExtensionSystem : public ExtensionSystem { const base::FilePath& install_directory, bool autoupdate_enabled); - // Creates an ExtensionProcessManager. If not invoked, the - // ExtensionProcessManager is NULL. - void CreateExtensionProcessManager(); + // Creates a ProcessManager. If not invoked, the ProcessManager is NULL. + void CreateProcessManager(); - // Allows the ExtensionProcessManager to be overriden, for example by a - // stub implementation. Takes ownership of |manager|. - void SetExtensionProcessManager(ExtensionProcessManager* manager); + // Allows the ProcessManager to be overriden, for example by a stub + // implementation. Takes ownership of |manager|. + void SetProcessManager(ProcessManager* manager); void CreateSocketManager(); @@ -60,7 +59,7 @@ class TestExtensionSystem : public ExtensionSystem { virtual ExtensionService* extension_service() OVERRIDE; virtual ManagementPolicy* management_policy() OVERRIDE; virtual UserScriptMaster* user_script_master() OVERRIDE; - virtual ExtensionProcessManager* process_manager() OVERRIDE; + virtual ProcessManager* process_manager() OVERRIDE; virtual StateStore* state_store() OVERRIDE; virtual StateStore* rules_store() OVERRIDE; TestingValueStore* value_store() { return value_store_; } @@ -92,7 +91,7 @@ class TestExtensionSystem : public ExtensionSystem { standard_management_policy_provider_; scoped_ptr<ManagementPolicy> management_policy_; scoped_ptr<ExtensionService> extension_service_; - scoped_ptr<ExtensionProcessManager> extension_process_manager_; + scoped_ptr<ProcessManager> process_manager_; scoped_refptr<ExtensionInfoMap> info_map_; scoped_ptr<ErrorConsole> error_console_; OneShotEvent ready_; diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index 5cee30e..81a9c3f 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -8,7 +8,6 @@ #include "base/strings/stringprintf.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/profiles/profile.h" @@ -26,6 +25,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/result_codes.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/switches.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 4002c20..7c6780c 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -10,7 +10,6 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" @@ -26,6 +25,7 @@ #include "content/public/browser/render_widget_host_iterator.h" #include "content/public/browser/web_contents.h" #include "content/public/common/bindings_policy.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc index ffb7959..b5dc439 100644 --- a/chrome/browser/net/chrome_network_delegate.cc +++ b/chrome/browser/net/chrome_network_delegate.cc @@ -26,7 +26,6 @@ #include "chrome/browser/extensions/api/web_request/web_request_api.h" #include "chrome/browser/extensions/event_router_forwarder.h" #include "chrome/browser/extensions/extension_info_map.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/net/chrome_network_data_saving_metrics.h" @@ -41,6 +40,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_request_info.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/constants.h" #include "net/base/host_port_pair.h" #include "net/base/net_errors.h" @@ -169,7 +169,7 @@ void ForceGoogleSafeSearchCallbackWrapper( enum RequestStatus { REQUEST_STARTED, REQUEST_DONE }; -// Notifies the ExtensionProcessManager that a request has started or stopped +// Notifies the extensions::ProcessManager that a request has started or stopped // for a particular RenderView. void NotifyEPMRequestStatus(RequestStatus status, void* profile_id, @@ -180,10 +180,10 @@ void NotifyEPMRequestStatus(RequestStatus status, if (!g_browser_process->profile_manager()->IsValidProfile(profile)) return; - ExtensionProcessManager* extension_process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profile)->process_manager(); // This may be NULL in unit tests. - if (!extension_process_manager) + if (!process_manager) return; // Will be NULL if the request was not issued on behalf of a renderer (e.g. a @@ -192,9 +192,9 @@ void NotifyEPMRequestStatus(RequestStatus status, RenderViewHost::FromID(process_id, render_view_id); if (render_view_host) { if (status == REQUEST_STARTED) { - extension_process_manager->OnNetworkRequestStarted(render_view_host); + process_manager->OnNetworkRequestStarted(render_view_host); } else if (status == REQUEST_DONE) { - extension_process_manager->OnNetworkRequestDone(render_view_host); + process_manager->OnNetworkRequestDone(render_view_host); } else { NOTREACHED(); } diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 85d113b..89088f1a 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -35,7 +35,6 @@ #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/unpacked_installer.h" @@ -114,6 +113,7 @@ #include "content/public/test/test_utils.h" #include "content/test/net/url_request_failed_job.h" #include "content/test/net/url_request_mock_http_job.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/constants.h" #include "grit/generated_resources.h" #include "net/base/net_errors.h" @@ -1555,10 +1555,10 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallForcelist) { // Wait until any background pages belonging to force-installed extensions // have been loaded. - ExtensionProcessManager* manager = + extensions::ProcessManager* manager = extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); - ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); - for (ExtensionProcessManager::ViewSet::const_iterator iter = + extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); + for (extensions::ProcessManager::ViewSet::const_iterator iter = all_views.begin(); iter != all_views.end();) { if (!(*iter)->IsLoading()) { diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index 37c7f14..da6dbba 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -23,7 +23,6 @@ #include "chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h" #include "chrome/browser/extensions/api/messaging/message_service.h" #include "chrome/browser/extensions/event_router.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/net/chrome_url_request_context.h" @@ -39,6 +38,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/resource_dispatcher_host.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/constants.h" #if defined(USE_TCMALLOC) diff --git a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc index f6c7bce..58e267f 100644 --- a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc +++ b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc @@ -10,7 +10,6 @@ #include "base/values.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" @@ -23,6 +22,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/common/console_message_level.h" +#include "extensions/browser/process_manager.h" #include "net/base/network_change_notifier.h" using extensions::EventRouter; @@ -48,7 +48,7 @@ void WarnIfMissingPauseOrResumeListener( if (has_onpause == has_onresume) return; - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = ExtensionSystem::Get(profile)->process_manager(); extensions::ExtensionHost* host = process_manager->GetBackgroundHostForExtension(extension_id); diff --git a/chrome/browser/task_manager/extension_process_resource_provider.cc b/chrome/browser/task_manager/extension_process_resource_provider.cc index 121ae0f..4a0ab96 100644 --- a/chrome/browser/task_manager/extension_process_resource_provider.cc +++ b/chrome/browser/task_manager/extension_process_resource_provider.cc @@ -10,7 +10,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -24,6 +23,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/process_manager.h" #include "extensions/browser/view_type_utils.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -150,7 +150,7 @@ void ExtensionProcessResource::SetSupportNetworkUsage() { const Extension* ExtensionProcessResource::GetExtension() const { Profile* profile = Profile::FromBrowserContext( render_view_host_->GetProcess()->GetBrowserContext()); - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profile)->process_manager(); return process_manager->GetExtensionForRenderViewHost(render_view_host_); } @@ -213,12 +213,13 @@ void ExtensionProcessResourceProvider::StartUpdating() { } for (size_t i = 0; i < profiles.size(); ++i) { - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profiles[i])->process_manager(); if (process_manager) { - const ExtensionProcessManager::ViewSet all_views = + const extensions::ProcessManager::ViewSet all_views = process_manager->GetAllViews(); - ExtensionProcessManager::ViewSet::const_iterator jt = all_views.begin(); + extensions::ProcessManager::ViewSet::const_iterator jt = + all_views.begin(); for (; jt != all_views.end(); ++jt) { content::RenderViewHost* rvh = *jt; // Don't add dead extension processes. diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index ca2f8b5..b10876e 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -16,7 +16,6 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/task_manager/background_resource_provider.h" diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index 6317ad5..afffdda 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -1331,7 +1331,7 @@ TEST_F(TranslateManagerBrowserTest, BeforeTranslateExtraButtons) { static_cast<TestingProfile*>(web_contents()->GetBrowserContext()); static_cast<extensions::TestExtensionSystem*>( extensions::ExtensionSystem::Get(test_profile))-> - CreateExtensionProcessManager(); + CreateProcessManager(); test_profile->ForceIncognito(true); for (int i = 0; i < 8; ++i) { SCOPED_TRACE(::testing::Message() << "Iteration " << i << diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc index 5fa4264..16415f7 100644 --- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc +++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc @@ -8,7 +8,6 @@ #include "ash/launcher/launcher_model.h" #include "ash/shell.h" #include "ash/wm/window_util.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" @@ -25,6 +24,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/process_manager.h" #include "ui/aura/window.h" #include "ui/events/event.h" #include "ui/views/corewm/window_animations.h" diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc index c74bef7..4457382 100644 --- a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc +++ b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc @@ -15,7 +15,6 @@ #include "base/strings/string_util.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/notification.h" @@ -35,6 +34,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "extensions/browser/process_manager.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 6761fcb..0d5b9a9 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -418,7 +418,7 @@ bool StartupBrowserCreatorImpl::Launch(Profile* profile, #if defined(ENABLE_EXTENSIONS) // If we deferred creation of background extension hosts, we want to create // them now that the session (if any) has been restored. - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = extensions::ExtensionSystem::Get(profile)->process_manager(); process_manager->DeferBackgroundHostCreation(false); #endif diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index 3257bab..67c0bfd 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -163,7 +163,8 @@ void SelectFileDialogExtension::ExtensionTerminated( // reload the extension at all - when we try to open the extension the next // time, the extension subsystem would automatically reload it for us. At // this time though this is broken because of some faulty wiring in - // ExtensionProcessManager::CreateViewHost. Once that is fixed, remove this. + // extensions::ProcessManager::CreateViewHost. Once that is fixed, remove + // this. if (profile_) { base::MessageLoop::current()->PostTask( FROM_HERE, diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc index 42a5684..9d4f05d 100644 --- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc +++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc @@ -1077,7 +1077,7 @@ ExtensionSettingsHandler::GetInspectablePagesForExtension( std::vector<ExtensionPage> result; // Get the extension process's active views. - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = ExtensionSystem::Get(extension_service_->profile())->process_manager(); GetInspectablePagesForExtensionProcess( extension, @@ -1104,7 +1104,7 @@ ExtensionSettingsHandler::GetInspectablePagesForExtension( // shell windows for incognito processes. if (extension_service_->profile()->HasOffTheRecordProfile() && IncognitoInfo::IsSplitMode(extension)) { - ExtensionProcessManager* process_manager = + extensions::ProcessManager* process_manager = ExtensionSystem::Get(extension_service_->profile()-> GetOffTheRecordProfile())->process_manager(); GetInspectablePagesForExtensionProcess( diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 22596bf..a39a539 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -727,8 +727,6 @@ 'browser/extensions/extension_prefs.h', 'browser/extensions/extension_prefs_factory.cc', 'browser/extensions/extension_prefs_factory.h', - 'browser/extensions/extension_process_manager.cc', - 'browser/extensions/extension_process_manager.h', 'browser/extensions/extension_protocols.cc', 'browser/extensions/extension_protocols.h', 'browser/extensions/extension_renderer_state.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index dbbedf75..03a8288 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1236,7 +1236,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', @@ -1255,6 +1254,7 @@ 'browser/extensions/page_action_browsertest.cc', 'browser/extensions/plugin_apitest.cc', 'browser/extensions/process_management_browsertest.cc', + 'browser/extensions/process_manager_browsertest.cc', 'browser/extensions/requirements_checker_browsertest.cc', 'browser/extensions/sandboxed_pages_apitest.cc', 'browser/extensions/shared_module_apitest.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 30c8cfa..6984399 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -888,7 +888,6 @@ 'browser/extensions/extension_pref_value_map_unittest.cc', 'browser/extensions/extension_prefs_unittest.cc', 'browser/extensions/extension_prefs_unittest.h', - 'browser/extensions/extension_process_manager_unittest.cc', 'browser/extensions/extension_protocols_unittest.cc', 'browser/extensions/extension_service_unittest.cc', 'browser/extensions/extension_service_unittest.h', @@ -907,6 +906,7 @@ 'browser/extensions/pack_extension_unittest.cc', 'browser/extensions/page_action_controller_unittest.cc', 'browser/extensions/permissions_updater_unittest.cc', + 'browser/extensions/process_manager_unittest.cc', 'browser/extensions/process_map_unittest.cc', 'browser/extensions/sandboxed_unpacker_unittest.cc', 'browser/extensions/script_badge_controller_unittest.cc', diff --git a/chrome/test/data/extensions/api_test/media_galleries/common/common_injected.js b/chrome/test/data/extensions/api_test/media_galleries/common/common_injected.js index 4362b37..43266d1 100644 --- a/chrome/test/data/extensions/api_test/media_galleries/common/common_injected.js +++ b/chrome/test/data/extensions/api_test/media_galleries/common/common_injected.js @@ -163,8 +163,8 @@ function runReadGalleriesTest(expectedGalleryCount, expectSucceed, } } -// Create a dummy window to prevent the ExtensionProcessManager from suspending -// the chrome-test app. Needed because the writer.onerror and writer.onwriteend +// Create a dummy window to prevent the ProcessManager from suspending the +// chrome-test app. Needed because the writer.onerror and writer.onwriteend // events do not qualify as pending callbacks, so the app looks dormant. function CreateDummyWindowToPreventSleep() { chrome.app.runtime.onLaunched.addListener(function() { diff --git a/chrome/test/data/extensions/api_test/media_galleries/picasa/test.js b/chrome/test/data/extensions/api_test/media_galleries/picasa/test.js index cb6aaa4..4a82827 100644 --- a/chrome/test/data/extensions/api_test/media_galleries/picasa/test.js +++ b/chrome/test/data/extensions/api_test/media_galleries/picasa/test.js @@ -216,8 +216,8 @@ chrome.test.runTests([ getTest(Folder2ListingTest), ]); -// Create a dummy window to prevent the ExtensionProcessManager from suspending -// the chrome-test app. Needed because the FileReader events do not qualify as +// Create a dummy window to prevent the ProcessManager from suspending the +// chrome-test app. Needed because the FileReader events do not qualify as // pending callbacks, so the app looks dormant. chrome.app.runtime.onLaunched.addListener(function() { chrome.app.window.create('dummy.html', { diff --git a/content/browser/devtools/render_view_devtools_agent_host.cc b/content/browser/devtools/render_view_devtools_agent_host.cc index 7bee941..b277778 100644 --- a/content/browser/devtools/render_view_devtools_agent_host.cc +++ b/content/browser/devtools/render_view_devtools_agent_host.cc @@ -173,7 +173,7 @@ void RenderViewDevToolsAgentHost::OnClientAttached() { render_view_host_->GetProcess()->GetID()); // TODO(kaznacheev): Move this call back to DevToolsManagerImpl when - // ExtensionProcessManager no longer relies on this notification. + // extensions::ProcessManager no longer relies on this notification. DevToolsManagerImpl::GetInstance()->NotifyObservers(this, true); #if defined(OS_ANDROID) @@ -219,7 +219,7 @@ void RenderViewDevToolsAgentHost::ClientDetachedFromRenderer() { } // TODO(kaznacheev): Move this call back to DevToolsManagerImpl when - // ExtensionProcessManager no longer relies on this notification. + // extensions::ProcessManager no longer relies on this notification. DevToolsManagerImpl::GetInstance()->NotifyObservers(this, false); } diff --git a/extensions/browser/DEPS b/extensions/browser/DEPS index 0f912bf..497895d 100644 --- a/extensions/browser/DEPS +++ b/extensions/browser/DEPS @@ -8,10 +8,12 @@ include_rules = [ # # TODO(jamescook): Remove these. http://crbug.com/162530 "+chrome/browser/chrome_notification_types.h", + "+chrome/browser/extensions/api/runtime/runtime_api.h", "+chrome/browser/extensions/extension_host.h", - "+chrome/browser/extensions/extension_process_manager.h", + "+chrome/browser/extensions/extension_host_mac.h", "+chrome/browser/extensions/extension_service.h", "+chrome/browser/extensions/extension_system.h", + "+chrome/browser/extensions/extension_util.h", "+chrome/browser/extensions/process_map.h", "+chrome/common/extensions/background_info.h", "+chrome/common/extensions/extension.h", diff --git a/extensions/browser/lazy_background_task_queue.cc b/extensions/browser/lazy_background_task_queue.cc index 584d897..77a219b 100644 --- a/extensions/browser/lazy_background_task_queue.cc +++ b/extensions/browser/lazy_background_task_queue.cc @@ -7,7 +7,6 @@ #include "base/callback.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_host.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/process_map.h" @@ -21,6 +20,7 @@ #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/extensions_browser_client.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/view_type.h" namespace extensions { @@ -44,7 +44,7 @@ bool LazyBackgroundTaskQueue::ShouldEnqueueTask( const Extension* extension) { DCHECK(extension); if (BackgroundInfo::HasBackgroundPage(extension)) { - ExtensionProcessManager* pm = ExtensionSystem::GetForBrowserContext( + ProcessManager* pm = ExtensionSystem::GetForBrowserContext( browser_context)->process_manager(); DCHECK(pm); ExtensionHost* background_host = @@ -81,7 +81,7 @@ void LazyBackgroundTaskQueue::AddPendingTask( if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) { // If this is the first enqueued task, and we're not waiting for the // background page to unload, ensure the background page is loaded. - ExtensionProcessManager* pm = ExtensionSystem::GetForBrowserContext( + ProcessManager* pm = ExtensionSystem::GetForBrowserContext( browser_context)->process_manager(); pm->IncrementLazyKeepaliveCount(extension); // Creating the background host may fail, e.g. if |profile| is incognito diff --git a/extensions/browser/lazy_background_task_queue_unittest.cc b/extensions/browser/lazy_background_task_queue_unittest.cc index e355cac..863a520 100644 --- a/extensions/browser/lazy_background_task_queue_unittest.cc +++ b/extensions/browser/lazy_background_task_queue_unittest.cc @@ -6,31 +6,30 @@ #include "base/bind.h" #include "base/command_line.h" -#include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service_unittest.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/common/extensions/extension.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread_bundle.h" +#include "extensions/browser/process_manager.h" #include "extensions/common/extension_builder.h" #include "testing/gtest/include/gtest/gtest.h" namespace extensions { -// An ExtensionProcessManager that doesn't create background host pages. -class TestExtensionProcessManager : public ExtensionProcessManager { +// A ProcessManager that doesn't create background host pages. +class TestProcessManager : public ProcessManager { public: - explicit TestExtensionProcessManager(Profile* profile) - : ExtensionProcessManager(profile, profile->GetOriginalProfile()), + explicit TestProcessManager(Profile* profile) + : ProcessManager(profile, profile->GetOriginalProfile()), create_count_(0) {} - virtual ~TestExtensionProcessManager() {} + virtual ~TestProcessManager() {} int create_count() { return create_count_; } - // ExtensionProcessManager overrides: - virtual extensions::ExtensionHost* CreateBackgroundHost( - const extensions::Extension* extension, - const GURL& url) OVERRIDE { + // ProcessManager overrides: + virtual ExtensionHost* CreateBackgroundHost(const Extension* extension, + const GURL& url) OVERRIDE { // Don't actually try to create a web contents. create_count_++; return NULL; @@ -39,7 +38,7 @@ class TestExtensionProcessManager : public ExtensionProcessManager { private: int create_count_; - DISALLOW_COPY_AND_ASSIGN(TestExtensionProcessManager); + DISALLOW_COPY_AND_ASSIGN(TestProcessManager); }; // Derives from ExtensionServiceTestBase because ExtensionService is difficult @@ -96,7 +95,7 @@ class LazyBackgroundTaskQueueTest : public ExtensionServiceTestBase { // Tests that only extensions with background pages should have tasks queued. TEST_F(LazyBackgroundTaskQueueTest, ShouldEnqueueTask) { InitializeEmptyExtensionService(); - InitializeExtensionProcessManager(); + InitializeProcessManager(); LazyBackgroundTaskQueue queue(profile_.get()); @@ -114,14 +113,13 @@ TEST_F(LazyBackgroundTaskQueueTest, ShouldEnqueueTask) { TEST_F(LazyBackgroundTaskQueueTest, AddPendingTask) { InitializeEmptyExtensionService(); - // Swap in our stub TestExtensionProcessManager. + // Swap in our stub TestProcessManager. TestExtensionSystem* extension_system = static_cast<extensions::TestExtensionSystem*>( ExtensionSystem::Get(profile_.get())); // Owned by |extension_system|. - TestExtensionProcessManager* process_manager = - new TestExtensionProcessManager(profile_.get()); - extension_system->SetExtensionProcessManager(process_manager); + TestProcessManager* process_manager = new TestProcessManager(profile_.get()); + extension_system->SetProcessManager(process_manager); LazyBackgroundTaskQueue queue(profile_.get()); diff --git a/chrome/browser/extensions/extension_process_manager.cc b/extensions/browser/process_manager.cc index b11eecf..f5134d1 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/extensions/browser/process_manager.cc @@ -2,7 +2,7 @@ // 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 "extensions/browser/process_manager.h" #include "base/bind.h" #include "base/command_line.h" @@ -48,15 +48,14 @@ using content::BrowserContext; using content::RenderViewHost; using content::SiteInstance; using content::WebContents; -using extensions::BackgroundInfo; -using extensions::BackgroundManifestHandler; -using extensions::Extension; -using extensions::ExtensionHost; -using extensions::ExtensionsBrowserClient; -using extensions::ExtensionSystem; +namespace extensions { class RenderViewHostDestructionObserver; -DEFINE_WEB_CONTENTS_USER_DATA_KEY(RenderViewHostDestructionObserver); +} +DEFINE_WEB_CONTENTS_USER_DATA_KEY( + extensions::RenderViewHostDestructionObserver); + +namespace extensions { namespace { @@ -78,13 +77,13 @@ void OnRenderViewHostUnregistered(BrowserContext* context, } // Incognito profiles use this process manager. It is mostly a shim that decides -// whether to fall back on the original profile's ExtensionProcessManager based +// whether to fall back on the original profile's ProcessManager based // on whether a given extension uses "split" or "spanning" incognito behavior. -class IncognitoExtensionProcessManager : public ExtensionProcessManager { +class IncognitoProcessManager : public ProcessManager { public: - IncognitoExtensionProcessManager(BrowserContext* incognito_context, - BrowserContext* original_context); - virtual ~IncognitoExtensionProcessManager(); + IncognitoProcessManager(BrowserContext* incognito_context, + BrowserContext* original_context); + virtual ~IncognitoProcessManager(); virtual ExtensionHost* CreateBackgroundHost(const Extension* extension, const GURL& url) OVERRIDE; virtual SiteInstance* GetSiteInstanceForURL(const GURL& url) OVERRIDE; @@ -93,13 +92,13 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager { // Returns true if the extension is allowed to run in incognito mode. bool IsIncognitoEnabled(const Extension* extension); - ExtensionProcessManager* original_manager_; + ProcessManager* original_manager_; - DISALLOW_COPY_AND_ASSIGN(IncognitoExtensionProcessManager); + DISALLOW_COPY_AND_ASSIGN(IncognitoProcessManager); }; static void CreateBackgroundHostForExtensionLoad( - ExtensionProcessManager* manager, const Extension* extension) { + ProcessManager* manager, const Extension* extension) { DVLOG(1) << "CreateBackgroundHostForExtensionLoad"; if (BackgroundInfo::HasPersistentBackgroundPage(extension)) manager->CreateBackgroundHost(extension, @@ -129,12 +128,12 @@ class RenderViewHostDestructionObserver process_manager_->UnregisterRenderViewHost(render_view_host); } - ExtensionProcessManager* process_manager_; + ProcessManager* process_manager_; DISALLOW_COPY_AND_ASSIGN(RenderViewHostDestructionObserver); }; -struct ExtensionProcessManager::BackgroundPageData { +struct ProcessManager::BackgroundPageData { // The count of things keeping the lazy background page alive. int lazy_keepalive_count; @@ -156,28 +155,26 @@ struct ExtensionProcessManager::BackgroundPageData { }; // -// ExtensionProcessManager +// ProcessManager // // static -ExtensionProcessManager* ExtensionProcessManager::Create( - BrowserContext* context) { +ProcessManager* ProcessManager::Create(BrowserContext* context) { if (context->IsOffTheRecord()) { BrowserContext* original_context = ExtensionsBrowserClient::Get()->GetOriginalContext(context); - return new IncognitoExtensionProcessManager(context, original_context); + return new IncognitoProcessManager(context, original_context); } - return new ExtensionProcessManager(context, context); + return new ProcessManager(context, context); } -ExtensionProcessManager::ExtensionProcessManager( - BrowserContext* context, - BrowserContext* original_context) +ProcessManager::ProcessManager(BrowserContext* context, + BrowserContext* original_context) : site_instance_(SiteInstance::Create(context)), defer_background_host_creation_(false), startup_background_hosts_created_(false), devtools_callback_(base::Bind( - &ExtensionProcessManager::OnDevToolsStateChanged, + &ProcessManager::OnDevToolsStateChanged, base::Unretained(this))), weak_ptr_factory_(this) { registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, @@ -222,15 +219,14 @@ ExtensionProcessManager::ExtensionProcessManager( devtools_callback_); } -ExtensionProcessManager::~ExtensionProcessManager() { +ProcessManager::~ProcessManager() { CloseBackgroundHosts(); DCHECK(background_hosts_.empty()); content::DevToolsManager::GetInstance()->RemoveAgentStateCallback( devtools_callback_); } -const ExtensionProcessManager::ViewSet -ExtensionProcessManager::GetAllViews() const { +const ProcessManager::ViewSet ProcessManager::GetAllViews() const { ViewSet result; for (ExtensionRenderViews::const_iterator iter = all_extension_views_.begin(); @@ -240,8 +236,8 @@ ExtensionProcessManager::GetAllViews() const { return result; } -ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( - const Extension* extension, const GURL& url) { +ExtensionHost* ProcessManager::CreateBackgroundHost(const Extension* extension, + const GURL& url) { DVLOG(1) << "CreateBackgroundHost " << url.spec(); // Hosted apps are taken care of from BackgroundContentsService. Ignore them // here. @@ -254,12 +250,12 @@ ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( ExtensionHost* host = #if defined(OS_MACOSX) - new extensions::ExtensionHostMac( + new ExtensionHostMac( extension, GetSiteInstanceForURL(url), url, - extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); + VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); #else new ExtensionHost(extension, GetSiteInstanceForURL(url), url, - extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); + VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); #endif host->CreateRenderViewSoon(); @@ -267,7 +263,7 @@ ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( return host; } -ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( +ExtensionHost* ProcessManager::GetBackgroundHostForExtension( const std::string& extension_id) { for (ExtensionHostSet::iterator iter = background_hosts_.begin(); iter != background_hosts_.end(); ++iter) { @@ -278,9 +274,8 @@ ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( return NULL; } -std::set<RenderViewHost*> - ExtensionProcessManager::GetRenderViewHostsForExtension( - const std::string& extension_id) { +std::set<RenderViewHost*> ProcessManager::GetRenderViewHostsForExtension( + const std::string& extension_id) { std::set<RenderViewHost*> result; SiteInstance* site_instance = GetSiteInstanceForURL( @@ -298,7 +293,7 @@ std::set<RenderViewHost*> return result; } -const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost( +const Extension* ProcessManager::GetExtensionForRenderViewHost( RenderViewHost* render_view_host) { if (!render_view_host->GetSiteInstance()) return NULL; @@ -311,7 +306,7 @@ const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost( return service->extensions()->GetByID(GetExtensionID(render_view_host)); } -void ExtensionProcessManager::UnregisterRenderViewHost( +void ProcessManager::UnregisterRenderViewHost( RenderViewHost* render_view_host) { ExtensionRenderViews::iterator view = all_extension_views_.find(render_view_host); @@ -319,12 +314,12 @@ void ExtensionProcessManager::UnregisterRenderViewHost( return; OnRenderViewHostUnregistered(GetBrowserContext(), render_view_host); - extensions::ViewType view_type = view->second; + ViewType view_type = view->second; all_extension_views_.erase(view); // Keepalive count, balanced in RegisterRenderViewHost. - if (view_type != extensions::VIEW_TYPE_INVALID && - view_type != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { + if (view_type != VIEW_TYPE_INVALID && + view_type != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { const Extension* extension = GetExtensionForRenderViewHost( render_view_host); if (extension) @@ -332,16 +327,14 @@ void ExtensionProcessManager::UnregisterRenderViewHost( } } -void ExtensionProcessManager::RegisterRenderViewHost( - RenderViewHost* render_view_host) { +void ProcessManager::RegisterRenderViewHost(RenderViewHost* render_view_host) { const Extension* extension = GetExtensionForRenderViewHost( render_view_host); if (!extension) return; WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); - all_extension_views_[render_view_host] = - extensions::GetViewType(web_contents); + all_extension_views_[render_view_host] = GetViewType(web_contents); // Keep the lazy background page alive as long as any non-background-page // extension views are visible. Keepalive count balanced in @@ -349,25 +342,23 @@ void ExtensionProcessManager::RegisterRenderViewHost( IncrementLazyKeepaliveCountForView(render_view_host); } -SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { +SiteInstance* ProcessManager::GetSiteInstanceForURL(const GURL& url) { return site_instance_->GetRelatedSiteInstance(url); } -bool ExtensionProcessManager::IsBackgroundHostClosing( - const std::string& extension_id) { +bool ProcessManager::IsBackgroundHostClosing(const std::string& extension_id) { ExtensionHost* host = GetBackgroundHostForExtension(extension_id); return (host && background_page_data_[extension_id].is_closing); } -int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) { +int ProcessManager::GetLazyKeepaliveCount(const Extension* extension) { if (!BackgroundInfo::HasLazyBackgroundPage(extension)) return 0; return background_page_data_[extension->id()].lazy_keepalive_count; } -int ExtensionProcessManager::IncrementLazyKeepaliveCount( - const Extension* extension) { +int ProcessManager::IncrementLazyKeepaliveCount(const Extension* extension) { if (!BackgroundInfo::HasLazyBackgroundPage(extension)) return 0; @@ -378,8 +369,7 @@ int ExtensionProcessManager::IncrementLazyKeepaliveCount( return count; } -int ExtensionProcessManager::DecrementLazyKeepaliveCount( - const Extension* extension) { +int ProcessManager::DecrementLazyKeepaliveCount(const Extension* extension) { if (!BackgroundInfo::HasLazyBackgroundPage(extension)) return 0; @@ -393,7 +383,7 @@ int ExtensionProcessManager::DecrementLazyKeepaliveCount( if (--count == 0 && !background_page_data_[extension->id()].is_closing) { base::MessageLoop::current()->PostDelayedTask( FROM_HERE, - base::Bind(&ExtensionProcessManager::OnLazyBackgroundPageIdle, + base::Bind(&ProcessManager::OnLazyBackgroundPageIdle, weak_ptr_factory_.GetWeakPtr(), extension->id(), ++background_page_data_[extension->id()].close_sequence_id), event_page_idle_time_); @@ -402,13 +392,13 @@ int ExtensionProcessManager::DecrementLazyKeepaliveCount( return count; } -void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( +void ProcessManager::IncrementLazyKeepaliveCountForView( RenderViewHost* render_view_host) { WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); - extensions::ViewType view_type = extensions::GetViewType(web_contents); - if (view_type != extensions::VIEW_TYPE_INVALID && - view_type != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { + ViewType view_type = GetViewType(web_contents); + if (view_type != VIEW_TYPE_INVALID && + view_type != VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { const Extension* extension = GetExtensionForRenderViewHost( render_view_host); if (extension) @@ -416,8 +406,8 @@ void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( } } -void ExtensionProcessManager::OnLazyBackgroundPageIdle( - const std::string& extension_id, int sequence_id) { +void ProcessManager::OnLazyBackgroundPageIdle(const std::string& extension_id, + int sequence_id) { ExtensionHost* host = GetBackgroundHostForExtension(extension_id); if (host && !background_page_data_[extension_id].is_closing && sequence_id == background_page_data_[extension_id].close_sequence_id) { @@ -432,7 +422,7 @@ void ExtensionProcessManager::OnLazyBackgroundPageIdle( } } -void ExtensionProcessManager::OnLazyBackgroundPageActive( +void ProcessManager::OnLazyBackgroundPageActive( const std::string& extension_id) { ExtensionHost* host = GetBackgroundHostForExtension(extension_id); if (host && !background_page_data_[extension_id].is_closing) { @@ -442,8 +432,8 @@ void ExtensionProcessManager::OnLazyBackgroundPageActive( } } -void ExtensionProcessManager::OnShouldSuspendAck( - const std::string& extension_id, int sequence_id) { +void ProcessManager::OnShouldSuspendAck(const std::string& extension_id, + int sequence_id) { ExtensionHost* host = GetBackgroundHostForExtension(extension_id); if (host && sequence_id == background_page_data_[extension_id].close_sequence_id) { @@ -451,18 +441,18 @@ void ExtensionProcessManager::OnShouldSuspendAck( } } -void ExtensionProcessManager::OnSuspendAck(const std::string& extension_id) { +void ProcessManager::OnSuspendAck(const std::string& extension_id) { background_page_data_[extension_id].is_closing = true; int sequence_id = background_page_data_[extension_id].close_sequence_id; base::MessageLoop::current()->PostDelayedTask( FROM_HERE, - base::Bind(&ExtensionProcessManager::CloseLazyBackgroundPageNow, + base::Bind(&ProcessManager::CloseLazyBackgroundPageNow, weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id), event_page_suspending_time_); } -void ExtensionProcessManager::CloseLazyBackgroundPageNow( - const std::string& extension_id, int sequence_id) { +void ProcessManager::CloseLazyBackgroundPageNow(const std::string& extension_id, + int sequence_id) { ExtensionHost* host = GetBackgroundHostForExtension(extension_id); if (host && sequence_id == background_page_data_[extension_id].close_sequence_id) { @@ -472,23 +462,21 @@ void ExtensionProcessManager::CloseLazyBackgroundPageNow( } } -void ExtensionProcessManager::OnNetworkRequestStarted( - RenderViewHost* render_view_host) { +void ProcessManager::OnNetworkRequestStarted(RenderViewHost* render_view_host) { ExtensionHost* host = GetBackgroundHostForExtension( GetExtensionID(render_view_host)); if (host && host->render_view_host() == render_view_host) IncrementLazyKeepaliveCount(host->extension()); } -void ExtensionProcessManager::OnNetworkRequestDone( - RenderViewHost* render_view_host) { +void ProcessManager::OnNetworkRequestDone(RenderViewHost* render_view_host) { ExtensionHost* host = GetBackgroundHostForExtension( GetExtensionID(render_view_host)); if (host && host->render_view_host() == render_view_host) DecrementLazyKeepaliveCount(host->extension()); } -void ExtensionProcessManager::CancelSuspend(const Extension* extension) { +void ProcessManager::CancelSuspend(const Extension* extension) { bool& is_closing = background_page_data_[extension->id()].is_closing; ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); if (host && is_closing) { @@ -504,7 +492,7 @@ void ExtensionProcessManager::CancelSuspend(const Extension* extension) { } } -void ExtensionProcessManager::DeferBackgroundHostCreation(bool defer) { +void ProcessManager::DeferBackgroundHostCreation(bool defer) { bool previous = defer_background_host_creation_; defer_background_host_creation_ = defer; @@ -514,7 +502,7 @@ void ExtensionProcessManager::DeferBackgroundHostCreation(bool defer) { CreateBackgroundHostsForProfileStartup(); } -void ExtensionProcessManager::OnBrowserWindowReady() { +void ProcessManager::OnBrowserWindowReady() { ExtensionService* service = ExtensionSystem::GetForBrowserContext( GetBrowserContext())->extension_service(); // On Chrome OS, a login screen is implemented as a browser. @@ -526,14 +514,13 @@ void ExtensionProcessManager::OnBrowserWindowReady() { CreateBackgroundHostsForProfileStartup(); } -content::BrowserContext* ExtensionProcessManager::GetBrowserContext() const { +content::BrowserContext* ProcessManager::GetBrowserContext() const { return site_instance_->GetBrowserContext(); } -void ExtensionProcessManager::Observe( - int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { +void ProcessManager::Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { switch (type) { case chrome::NOTIFICATION_EXTENSIONS_READY: case chrome::NOTIFICATION_PROFILE_CREATED: { @@ -555,8 +542,7 @@ void ExtensionProcessManager::Observe( case chrome::NOTIFICATION_EXTENSION_UNLOADED: { const Extension* extension = - content::Details<extensions::UnloadedExtensionInfo>( - details)->extension; + content::Details<UnloadedExtensionInfo>(details)->extension; for (ExtensionHostSet::iterator iter = background_hosts_.begin(); iter != background_hosts_.end(); ++iter) { ExtensionHost* host = *iter; @@ -581,8 +567,7 @@ void ExtensionProcessManager::Observe( case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); - if (host->extension_host_type() == - extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { + if (host->extension_host_type() == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { CloseBackgroundHost(host); } break; @@ -642,16 +627,17 @@ void ExtensionProcessManager::Observe( } } -void ExtensionProcessManager::OnDevToolsStateChanged( - content::DevToolsAgentHost* agent_host, bool attached) { +void ProcessManager::OnDevToolsStateChanged( + content::DevToolsAgentHost* agent_host, + bool attached) { RenderViewHost* rvh = agent_host->GetRenderViewHost(); // Ignore unrelated notifications. if (!rvh || rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != GetBrowserContext()) return; - if (extensions::GetViewType(WebContents::FromRenderViewHost(rvh)) != - extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) + if (GetViewType(WebContents::FromRenderViewHost(rvh)) != + VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) return; const Extension* extension = GetExtensionForRenderViewHost(rvh); if (!extension) @@ -665,7 +651,7 @@ void ExtensionProcessManager::OnDevToolsStateChanged( } } -void ExtensionProcessManager::CreateBackgroundHostsForProfileStartup() { +void ProcessManager::CreateBackgroundHostsForProfileStartup() { if (startup_background_hosts_created_) return; @@ -683,8 +669,8 @@ void ExtensionProcessManager::CreateBackgroundHostsForProfileStartup() { extension != service->extensions()->end(); ++extension) { CreateBackgroundHostForExtensionLoad(this, extension->get()); - extensions::RuntimeEventRouter::DispatchOnStartupEvent( - GetBrowserContext(), (*extension)->id()); + RuntimeEventRouter::DispatchOnStartupEvent(GetBrowserContext(), + (*extension)->id()); } startup_background_hosts_created_ = true; @@ -710,7 +696,7 @@ void ExtensionProcessManager::CreateBackgroundHostsForProfileStartup() { } } -void ExtensionProcessManager::OnBackgroundHostCreated(ExtensionHost* host) { +void ProcessManager::OnBackgroundHostCreated(ExtensionHost* host) { DCHECK_EQ(GetBrowserContext(), host->browser_context()); background_hosts_.insert(host); @@ -725,15 +711,15 @@ void ExtensionProcessManager::OnBackgroundHostCreated(ExtensionHost* host) { } } -void ExtensionProcessManager::CloseBackgroundHost(ExtensionHost* host) { +void ProcessManager::CloseBackgroundHost(ExtensionHost* host) { CHECK(host->extension_host_type() == - extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); + VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); delete host; // |host| should deregister itself from our structures. CHECK(background_hosts_.find(host) == background_hosts_.end()); } -void ExtensionProcessManager::CloseBackgroundHosts() { +void ProcessManager::CloseBackgroundHosts() { for (ExtensionHostSet::iterator iter = background_hosts_.begin(); iter != background_hosts_.end(); ) { ExtensionHostSet::iterator current = iter++; @@ -741,8 +727,7 @@ void ExtensionProcessManager::CloseBackgroundHosts() { } } -void ExtensionProcessManager::UnregisterExtension( - const std::string& extension_id) { +void ProcessManager::UnregisterExtension(const std::string& extension_id) { // The lazy_keepalive_count may be greater than zero at this point because // RenderViewHosts are still alive. During extension reloading, they will // decrement the lazy_keepalive_count to negative for the new extension @@ -762,8 +747,7 @@ void ExtensionProcessManager::UnregisterExtension( background_page_data_.erase(extension_id); } -void ExtensionProcessManager::ClearBackgroundPageData( - const std::string& extension_id) { +void ProcessManager::ClearBackgroundPageData(const std::string& extension_id) { background_page_data_.erase(extension_id); // Re-register all RenderViews for this extension. We do this to restore @@ -776,7 +760,7 @@ void ExtensionProcessManager::ClearBackgroundPageData( } } -bool ExtensionProcessManager::DeferLoadingBackgroundHosts() const { +bool ProcessManager::DeferLoadingBackgroundHosts() const { // Don't load background hosts now if the loading should be deferred. if (defer_background_host_creation_) return true; @@ -787,18 +771,18 @@ bool ExtensionProcessManager::DeferLoadingBackgroundHosts() const { } // -// IncognitoExtensionProcessManager +// IncognitoProcessManager // -IncognitoExtensionProcessManager::IncognitoExtensionProcessManager( +IncognitoProcessManager::IncognitoProcessManager( BrowserContext* incognito_context, BrowserContext* original_context) - : ExtensionProcessManager(incognito_context, original_context), - original_manager_(extensions::ExtensionSystem::GetForBrowserContext( + : ProcessManager(incognito_context, original_context), + original_manager_(ExtensionSystem::GetForBrowserContext( original_context)->process_manager()) { DCHECK(incognito_context->IsOffTheRecord()); - // The original profile will have its own ExtensionProcessManager to + // The original profile will have its own ProcessManager 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. @@ -808,7 +792,7 @@ IncognitoExtensionProcessManager::IncognitoExtensionProcessManager( content::Source<BrowserContext>(original_context)); } -IncognitoExtensionProcessManager::~IncognitoExtensionProcessManager() { +IncognitoProcessManager::~IncognitoProcessManager() { // TODO(yoz): This cleanup code belongs in the MenuManager. // Remove "incognito" "split" mode context menu items. ExtensionService* service = ExtensionSystem::GetForBrowserContext( @@ -817,11 +801,11 @@ IncognitoExtensionProcessManager::~IncognitoExtensionProcessManager() { service->menu_manager()->RemoveAllIncognitoContextItems(); } -ExtensionHost* IncognitoExtensionProcessManager::CreateBackgroundHost( +ExtensionHost* IncognitoProcessManager::CreateBackgroundHost( const Extension* extension, const GURL& url) { - if (extensions::IncognitoInfo::IsSplitMode(extension)) { + if (IncognitoInfo::IsSplitMode(extension)) { if (IsIncognitoEnabled(extension)) - return ExtensionProcessManager::CreateBackgroundHost(extension, url); + return ProcessManager::CreateBackgroundHost(extension, url); } else { // Do nothing. If an extension is spanning, then its original-profile // background page is shared with incognito, so we don't create another. @@ -829,25 +813,24 @@ ExtensionHost* IncognitoExtensionProcessManager::CreateBackgroundHost( return NULL; } -SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL( - const GURL& url) { +SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) { ExtensionService* service = ExtensionSystem::GetForBrowserContext( GetBrowserContext())->extension_service(); if (service) { const Extension* extension = service->extensions()->GetExtensionOrAppByURL(url); - if (extension && - !extensions::IncognitoInfo::IsSplitMode(extension)) { + if (extension && !IncognitoInfo::IsSplitMode(extension)) { return original_manager_->GetSiteInstanceForURL(url); } } - return ExtensionProcessManager::GetSiteInstanceForURL(url); + return ProcessManager::GetSiteInstanceForURL(url); } -bool IncognitoExtensionProcessManager::IsIncognitoEnabled( - const Extension* extension) { +bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { // Keep in sync with duplicate in extension_info_map.cc. ExtensionService* service = ExtensionSystem::GetForBrowserContext( GetBrowserContext())->extension_service(); return extension_util::IsIncognitoEnabled(extension->id(), service); } + +} // namespace extensions diff --git a/chrome/browser/extensions/extension_process_manager.h b/extensions/browser/process_manager.h index a2fefb1..be47f0d 100644 --- a/chrome/browser/extensions/extension_process_manager.h +++ b/extensions/browser/process_manager.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ +#ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ +#define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ #include <map> #include <set> @@ -28,20 +28,20 @@ class SiteInstance; }; namespace extensions { + class Extension; class ExtensionHost; -} // Manages dynamic state of running Chromium extensions. There is one instance // of this class per Profile. OTR Profiles have a separate instance that keeps // track of split-mode extensions only. -class ExtensionProcessManager : public content::NotificationObserver { +class ProcessManager : public content::NotificationObserver { public: typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; typedef ExtensionHostSet::const_iterator const_iterator; - static ExtensionProcessManager* Create(content::BrowserContext* context); - virtual ~ExtensionProcessManager(); + static ProcessManager* Create(content::BrowserContext* context); + virtual ~ProcessManager(); const ExtensionHostSet& background_hosts() const { return background_hosts_; @@ -52,14 +52,12 @@ class ExtensionProcessManager : public content::NotificationObserver { // Creates a new UI-less extension instance. Like CreateViewHost, but not // displayed anywhere. - virtual extensions::ExtensionHost* CreateBackgroundHost( - const extensions::Extension* extension, - const GURL& url); + virtual ExtensionHost* CreateBackgroundHost(const Extension* extension, + const GURL& url); // Gets the ExtensionHost for the background page for an extension, or NULL if // the extension isn't running or doesn't have a background page. - extensions::ExtensionHost* GetBackgroundHostForExtension( - const std::string& extension_id); + ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); // Returns the SiteInstance that the given URL belongs to. // TODO(aa): This only returns correct results for extensions and packaged @@ -76,7 +74,7 @@ class ExtensionProcessManager : public content::NotificationObserver { // Returns the extension associated with the specified RenderViewHost, or // NULL. - const extensions::Extension* GetExtensionForRenderViewHost( + const Extension* GetExtensionForRenderViewHost( content::RenderViewHost* render_view_host); // Returns true if the (lazy) background host for the given extension has @@ -87,9 +85,9 @@ class ExtensionProcessManager : public content::NotificationObserver { // the count of how many outstanding "things" are keeping the page alive. // When this reaches 0, we will begin the process of shutting down the page. // "Things" include pending events, resource loads, and API calls. - int GetLazyKeepaliveCount(const extensions::Extension* extension); - int IncrementLazyKeepaliveCount(const extensions::Extension* extension); - int DecrementLazyKeepaliveCount(const extensions::Extension* extension); + int GetLazyKeepaliveCount(const Extension* extension); + int IncrementLazyKeepaliveCount(const Extension* extension); + int DecrementLazyKeepaliveCount(const Extension* extension); void IncrementLazyKeepaliveCountForView( content::RenderViewHost* render_view_host); @@ -108,7 +106,7 @@ class ExtensionProcessManager : public content::NotificationObserver { // Prevents |extension|'s background page from being closed and sends the // onSuspendCanceled() event to it. - void CancelSuspend(const extensions::Extension* extension); + void CancelSuspend(const Extension* extension); // If |defer| is true background host creation is to be deferred until this is // called again with |defer| set to false, at which point all deferred @@ -125,8 +123,8 @@ class ExtensionProcessManager : public content::NotificationObserver { 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); + ProcessManager(content::BrowserContext* context, + content::BrowserContext* original_context); // Called on browser shutdown to close our extension hosts. void CloseBackgroundHosts(); @@ -151,7 +149,7 @@ class ExtensionProcessManager : public content::NotificationObserver { scoped_refptr<content::SiteInstance> site_instance_; private: - friend class ExtensionProcessManagerTest; + friend class ProcessManagerTest; // Extra information we keep for each extension's background page. struct BackgroundPageData; @@ -161,10 +159,10 @@ class ExtensionProcessManager : public content::NotificationObserver { extensions::ViewType> ExtensionRenderViews; // Called just after |host| is created so it can be registered in our lists. - void OnBackgroundHostCreated(extensions::ExtensionHost* host); + void OnBackgroundHostCreated(ExtensionHost* host); // Close the given |host| iff it's a background page. - void CloseBackgroundHost(extensions::ExtensionHost* host); + void CloseBackgroundHost(ExtensionHost* host); // These are called when the extension transitions between idle and active. // They control the process of closing the background page when idle. @@ -213,9 +211,11 @@ class ExtensionProcessManager : public content::NotificationObserver { base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; - base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; + base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); + DISALLOW_COPY_AND_ASSIGN(ProcessManager); }; -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index 6cef0ee..40936e6 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -130,6 +130,9 @@ 'include_dirs': [ '..', '<(INTERMEDIATE_DIR)', + # Needed to access generated API headers. + '<(SHARED_INTERMEDIATE_DIR)', + # Needed for grit. '<(SHARED_INTERMEDIATE_DIR)/chrome', ], 'sources': [ @@ -148,6 +151,8 @@ 'browser/lazy_background_task_queue.h', 'browser/pref_names.cc', 'browser/pref_names.h', + 'browser/process_manager.cc', + 'browser/process_manager.h', 'browser/view_type_utils.cc', 'browser/view_type_utils.h', ], |