diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 23:14:02 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 23:14:02 +0000 |
commit | 9adb9693e8a90bb63be325dbb5d3391f47f839ba (patch) | |
tree | 555765afd7bc851de6f3a2bf4a35151435d58d77 /chrome/browser/extensions | |
parent | 5b5a5c976aead85a87ced0847c068012d3979cae (diff) | |
download | chromium_src-9adb9693e8a90bb63be325dbb5d3391f47f839ba.zip chromium_src-9adb9693e8a90bb63be325dbb5d3391f47f839ba.tar.gz chromium_src-9adb9693e8a90bb63be325dbb5d3391f47f839ba.tar.bz2 |
Part 3 of immutable Extension refactor.
Make ExtensionsService hold const Extension pointers only. This ensures that
extensions can't be modified after they're created, and lets us share them
between threads.
BUG=56558
TEST=no functional change
Review URL: http://codereview.chromium.org/4138006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
71 files changed, 329 insertions, 314 deletions
diff --git a/chrome/browser/extensions/alert_apitest.cc b/chrome/browser/extensions/alert_apitest.cc index 23e8fe8..8e70fdb 100644 --- a/chrome/browser/extensions/alert_apitest.cc +++ b/chrome/browser/extensions/alert_apitest.cc @@ -14,7 +14,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlertBasic) { ASSERT_TRUE(RunExtensionTest("alert")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ExtensionHost* host = browser()->profile()->GetExtensionProcessManager()-> GetBackgroundHostForExtension(extension); ASSERT_TRUE(host); diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc index 8b09783..5e76310 100644 --- a/chrome/browser/extensions/browser_action_apitest.cc +++ b/chrome/browser/extensions/browser_action_apitest.cc @@ -47,7 +47,7 @@ class BrowserActionApiTest : public ExtensionApiTest { IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, Basic) { ASSERT_TRUE(test_server()->Start()); ASSERT_TRUE(RunExtensionTest("browser_action/basics")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; // Test that there is a browser action in the toolbar. @@ -87,7 +87,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, Basic) { IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { ASSERT_TRUE(RunExtensionTest("browser_action/no_icon")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; // Test that there is a browser action in the toolbar and that it has no icon. @@ -117,7 +117,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DynamicBrowserAction) { IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TabSpecificBrowserActionState) { ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; // Test that there is a browser action in the toolbar and that it has an icon. @@ -147,7 +147,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopup) { ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( "browser_action/popup"))); BrowserActionTestUtil actions_bar = GetBrowserActionsBar(); - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; // The extension's popup's size grows by |growFactor| each click. @@ -180,7 +180,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopup) { // a popup. IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionAddPopup) { ASSERT_TRUE(RunExtensionTest("browser_action/add_popup")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); @@ -235,7 +235,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionAddPopup) { IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionRemovePopup) { // Load the extension, which has a browser action with a default popup. ASSERT_TRUE(RunExtensionTest("browser_action/remove_popup")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); @@ -269,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoBasic) { ASSERT_TRUE(test_server()->Start()); ASSERT_TRUE(RunExtensionTest("browser_action/basics")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; // Test that there is a browser action in the toolbar. diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 07aa3d08..17276f7 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -157,7 +157,8 @@ void CrxInstaller::ConvertUserScriptOnFileThread() { OnUnpackSuccess(extension->path(), extension->path(), extension); } -bool CrxInstaller::AllowInstall(Extension* extension, std::string* error) { +bool CrxInstaller::AllowInstall(const Extension* extension, + std::string* error) { DCHECK(error); // We always allow themes and external installs. @@ -239,7 +240,7 @@ void CrxInstaller::OnUnpackFailure(const std::string& error_message) { void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir, const FilePath& extension_dir, - Extension* extension) { + const Extension* extension) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); // Note: We take ownership of |extension| and |temp_dir|. @@ -282,7 +283,7 @@ void CrxInstaller::ConfirmInstall() { } GURL overlapping_url; - Extension* overlapping_extension = + const Extension* overlapping_extension = frontend_->GetExtensionByOverlappingWebExtent(extension_->web_extent()); if (overlapping_extension) { ReportFailureFromUIThread(l10n_util::GetStringFUTF8( diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h index 8263095..73d5af8 100644 --- a/chrome/browser/extensions/crx_installer.h +++ b/chrome/browser/extensions/crx_installer.h @@ -120,13 +120,13 @@ class CrxInstaller // Called after OnUnpackSuccess as a last check to see whether the install // should complete. - bool AllowInstall(Extension* extension, std::string* error); + bool AllowInstall(const Extension* extension, std::string* error); // SandboxedExtensionUnpackerClient virtual void OnUnpackFailure(const std::string& error_message); virtual void OnUnpackSuccess(const FilePath& temp_dir, const FilePath& extension_dir, - Extension* extension); + const Extension* extension); // Runs on the UI thread. Confirms with the user (via ExtensionInstallUI) that // it is OK to install this extension. @@ -187,7 +187,7 @@ class CrxInstaller // The extension we're installing. We own this and either pass it off to // ExtensionsService on success, or delete it on failure. - scoped_refptr<Extension> extension_; + scoped_refptr<const Extension> extension_; // If non-empty, contains the current version of the extension we're // installing (for upgrades). diff --git a/chrome/browser/extensions/execute_code_in_tab_function.cc b/chrome/browser/extensions/execute_code_in_tab_function.cc index b7bf999..8021e6c 100644 --- a/chrome/browser/extensions/execute_code_in_tab_function.cc +++ b/chrome/browser/extensions/execute_code_in_tab_function.cc @@ -78,7 +78,7 @@ bool ExecuteCodeInTabFunction::RunImpl() { // NOTE: This can give the wrong answer due to race conditions, but it is OK, // we check again in the renderer. - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); const std::vector<URLPattern> host_permissions = extension->host_permissions(); if (!Extension::CanExecuteScriptOnPage( @@ -158,7 +158,7 @@ bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { return false; } - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); if (!extension) { SendResponse(false); return false; diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc index 0547554..07668b3 100644 --- a/chrome/browser/extensions/extension_apitest.cc +++ b/chrome/browser/extensions/extension_apitest.cc @@ -144,7 +144,7 @@ bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, "Relative page_url given with no extension_name"; ExtensionsService* service = browser()->profile()->GetExtensionsService(); - Extension* extension = + const Extension* extension = service->GetExtensionById(last_loaded_extension_id_, false); if (!extension) return false; @@ -165,7 +165,7 @@ bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, } // Test that exactly one extension loaded. -Extension* ExtensionApiTest::GetSingleLoadedExtension() { +const Extension* ExtensionApiTest::GetSingleLoadedExtension() { ExtensionsService* service = browser()->profile()->GetExtensionsService(); int found_extension_index = -1; @@ -185,7 +185,7 @@ Extension* ExtensionApiTest::GetSingleLoadedExtension() { found_extension_index = static_cast<int>(i); } - Extension* extension = service->extensions()->at(found_extension_index); + const Extension* extension = service->extensions()->at(found_extension_index); if (!extension) { message_ = "extension pointer is NULL."; return NULL; diff --git a/chrome/browser/extensions/extension_apitest.h b/chrome/browser/extensions/extension_apitest.h index b0a0e01..b2079a6 100644 --- a/chrome/browser/extensions/extension_apitest.h +++ b/chrome/browser/extensions/extension_apitest.h @@ -94,7 +94,7 @@ class ExtensionApiTest : public ExtensionBrowserTest { // Test that exactly one extension loaded. If so, return a pointer to // the extension. If not, return NULL and set message_. - Extension* GetSingleLoadedExtension(); + const Extension* GetSingleLoadedExtension(); // All extensions tested by ExtensionApiTest are in the "api_test" dir. virtual void SetUpCommandLine(CommandLine* command_line); diff --git a/chrome/browser/extensions/extension_browser_actions_api.cc b/chrome/browser/extensions/extension_browser_actions_api.cc index 1ce4dfe..1986d28 100644 --- a/chrome/browser/extensions/extension_browser_actions_api.cc +++ b/chrome/browser/extensions/extension_browser_actions_api.cc @@ -26,7 +26,7 @@ bool BrowserActionFunction::RunImpl() { if (details_->HasKey("tabId")) EXTENSION_FUNCTION_VALIDATE(details_->GetInteger("tabId", &tab_id_)); - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); browser_action_ = extension->browser_action(); if (!browser_action_) { error_ = kNoBrowserActionError; diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 7c4cd83..af8a6de 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -69,7 +69,7 @@ bool ExtensionBrowserTest::LoadExtensionImpl(const FilePath& path, // Find the extension by iterating backwards since it is likely last. FilePath extension_path = path; file_util::AbsolutePath(&extension_path); - Extension* extension = NULL; + const Extension* extension = NULL; for (ExtensionList::const_reverse_iterator iter = service->extensions()->rbegin(); iter != service->extensions()->rend(); ++iter) { @@ -107,14 +107,15 @@ class MockAbortExtensionInstallUI : public ExtensionInstallUI { MockAbortExtensionInstallUI() : ExtensionInstallUI(NULL) {} // Simulate a user abort on an extension installation. - virtual void ConfirmInstall(Delegate* delegate, Extension* extension) { + virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { delegate->InstallUIAbort(); MessageLoopForUI::current()->Quit(); } - virtual void ConfirmUninstall(Delegate* delegate, Extension* extension) {} + virtual void ConfirmUninstall(Delegate* delegate, + const Extension* extension) {} - virtual void OnInstallSuccess(Extension* extension) {} + virtual void OnInstallSuccess(const Extension* extension) {} virtual void OnInstallFailure(const std::string& error) {} }; @@ -288,7 +289,7 @@ void ExtensionBrowserTest::Observe(NotificationType type, const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSION_LOADED: - last_loaded_extension_id_ = Details<Extension>(details).ptr()->id(); + last_loaded_extension_id_ = Details<const Extension>(details).ptr()->id(); VLOG(1) << "Got EXTENSION_LOADED notification."; MessageLoopForUI::current()->Quit(); break; diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc index 903e0ff..3b1780d 100644 --- a/chrome/browser/extensions/extension_browsertests_misc.cc +++ b/chrome/browser/extensions/extension_browsertests_misc.cc @@ -260,13 +260,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) { ASSERT_TRUE(LoadExtension(base_path.AppendASCII("ExtA"))); ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); ASSERT_EQ(size_before + 1, service->extensions()->size()); - Extension* extensionA = service->extensions()->at(size_before); + const Extension* extensionA = service->extensions()->at(size_before); // Load extension B. ASSERT_TRUE(LoadExtension(base_path.AppendASCII("ExtB"))); ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(2)); ASSERT_EQ(size_before + 2, service->extensions()->size()); - Extension* extensionB = service->extensions()->at(size_before + 1); + const Extension* extensionB = service->extensions()->at(size_before + 1); ReloadExtension(extensionA->id()); // ExtensionA has changed, so refetch it. @@ -306,7 +306,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationBrowserAction) { ASSERT_TRUE(LoadExtension(extension_path)); ASSERT_EQ(size_before + 1, service->extensions()->size()); - Extension* extension = service->extensions()->at(size_before); + const Extension* extension = service->extensions()->at(size_before); EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(), extension->description().c_str()); @@ -335,7 +335,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); ASSERT_EQ(size_before + 1, service->extensions()->size()); - Extension* extension = service->extensions()->at(size_before); + const Extension* extension = service->extensions()->at(size_before); EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), extension->description().c_str()); @@ -422,7 +422,7 @@ void NavigateToFeedAndValidate(net::TestServer* server, } ExtensionsService* service = browser->profile()->GetExtensionsService(); - Extension* extension = service->extensions()->back(); + const Extension* extension = service->extensions()->back(); std::string id = extension->id(); // Navigate to the subscribe page directly. @@ -778,7 +778,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { ExtensionsService* service = browser()->profile()->GetExtensionsService(); const ExtensionList* extensions = service->extensions(); ASSERT_EQ(1u, extensions->size()); - Extension* extension = extensions->at(0); + const Extension* extension = extensions->at(0); // Go to the chrome://extensions page and click the Options button. ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); diff --git a/chrome/browser/extensions/extension_context_menu_browsertest.cc b/chrome/browser/extensions/extension_context_menu_browsertest.cc index 62221e1..b0041ad 100644 --- a/chrome/browser/extensions/extension_context_menu_browsertest.cc +++ b/chrome/browser/extensions/extension_context_menu_browsertest.cc @@ -142,7 +142,7 @@ class ExtensionContextMenuBrowserTest : public ExtensionBrowserTest { // Returns a pointer to the currently loaded extension with |name|, or null // if not found. - Extension* GetExtensionNamed(std::string name) { + const Extension* GetExtensionNamed(std::string name) { const ExtensionList* extensions = browser()->profile()->GetExtensionsService()->extensions(); ExtensionList::const_iterator i; @@ -301,7 +301,7 @@ static void VerifyMenuForSeparatorsTest(const MenuModel& menu) { IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Separators) { // Load the extension. ASSERT_TRUE(LoadContextMenuExtension("separators")); - Extension* extension = GetExtensionNamed("Separators Test"); + const Extension* extension = GetExtensionNamed("Separators Test"); ASSERT_TRUE(extension != NULL); // Navigate to test1.html inside the extension, which should create a bunch diff --git a/chrome/browser/extensions/extension_context_menu_model.cc b/chrome/browser/extensions/extension_context_menu_model.cc index 6432f9d..404241e 100644 --- a/chrome/browser/extensions/extension_context_menu_model.cc +++ b/chrome/browser/extensions/extension_context_menu_model.cc @@ -28,7 +28,7 @@ enum MenuEntries { }; ExtensionContextMenuModel::ExtensionContextMenuModel( - Extension* extension, + const Extension* extension, Browser* browser, PopupDelegate* delegate) : ALLOW_THIS_IN_INITIALIZER_LIST(SimpleMenuModel(this)), @@ -53,7 +53,7 @@ ExtensionContextMenuModel::~ExtensionContextMenuModel() { } void ExtensionContextMenuModel::InitCommonCommands() { - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); // The extension pointer should only be null if the extension was uninstalled, // and since the menu just opened, it should still be installed. @@ -73,7 +73,7 @@ bool ExtensionContextMenuModel::IsCommandIdChecked(int command_id) const { } bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { - Extension* extension = this->GetExtension(); + const Extension* extension = this->GetExtension(); if (!extension) return false; @@ -99,7 +99,7 @@ bool ExtensionContextMenuModel::GetAcceleratorForCommandId( } void ExtensionContextMenuModel::ExecuteCommand(int command_id) { - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); if (!extension) return; @@ -151,7 +151,7 @@ void ExtensionContextMenuModel::InstallUIAbort() { Release(); } -Extension* ExtensionContextMenuModel::GetExtension() const { +const Extension* ExtensionContextMenuModel::GetExtension() const { ExtensionsService* extension_service = profile_->GetExtensionsService(); return extension_service->GetExtensionById(extension_id_, false); } diff --git a/chrome/browser/extensions/extension_context_menu_model.h b/chrome/browser/extensions/extension_context_menu_model.h index e7c5b31..89cf3f9 100644 --- a/chrome/browser/extensions/extension_context_menu_model.h +++ b/chrome/browser/extensions/extension_context_menu_model.h @@ -37,7 +37,7 @@ class ExtensionContextMenuModel // prefs::kExtensionsUIDeveloperMode is enabled then a menu item // will be shown for "Inspect Popup" which, when selected, will cause // ShowPopupForDevToolsWindow() to be called on |delegate|. - ExtensionContextMenuModel(Extension* extension, + ExtensionContextMenuModel(const Extension* extension, Browser* browser, PopupDelegate* delegate); virtual ~ExtensionContextMenuModel(); @@ -58,7 +58,7 @@ class ExtensionContextMenuModel // Gets the extension we are displaying the menu for. Returns NULL if the // extension has been uninstalled and no longer exists. - Extension* GetExtension() const; + const Extension* GetExtension() const; // A copy of the extension's id. std::string extension_id_; diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc index 32b67af..3ad8813 100644 --- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc +++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc @@ -51,7 +51,8 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { void CrashExtension(size_t index) { ASSERT_LT(index, GetExtensionsService()->extensions()->size()); - Extension* extension = GetExtensionsService()->extensions()->at(index); + const Extension* extension = + GetExtensionsService()->extensions()->at(index); ASSERT_TRUE(extension); std::string extension_id(extension->id()); ExtensionHost* extension_host = @@ -69,7 +70,8 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { void CheckExtensionConsistency(size_t index) { ASSERT_LT(index, GetExtensionsService()->extensions()->size()); - Extension* extension = GetExtensionsService()->extensions()->at(index); + const Extension* extension = + GetExtensionsService()->extensions()->at(index); ASSERT_TRUE(extension); ExtensionHost* extension_host = GetExtensionProcessManager()->GetBackgroundHostForExtension(extension); @@ -85,7 +87,7 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { const size_t size_before = GetExtensionsService()->extensions()->size(); ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); - Extension* extension = GetExtensionsService()->extensions()->back(); + const Extension* extension = GetExtensionsService()->extensions()->back(); ASSERT_TRUE(extension); first_extension_id_ = extension->id(); CheckExtensionConsistency(size_before); @@ -95,7 +97,8 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { int offset = GetExtensionsService()->extensions()->size(); ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("install").AppendASCII("install"))); - Extension* extension = GetExtensionsService()->extensions()->at(offset); + const Extension* extension = + GetExtensionsService()->extensions()->at(offset); ASSERT_TRUE(extension); second_extension_id_ = extension->id(); CheckExtensionConsistency(offset); diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index 6e51c47..af38e4f 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -26,7 +26,7 @@ class ExtensionDisabledDialogDelegate public: ExtensionDisabledDialogDelegate(Profile* profile, ExtensionsService* service, - Extension* extension) + const Extension* extension) : service_(service), extension_(extension) { AddRef(); // Balanced in Proceed or Abort. @@ -55,7 +55,7 @@ class ExtensionDisabledDialogDelegate scoped_ptr<ExtensionInstallUI> install_ui_; ExtensionsService* service_; - Extension* extension_; + const Extension* extension_; }; class ExtensionDisabledInfobarDelegate @@ -64,7 +64,7 @@ class ExtensionDisabledInfobarDelegate public: ExtensionDisabledInfobarDelegate(TabContents* tab_contents, ExtensionsService* service, - Extension* extension) + const Extension* extension) : ConfirmInfoBarDelegate(tab_contents), tab_contents_(tab_contents), service_(service), @@ -110,7 +110,7 @@ class ExtensionDisabledInfobarDelegate switch (type.value) { case NotificationType::EXTENSION_LOADED: case NotificationType::EXTENSION_UNLOADED_DISABLED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == extension_) tab_contents_->RemoveInfoBar(this); break; @@ -124,11 +124,11 @@ class ExtensionDisabledInfobarDelegate NotificationRegistrar registrar_; TabContents* tab_contents_; ExtensionsService* service_; - Extension* extension_; + const Extension* extension_; }; void ShowExtensionDisabledUI(ExtensionsService* service, Profile* profile, - Extension* extension) { + const Extension* extension) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) return; @@ -142,7 +142,7 @@ void ShowExtensionDisabledUI(ExtensionsService* service, Profile* profile, } void ShowExtensionDisabledDialog(ExtensionsService* service, Profile* profile, - Extension* extension) { + const Extension* extension) { // This object manages its own lifetime. new ExtensionDisabledDialogDelegate(profile, service, extension); } diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.h b/chrome/browser/extensions/extension_disabled_infobar_delegate.h index 16d3b6f..430e652 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.h +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.h @@ -13,10 +13,10 @@ class Profile; // Shows UI to inform the user that an extension was disabled after upgrading // to higher permissions. void ShowExtensionDisabledUI(ExtensionsService* service, Profile* profile, - Extension* extension); + const Extension* extension); // Shows the extension install dialog. void ShowExtensionDisabledDialog(ExtensionsService* service, Profile* profile, - Extension* extension); + const Extension* extension); #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DISABLED_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc index 29c5aab..054eb1e 100644 --- a/chrome/browser/extensions/extension_dom_ui.cc +++ b/chrome/browser/extensions/extension_dom_ui.cc @@ -112,7 +112,7 @@ class ExtensionDOMUIImageLoadingTracker : public ImageLoadingTracker::Observer { ImageLoadingTracker tracker_; scoped_refptr<FaviconService::GetFaviconRequest> request_; - Extension* extension_; + const Extension* extension_; DISALLOW_COPY_AND_ASSIGN(ExtensionDOMUIImageLoadingTracker); }; @@ -126,7 +126,7 @@ ExtensionDOMUI::ExtensionDOMUI(TabContents* tab_contents, GURL url) : DOMUI(tab_contents), url_(url) { ExtensionsService* service = tab_contents->profile()->GetExtensionsService(); - Extension* extension = service->GetExtensionByURL(url); + const Extension* extension = service->GetExtensionByURL(url); if (!extension) extension = service->GetExtensionByWebExtent(url); DCHECK(extension); @@ -271,7 +271,7 @@ bool ExtensionDOMUI::HandleChromeURLOverride(GURL* url, Profile* profile) { } // Verify that the extension that's being referred to actually exists. - Extension* extension = service->GetExtensionByURL(extension_url); + const Extension* extension = service->GetExtensionByURL(extension_url); if (!extension) { // This can currently happen if you use --load-extension one run, and // then don't use it the next. It could also happen if an extension diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc index 9d22da7..b1577167 100644 --- a/chrome/browser/extensions/extension_event_router.cc +++ b/chrome/browser/extensions/extension_event_router.cc @@ -38,7 +38,7 @@ static bool CanCrossIncognito(Profile* profile, // We allow the extension to see events and data from another profile iff it // uses "spanning" behavior and it has incognito access. "split" mode // extensions only see events for a matching profile. - Extension* extension = + const Extension* extension = profile->GetExtensionsService()->GetExtensionById(extension_id, false); return (profile->GetExtensionsService()->IsIncognitoEnabled(extension) && !extension->incognito_split_mode()); diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc index f285e9d..88a6c9e 100644 --- a/chrome/browser/extensions/extension_function.cc +++ b/chrome/browser/extensions/extension_function.cc @@ -21,7 +21,7 @@ ExtensionFunction::ExtensionFunction() ExtensionFunction::~ExtensionFunction() { } -Extension* ExtensionFunction::GetExtension() { +const Extension* ExtensionFunction::GetExtension() { ExtensionsService* service = profile_->GetExtensionsService(); DCHECK(service); return service->GetExtensionById(extension_id_, false); diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index b48d0a9..57a8665 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -107,7 +107,7 @@ class ExtensionFunction : public base::RefCountedThreadSafe<ExtensionFunction> { // Gets the extension that called this function. This can return NULL for // async functions, for example if the extension is unloaded while the // function is running. - Extension* GetExtension(); + const Extension* GetExtension(); // Gets the "current" browser, if any. // diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index e3ca590..783a8bf 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -341,7 +341,7 @@ ExtensionFunctionDispatcher* ExtensionFunctionDispatcher::Create( if (!service->ExtensionBindingsAllowed(url)) return NULL; - Extension* extension = service->GetExtensionByURL(url); + const Extension* extension = service->GetExtensionByURL(url); if (!extension) extension = service->GetExtensionByWebExtent(url); @@ -355,7 +355,7 @@ ExtensionFunctionDispatcher* ExtensionFunctionDispatcher::Create( ExtensionFunctionDispatcher::ExtensionFunctionDispatcher( RenderViewHost* render_view_host, Delegate* delegate, - Extension* extension, + const Extension* extension, const GURL& url) : profile_(render_view_host->process()->profile()), render_view_host_(render_view_host), @@ -448,7 +448,7 @@ void ExtensionFunctionDispatcher::HandleRequest( function->set_user_gesture(params.user_gesture); ExtensionsService* service = profile()->GetExtensionsService(); DCHECK(service); - Extension* extension = service->GetExtensionById(extension_id(), false); + const Extension* extension = service->GetExtensionById(extension_id(), false); DCHECK(extension); function->set_include_incognito(service->IsIncognitoEnabled(extension) && !extension->incognito_split_mode()); diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h index 99328f7..9969b1f 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.h +++ b/chrome/browser/extensions/extension_function_dispatcher.h @@ -125,7 +125,7 @@ class ExtensionFunctionDispatcher { private: ExtensionFunctionDispatcher(RenderViewHost* render_view_host, Delegate* delegate, - Extension* extension, + const Extension* extension, const GURL& url); // We need to keep a pointer to the profile because we use it in the dtor diff --git a/chrome/browser/extensions/extension_gallery_install_apitest.cc b/chrome/browser/extensions/extension_gallery_install_apitest.cc index cf10ed4..5dd4811 100644 --- a/chrome/browser/extensions/extension_gallery_install_apitest.cc +++ b/chrome/browser/extensions/extension_gallery_install_apitest.cc @@ -24,8 +24,7 @@ class ExtensionGalleryInstallApiTest : public ExtensionApiTest { #else #define MAYBE_InstallAndUninstall InstallAndUninstall #endif -IN_PROC_BROWSER_TEST_F(ExtensionGalleryInstallApiTest, - MAYBE_InstallAndUninstall) { +IN_PROC_BROWSER_TEST_F(ExtensionGalleryInstallApiTest, InstallAndUninstall) { host_resolver()->AddRule("www.example.com", "127.0.0.1"); ASSERT_TRUE(test_server()->Start()); diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index d39bcf7..0453880 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -122,8 +122,10 @@ class ExtensionHost::ProcessCreationQueue { //////////////// // ExtensionHost -ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance, - const GURL& url, ViewType::Type host_type) +ExtensionHost::ExtensionHost(const Extension* extension, + SiteInstance* site_instance, + const GURL& url, + ViewType::Type host_type) : extension_(extension), profile_(site_instance->browsing_instance()->profile()), did_stop_loading_(false), @@ -265,7 +267,7 @@ void ExtensionHost::Observe(NotificationType type, // sent. NULL it out so that dirty pointer issues don't arise in cases // when multiple ExtensionHost objects pointing to the same Extension are // present. - if (extension_ == Details<Extension>(details).ptr()) + if (extension_ == Details<const Extension>(details).ptr()) extension_ = NULL; break; default: diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index cf677e3..bb96c5d 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -51,7 +51,7 @@ class ExtensionHost : public RenderViewHostDelegate, typedef std::list<ExtensionHost*> HostPointerList; static HostPointerList* recently_deleted(); - ExtensionHost(Extension* extension, SiteInstance* site_instance, + ExtensionHost(const Extension* extension, SiteInstance* site_instance, const GURL& url, ViewType::Type host_type); ~ExtensionHost(); @@ -73,7 +73,7 @@ class ExtensionHost : public RenderViewHostDelegate, // instantiate Browser objects. void CreateView(Browser* browser); - Extension* extension() { return extension_; } + const Extension* extension() { return extension_; } RenderViewHost* render_view_host() const { return render_view_host_; } RenderProcessHost* render_process_host() const; SiteInstance* site_instance() const; @@ -238,7 +238,7 @@ class ExtensionHost : public RenderViewHostDelegate, bool is_background_page() const { return !view(); } // The extension that we're hosting in this view. - Extension* extension_; + const Extension* extension_; // The profile that this host is tied to. Profile* profile_; diff --git a/chrome/browser/extensions/extension_host_mac.h b/chrome/browser/extensions/extension_host_mac.h index 65aceaa..da46f16 100644 --- a/chrome/browser/extensions/extension_host_mac.h +++ b/chrome/browser/extensions/extension_host_mac.h @@ -12,7 +12,7 @@ class RenderWidgetHostView; class ExtensionHostMac : public ExtensionHost { public: - ExtensionHostMac(Extension* extension, SiteInstance* site_instance, + ExtensionHostMac(const Extension* extension, SiteInstance* site_instance, const GURL& url, ViewType::Type host_type) : ExtensionHost(extension, site_instance, url, host_type) {} virtual ~ExtensionHostMac(); diff --git a/chrome/browser/extensions/extension_icon_manager.cc b/chrome/browser/extensions/extension_icon_manager.cc index 53c8923..887dc3ff 100644 --- a/chrome/browser/extensions/extension_icon_manager.cc +++ b/chrome/browser/extensions/extension_icon_manager.cc @@ -45,7 +45,7 @@ ExtensionIconManager::ExtensionIconManager() ExtensionIconManager::~ExtensionIconManager() { } -void ExtensionIconManager::LoadIcon(Extension* extension) { +void ExtensionIconManager::LoadIcon(const Extension* extension) { ExtensionResource icon_resource = extension->GetIconResource( Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER); if (!icon_resource.extension_root().empty()) { diff --git a/chrome/browser/extensions/extension_icon_manager.h b/chrome/browser/extensions/extension_icon_manager.h index 876f5e0..cc0deb9 100644 --- a/chrome/browser/extensions/extension_icon_manager.h +++ b/chrome/browser/extensions/extension_icon_manager.h @@ -23,7 +23,7 @@ class ExtensionIconManager : public ImageLoadingTracker::Observer { virtual ~ExtensionIconManager(); // Start loading the icon for the given extension. - void LoadIcon(Extension* extension); + void LoadIcon(const Extension* extension); // This returns a bitmap of width/height kFavIconSize, loaded either from an // entry specified in the extension's 'icon' section of the manifest, or a diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc index b3b8a39..0aea7ce 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_infobar_delegate.cc @@ -15,7 +15,7 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(Browser* browser, TabContents* tab_contents, - Extension* extension, + const Extension* extension, const GURL& url) : InfoBarDelegate(tab_contents), observer_(NULL), @@ -78,7 +78,7 @@ void ExtensionInfoBarDelegate::Observe(NotificationType type, break; } case NotificationType::EXTENSION_UNLOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension_ == extension) tab_contents_->RemoveInfoBar(this); break; diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h index dae7aa9..949b655 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.h +++ b/chrome/browser/extensions/extension_infobar_delegate.h @@ -28,10 +28,10 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, }; ExtensionInfoBarDelegate(Browser* browser, TabContents* contents, - Extension* extension, const GURL& url); + const Extension* extension, const GURL& url); ~ExtensionInfoBarDelegate(); - Extension* extension() { return extension_; } + const Extension* extension() { return extension_; } ExtensionHost* extension_host() { return extension_host_.get(); } void set_observer(DelegateObserver* observer) { observer_ = observer; } @@ -60,7 +60,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate, // The observer monitoring when the delegate dies. DelegateObserver* observer_; - Extension* extension_; + const Extension* extension_; TabContents* tab_contents_; diff --git a/chrome/browser/extensions/extension_infobar_module.cc b/chrome/browser/extensions/extension_infobar_module.cc index 590bfc1..6662bea 100644 --- a/chrome/browser/extensions/extension_infobar_module.cc +++ b/chrome/browser/extensions/extension_infobar_module.cc @@ -32,7 +32,7 @@ bool ShowInfoBarFunction::RunImpl() { std::string html_path; EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kHtmlPath, &html_path)); - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); GURL url = extension->GetResourceURL(extension->url(), html_path); Browser* browser = NULL; diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index b1b2205..3c5f819 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -82,7 +82,7 @@ ExtensionInstallUI::~ExtensionInstallUI() { } void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, - Extension* extension) { + const Extension* extension) { DCHECK(ui_loop_ == MessageLoop::current()); extension_ = extension; delegate_ = delegate; @@ -92,7 +92,7 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, // to allow the user to revert if they don't like it. if (extension->is_theme()) { // Remember the current theme in case the user pressed undo. - Extension* previous_theme = profile_->GetTheme(); + const Extension* previous_theme = profile_->GetTheme(); if (previous_theme) previous_theme_id_ = previous_theme->id(); @@ -113,7 +113,7 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, } void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, - Extension* extension) { + const Extension* extension) { DCHECK(ui_loop_ == MessageLoop::current()); extension_ = extension; delegate_ = delegate; @@ -121,7 +121,7 @@ void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, ShowConfirmation(UNINSTALL_PROMPT); } -void ExtensionInstallUI::OnInstallSuccess(Extension* extension) { +void ExtensionInstallUI::OnInstallSuccess(const Extension* extension) { if (extension->is_theme()) { ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, extension, profile_); @@ -226,7 +226,7 @@ void ExtensionInstallUI::OnImageLoaded( void ExtensionInstallUI::ShowThemeInfoBar( const std::string& previous_theme_id, bool previous_use_system_theme, - Extension* new_theme, Profile* profile) { + const Extension* new_theme, Profile* profile) { if (!new_theme->is_theme()) return; @@ -283,7 +283,7 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { #if defined(OS_MACOSX) void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar( - Extension* new_extension) { + const Extension* new_extension) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); if (!browser) return; @@ -304,7 +304,7 @@ void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar( #endif InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( - TabContents* tab_contents, Extension* new_theme, + TabContents* tab_contents, const Extension* new_theme, const std::string& previous_theme_id, bool previous_use_system_theme) { #if defined(TOOLKIT_GTK) return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 7ab2c02..6cc8876 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -58,17 +58,17 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { // // We *MUST* eventually call either Proceed() or Abort() // on |delegate|. - virtual void ConfirmInstall(Delegate* delegate, Extension* extension); + virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); // This is called by the extensions management page to verify whether the // uninstallation should proceed. This is declared virtual for testing. // // We *MUST* eventually call either Proceed() or Abort() // on |delegate|. - virtual void ConfirmUninstall(Delegate* delegate, Extension* extension); + virtual void ConfirmUninstall(Delegate* delegate, const Extension* extension); // Installation was successful. This is declared virtual for testing. - virtual void OnInstallSuccess(Extension* extension); + virtual void OnInstallSuccess(const Extension* extension); // Installation failed. This is declared virtual for testing. virtual void OnInstallFailure(const std::string& error); @@ -85,7 +85,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { // GetNewThemeInstalledInfoBarDelegate()). static void ShowThemeInfoBar( const std::string& previous_theme_id, bool previous_use_system_theme, - Extension* new_theme, Profile* profile); + const Extension* new_theme, Profile* profile); private: // Starts the process of showing a confirmation UI, which is split into two. @@ -96,25 +96,25 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { #if defined(OS_MACOSX) // When an extension is installed on Mac with neither browser action nor // page action icons, show an infobar instead of a popup bubble. - void ShowGenericExtensionInstalledInfoBar(Extension* new_extension); + void ShowGenericExtensionInstalledInfoBar(const Extension* new_extension); #endif // Returns the delegate to control the browser's info bar. This is // within its own function due to its platform-specific nature. static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate( - TabContents* tab_contents, Extension* new_theme, + TabContents* tab_contents, const Extension* new_theme, const std::string& previous_theme_id, bool previous_use_system_theme); // Implements the showing of the install/uninstall dialog prompt. // NOTE: The implementations of this function is platform-specific. static void ShowExtensionInstallUIPromptImpl( - Profile* profile, Delegate* delegate, Extension* extension, + Profile* profile, Delegate* delegate, const Extension* extension, SkBitmap* icon, PromptType type); // Implements the showing of the new install dialog. The implementations of // this function are platform-specific. static void ShowExtensionInstallUIPrompt2Impl( - Profile* profile, Delegate* delegate, Extension* extension, + Profile* profile, Delegate* delegate, const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions); Profile* profile_; @@ -125,7 +125,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { bool previous_use_system_theme_; SkBitmap icon_; // The extensions installation icon. - Extension* extension_; // The extension we are showing the UI for. + const Extension* extension_; // The extension we are showing the UI for. Delegate* delegate_; // The delegate we will call Proceed/Abort on after // confirmation UI. PromptType prompt_type_; // The type of prompt we are going to show. diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index 14a6a5b..9a5a9f2 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -39,7 +39,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, // Install theme once and undo to verify we go back to default theme. FilePath theme_path = test_data_dir_.AppendASCII("theme.crx"); ASSERT_TRUE(InstallExtensionWithUI(theme_path, 1)); - Extension* theme = browser()->profile()->GetTheme(); + const Extension* theme = browser()->profile()->GetTheme(); ASSERT_TRUE(theme); ASSERT_EQ(theme_crx, theme->id()); VerifyThemeInfoBarAndUndoInstall(); diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc index 50777db..fcf40b8 100644 --- a/chrome/browser/extensions/extension_management_api.cc +++ b/chrome/browser/extensions/extension_management_api.cc @@ -107,7 +107,7 @@ bool GetAllExtensionsFunction::RunImpl() { bool LaunchAppFunction::RunImpl() { std::string extension_id; EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id)); - Extension* extension = service()->GetExtensionById(extension_id, true); + const Extension* extension = service()->GetExtensionById(extension_id, true); if (!extension) { error_ = ExtensionErrorUtils::FormatErrorMessage(kNoExtensionError, extension_id); @@ -219,7 +219,7 @@ void ExtensionManagementEventRouter::Observe( Details<UninstalledExtensionInfo>(details).ptr()->extension_id; args.Append(Value::CreateStringValue(extension_id)); } else { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); CHECK(extension); ExtensionsService* service = profile->GetExtensionsService(); bool enabled = service->GetExtensionById(extension->id(), false) != NULL; diff --git a/chrome/browser/extensions/extension_management_browsertest.cc b/chrome/browser/extensions/extension_management_browsertest.cc index e6b1f8f..a80cc8a 100644 --- a/chrome/browser/extensions/extension_management_browsertest.cc +++ b/chrome/browser/extensions/extension_management_browsertest.cc @@ -25,7 +25,7 @@ class ExtensionManagementTest : public ExtensionBrowserTest { // in the extension's manifest. We use the version as reported by the // background page to test how overinstalling crx files with the same // manifest version works. - bool IsExtensionAtVersion(Extension* extension, + bool IsExtensionAtVersion(const Extension* extension, const std::string& expected_version) { // 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 @@ -171,7 +171,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) { .AppendASCII("1.0"))); ASSERT_EQ(size_before + 1, service->extensions()->size()); EXPECT_EQ(0u, service->disabled_extensions()->size()); - Extension* extension = service->extensions()->at(size_before); + const Extension* extension = service->extensions()->at(size_before); EXPECT_TRUE(manager->GetBackgroundHostForExtension(extension)); ASSERT_TRUE(service->HasInstalledExtensions()); diff --git a/chrome/browser/extensions/extension_menu_manager.cc b/chrome/browser/extensions/extension_menu_manager.cc index 58bd1af..9ddb0f0 100644 --- a/chrome/browser/extensions/extension_menu_manager.cc +++ b/chrome/browser/extensions/extension_menu_manager.cc @@ -125,7 +125,7 @@ const ExtensionMenuItem::List* ExtensionMenuManager::MenuItems( return NULL; } -bool ExtensionMenuManager::AddContextItem(Extension* extension, +bool ExtensionMenuManager::AddContextItem(const Extension* extension, ExtensionMenuItem* item) { const std::string& extension_id = item->extension_id(); // The item must have a non-empty extension id, and not have already been @@ -455,7 +455,7 @@ void ExtensionMenuManager::Observe(NotificationType type, NOTREACHED(); return; } - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (ContainsKey(context_items_, extension->id())) { RemoveAllContextItems(extension->id()); } diff --git a/chrome/browser/extensions/extension_menu_manager.h b/chrome/browser/extensions/extension_menu_manager.h index 41edb61..4455ee1 100644 --- a/chrome/browser/extensions/extension_menu_manager.h +++ b/chrome/browser/extensions/extension_menu_manager.h @@ -198,7 +198,7 @@ class ExtensionMenuManager : public NotificationObserver { // Adds a top-level menu item for an extension, requiring the |extension| // pointer so it can load the icon for the extension. Takes ownership of // |item|. Returns a boolean indicating success or failure. - bool AddContextItem(Extension* extension, ExtensionMenuItem* item); + bool AddContextItem(const Extension* extension, ExtensionMenuItem* item); // Add an item as a child of another item which has been previously added, and // takes ownership of |item|. Returns a boolean indicating success or failure. diff --git a/chrome/browser/extensions/extension_menu_manager_unittest.cc b/chrome/browser/extensions/extension_menu_manager_unittest.cc index 56c95c4..549c245 100644 --- a/chrome/browser/extensions/extension_menu_manager_unittest.cc +++ b/chrome/browser/extensions/extension_menu_manager_unittest.cc @@ -323,7 +323,7 @@ TEST_F(ExtensionMenuManagerTest, ExtensionUnloadRemovesMenuItems) { // gone. notifier->Notify(NotificationType::EXTENSION_UNLOADED, Source<Profile>(NULL), - Details<Extension>(extension1)); + Details<const Extension>(extension1)); ASSERT_EQ(NULL, manager_.MenuItems(extension1->id())); ASSERT_EQ(1u, manager_.MenuItems(extension2->id())->size()); ASSERT_TRUE(manager_.GetItemById(id1) == NULL); diff --git a/chrome/browser/extensions/extension_metrics_apitest.cc b/chrome/browser/extensions/extension_metrics_apitest.cc index ee4761c..c9464d2 100644 --- a/chrome/browser/extensions/extension_metrics_apitest.cc +++ b/chrome/browser/extensions/extension_metrics_apitest.cc @@ -146,7 +146,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) { UserActionObserver observer; ASSERT_TRUE(RunExtensionTest("metrics")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension); observer.ValidateUserActions(extension, diff --git a/chrome/browser/extensions/extension_pref_store.cc b/chrome/browser/extensions/extension_pref_store.cc index 773e94e..27719ed 100644 --- a/chrome/browser/extensions/extension_pref_store.cc +++ b/chrome/browser/extensions/extension_pref_store.cc @@ -25,7 +25,7 @@ ExtensionPrefStore::~ExtensionPrefStore() { notification_registrar_.RemoveAll(); } -void ExtensionPrefStore::InstallExtensionPref(Extension* extension, +void ExtensionPrefStore::InstallExtensionPref(const Extension* extension, const char* new_pref_path, Value* new_pref_value) { ExtensionStack::iterator i; @@ -62,7 +62,7 @@ void ExtensionPrefStore::InstallExtensionPref(Extension* extension, UpdateOnePref(new_pref_path); } -void ExtensionPrefStore::UninstallExtension(Extension* extension) { +void ExtensionPrefStore::UninstallExtension(const Extension* extension) { // Remove this extension from the stack. for (ExtensionStack::iterator i = extension_stack_.begin(); i != extension_stack_.end(); ++i) { @@ -178,7 +178,7 @@ void ExtensionPrefStore::Observe(NotificationType type, } case NotificationType::EXTENSION_UNLOADED: { Profile* extension_profile = Source<Profile>(source).ptr(); - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); // The ExtensionPrefStore for the local state watches all profiles. if (profile_ == NULL || profile_ == extension_profile) UninstallExtension(extension); @@ -190,7 +190,7 @@ void ExtensionPrefStore::Observe(NotificationType type, } } -ExtensionPrefStore::ExtensionPrefs::ExtensionPrefs(Extension* extension, +ExtensionPrefStore::ExtensionPrefs::ExtensionPrefs(const Extension* extension, PrefValueMap* values) : extension(extension), pref_values(values) {} ExtensionPrefStore::ExtensionPrefs::~ExtensionPrefs() { diff --git a/chrome/browser/extensions/extension_pref_store.h b/chrome/browser/extensions/extension_pref_store.h index 926f29e..00248c3 100644 --- a/chrome/browser/extensions/extension_pref_store.h +++ b/chrome/browser/extensions/extension_pref_store.h @@ -39,13 +39,13 @@ class ExtensionPrefStore : public PrefStore, // Begins tracking the preference and value an extension wishes to set. This // must be called each time an extension API tries to set a preference. // The ExtensionPrefStore will take ownership of the |pref_value|. - virtual void InstallExtensionPref(Extension* extension, + virtual void InstallExtensionPref(const Extension* extension, const char* pref_path, Value* pref_value); // Removes an extension and all its preference settings from this PrefStore. // This must be called when an extension is uninstalled or disabled. - virtual void UninstallExtension(Extension* extension); + virtual void UninstallExtension(const Extension* extension); // PrefStore methods: virtual DictionaryValue* prefs() { return prefs_.get(); } @@ -56,7 +56,7 @@ class ExtensionPrefStore : public PrefStore, // The nested pairs are <extension, <pref_path, pref_value> >. This is here, // rather than in (say) notification_type.h, to keep the dependency on // std::pair out of the many places that include notification_type.h. - typedef std::pair<Extension*, std::pair<const char*, Value*> > + typedef std::pair<const Extension*, std::pair<const char*, Value*> > ExtensionPrefDetails; protected: @@ -95,10 +95,10 @@ class ExtensionPrefStore : public PrefStore, // Associates an extension with the prefs it sets. Owns the pref values. struct ExtensionPrefs { - ExtensionPrefs(Extension* extension, PrefValueMap* values); + ExtensionPrefs(const Extension* extension, PrefValueMap* values); ~ExtensionPrefs(); - Extension* extension; + const Extension* extension; PrefValueMap* pref_values; }; diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index eb6485f..8fbabf6 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -320,7 +320,7 @@ bool ExtensionPrefs::DidExtensionEscalatePermissions( } void ExtensionPrefs::SetDidExtensionEscalatePermissions( - Extension* extension, bool did_escalate) { + const Extension* extension, bool did_escalate) { UpdateExtensionPref(extension->id(), kExtensionDidEscalatePermissions, Value::CreateBooleanValue(did_escalate)); prefs_->ScheduleSavePersistentPrefs(); @@ -518,7 +518,7 @@ void ExtensionPrefs::SetToolbarOrder( } void ExtensionPrefs::OnExtensionInstalled( - Extension* extension, Extension::State initial_state, + const Extension* extension, Extension::State initial_state, bool initial_incognito_enabled) { const std::string& id = extension->id(); UpdateExtensionPref(id, kPrefState, @@ -575,7 +575,7 @@ Extension::State ExtensionPrefs::GetExtensionState( return static_cast<Extension::State>(state); } -void ExtensionPrefs::SetExtensionState(Extension* extension, +void ExtensionPrefs::SetExtensionState(const Extension* extension, Extension::State state) { UpdateExtensionPref(extension->id(), kPrefState, Value::CreateIntegerValue(state)); @@ -596,7 +596,7 @@ std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { return version; } -void ExtensionPrefs::UpdateManifest(Extension* extension) { +void ExtensionPrefs::UpdateManifest(const Extension* extension) { if (extension->location() != Extension::LOAD) { UpdateExtensionPref(extension->id(), kPrefManifest, extension->manifest_value()->DeepCopy()); diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h index 97547ea..eb16329 100644 --- a/chrome/browser/extensions/extension_prefs.h +++ b/chrome/browser/extensions/extension_prefs.h @@ -63,7 +63,7 @@ class ExtensionPrefs { void SetToolbarOrder(const std::vector<std::string>& extension_ids); // Called when an extension is installed, so that prefs get created. - void OnExtensionInstalled(Extension* extension, + void OnExtensionInstalled(const Extension* extension, Extension::State initial_state, bool initial_incognito_enabled); @@ -76,14 +76,14 @@ class ExtensionPrefs { Extension::State GetExtensionState(const std::string& extension_id); // Called to change the extension's state when it is enabled/disabled. - void SetExtensionState(Extension* extension, Extension::State); + void SetExtensionState(const Extension* extension, Extension::State); // Did the extension ask to escalate its permission during an upgrade? bool DidExtensionEscalatePermissions(const std::string& id); // If |did_escalate| is true, the preferences for |extension| will be set to // require the install warning when the user tries to enable. - void SetDidExtensionEscalatePermissions(Extension* extension, + void SetDidExtensionEscalatePermissions(const Extension* extension, bool did_escalate); // Returns the version string for the currently installed extension, or @@ -92,7 +92,7 @@ class ExtensionPrefs { // Re-writes the extension manifest into the prefs. // Called to change the extension's manifest when it's re-localized. - void UpdateManifest(Extension* extension); + void UpdateManifest(const Extension* extension); // Returns extension path based on extension ID, or empty FilePath on error. FilePath GetExtensionPath(const std::string& extension_id); diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index f941544..12ff5c0 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -32,11 +32,12 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager { public: explicit IncognitoExtensionProcessManager(Profile* profile); virtual ~IncognitoExtensionProcessManager() {} - virtual ExtensionHost* CreateView(Extension* extension, + virtual ExtensionHost* CreateView(const Extension* extension, const GURL& url, Browser* browser, ViewType::Type view_type); - virtual void CreateBackgroundHost(Extension* extension, const GURL& url); + virtual void CreateBackgroundHost(const Extension* extension, + const GURL& url); virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); virtual RenderProcessHost* GetExtensionProcess(const GURL& url); @@ -48,7 +49,7 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager { // Returns the extension for an URL, which can either be a chrome-extension // URL or a web app URL. - Extension* GetExtensionOrAppByURL(const GURL& url); + const Extension* GetExtensionOrAppByURL(const GURL& url); // Returns true if the extension is allowed to run in incognito mode. bool IsIncognitoEnabled(const Extension* extension); @@ -57,7 +58,7 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager { }; static void CreateBackgroundHost( - ExtensionProcessManager* manager, Extension* extension) { + ExtensionProcessManager* manager, const Extension* extension) { // Start the process for the master page, if it exists. if (extension->background_url().is_valid()) manager->CreateBackgroundHost(extension, extension->background_url()); @@ -110,7 +111,7 @@ ExtensionProcessManager::~ExtensionProcessManager() { DCHECK(background_hosts_.empty()); } -ExtensionHost* ExtensionProcessManager::CreateView(Extension* extension, +ExtensionHost* ExtensionProcessManager::CreateView(const Extension* extension, const GURL& url, Browser* browser, ViewType::Type view_type) { @@ -137,14 +138,14 @@ ExtensionHost* ExtensionProcessManager::CreateView(const GURL& url, ExtensionsService* service = browsing_instance_->profile()->GetExtensionsService(); if (service) { - Extension* extension = service->GetExtensionByURL(url); + const Extension* extension = service->GetExtensionByURL(url); if (extension) return CreateView(extension, url, browser, view_type); } return NULL; } -ExtensionHost* ExtensionProcessManager::CreatePopup(Extension* extension, +ExtensionHost* ExtensionProcessManager::CreatePopup(const Extension* extension, const GURL& url, Browser* browser) { return CreateView(extension, url, browser, ViewType::EXTENSION_POPUP); @@ -155,9 +156,8 @@ ExtensionHost* ExtensionProcessManager::CreatePopup(const GURL& url, return CreateView(url, browser, ViewType::EXTENSION_POPUP); } -ExtensionHost* ExtensionProcessManager::CreateInfobar(Extension* extension, - const GURL& url, - Browser* browser) { +ExtensionHost* ExtensionProcessManager::CreateInfobar( + const Extension* extension, const GURL& url, Browser* browser) { return CreateView(extension, url, browser, ViewType::EXTENSION_INFOBAR); } @@ -167,7 +167,7 @@ ExtensionHost* ExtensionProcessManager::CreateInfobar(const GURL& url, } void ExtensionProcessManager::CreateBackgroundHost( - Extension* extension, const GURL& url) { + const Extension* extension, const GURL& url) { // Don't create multiple background hosts for an extension. if (GetBackgroundHostForExtension(extension)) return; @@ -185,7 +185,7 @@ void ExtensionProcessManager::CreateBackgroundHost( OnExtensionHostCreated(host, true); } -void ExtensionProcessManager::OpenOptionsPage(Extension* extension, +void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, Browser* browser) { DCHECK(!extension->options_url().is_empty()); @@ -203,7 +203,7 @@ void ExtensionProcessManager::OpenOptionsPage(Extension* extension, } ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( - Extension* extension) { + const Extension* extension) { for (ExtensionHostSet::iterator iter = background_hosts_.begin(); iter != background_hosts_.end(); ++iter) { ExtensionHost* host = *iter; @@ -230,7 +230,7 @@ void ExtensionProcessManager::RegisterExtensionProcess( browsing_instance_->profile()->GetExtensionsService(); std::vector<std::string> page_action_ids; - Extension* extension = + const Extension* extension = extension_service->GetExtensionById(extension_id, false); if (extension->page_action()) page_action_ids.push_back(extension->page_action()->id()); @@ -288,14 +288,14 @@ void ExtensionProcessManager::Observe(NotificationType type, ExtensionsService* service = Source<Profile>(source).ptr()->GetExtensionsService(); if (service->is_ready()) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); ::CreateBackgroundHost(this, extension); } break; } case NotificationType::EXTENSION_UNLOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); for (ExtensionHostSet::iterator iter = background_hosts_.begin(); iter != background_hosts_.end(); ++iter) { ExtensionHost* host = *iter; @@ -374,7 +374,7 @@ IncognitoExtensionProcessManager::IncognitoExtensionProcessManager( } ExtensionHost* IncognitoExtensionProcessManager::CreateView( - Extension* extension, + const Extension* extension, const GURL& url, Browser* browser, ViewType::Type view_type) { @@ -394,7 +394,7 @@ ExtensionHost* IncognitoExtensionProcessManager::CreateView( } void IncognitoExtensionProcessManager::CreateBackgroundHost( - Extension* extension, const GURL& url) { + const Extension* extension, const GURL& url) { if (extension->incognito_split_mode()) { if (IsIncognitoEnabled(extension)) ExtensionProcessManager::CreateBackgroundHost(extension, url); @@ -406,7 +406,7 @@ void IncognitoExtensionProcessManager::CreateBackgroundHost( SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL( const GURL& url) { - Extension* extension = GetExtensionOrAppByURL(url); + const Extension* extension = GetExtensionOrAppByURL(url); if (!extension || extension->incognito_split_mode()) { return ExtensionProcessManager::GetSiteInstanceForURL(url); } else { @@ -416,7 +416,7 @@ SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL( RenderProcessHost* IncognitoExtensionProcessManager::GetExtensionProcess( const GURL& url) { - Extension* extension = GetExtensionOrAppByURL(url); + const Extension* extension = GetExtensionOrAppByURL(url); if (!extension || extension->incognito_split_mode()) { return ExtensionProcessManager::GetExtensionProcess(url); } else { @@ -424,7 +424,7 @@ RenderProcessHost* IncognitoExtensionProcessManager::GetExtensionProcess( } } -Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL( +const Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL( const GURL& url) { ExtensionsService* service = browsing_instance_->profile()->GetExtensionsService(); diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h index d284275..2d812ef 100644 --- a/chrome/browser/extensions/extension_process_manager.h +++ b/chrome/browser/extensions/extension_process_manager.h @@ -35,33 +35,34 @@ class ExtensionProcessManager : public NotificationObserver { // Creates a new ExtensionHost with its associated view, grouping it in the // appropriate SiteInstance (and therefore process) based on the URL and // profile. - virtual ExtensionHost* CreateView(Extension* extension, + virtual ExtensionHost* CreateView(const Extension* extension, const GURL& url, Browser* browser, ViewType::Type view_type); ExtensionHost* CreateView(const GURL& url, Browser* browser, ViewType::Type view_type); - ExtensionHost* CreatePopup(Extension* extension, + ExtensionHost* CreatePopup(const Extension* extension, const GURL& url, Browser* browser); ExtensionHost* CreatePopup(const GURL& url, Browser* browser); - ExtensionHost* CreateInfobar(Extension* extension, + ExtensionHost* CreateInfobar(const Extension* extension, const GURL& url, Browser* browser); ExtensionHost* CreateInfobar(const GURL& url, Browser* browser); // Open the extension's options page. - void OpenOptionsPage(Extension* extension, Browser* browser); + void OpenOptionsPage(const Extension* extension, Browser* browser); // Creates a new UI-less extension instance. Like CreateView, but not // displayed anywhere. - virtual void CreateBackgroundHost(Extension* extension, const GURL& url); + virtual void 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. - ExtensionHost* GetBackgroundHostForExtension(Extension* extension); + ExtensionHost* GetBackgroundHostForExtension(const Extension* extension); // Returns the SiteInstance that the given URL belongs to. virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); diff --git a/chrome/browser/extensions/extension_proxy_apitest.cc b/chrome/browser/extensions/extension_proxy_apitest.cc index 9c127ad..a22baf8 100644 --- a/chrome/browser/extensions/extension_proxy_apitest.cc +++ b/chrome/browser/extensions/extension_proxy_apitest.cc @@ -16,7 +16,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyAutoSettings) { switches::kEnableExperimentalExtensionApis); ASSERT_TRUE(RunExtensionTest("proxy/auto")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); @@ -46,7 +46,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualSingle) { switches::kEnableExperimentalExtensionApis); ASSERT_TRUE(RunExtensionTest("proxy/single")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); @@ -81,7 +81,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProxyManualIndividual) { switches::kEnableExperimentalExtensionApis); ASSERT_TRUE(RunExtensionTest("proxy/individual")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension); PrefService* pref_service = browser()->profile()->GetPrefs(); diff --git a/chrome/browser/extensions/extension_sidebar_api.cc b/chrome/browser/extensions/extension_sidebar_api.cc index 8b6913e..7dbb6fd 100644 --- a/chrome/browser/extensions/extension_sidebar_api.cc +++ b/chrome/browser/extensions/extension_sidebar_api.cc @@ -51,7 +51,7 @@ const char kShownState[] = "shown"; } static GURL ResolvePossiblyRelativeURL(const std::string& url_string, - Extension* extension) { + const Extension* extension) { GURL url = GURL(url_string); if (!url.is_valid()) url = extension->GetResourceURL(url_string); @@ -59,7 +59,7 @@ static GURL ResolvePossiblyRelativeURL(const std::string& url_string, return url; } -static bool CanUseHost(Extension* extension, +static bool CanUseHost(const Extension* extension, const GURL& url, std::string* error) { if (extension->HasHostPermission(url)) diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 76b001a..ce3a92a 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -65,7 +65,7 @@ static bool GetTabById(int tab_id, Profile* profile, // but because the api shipped with urls resolved relative to their extension // base, we decided it wasn't worth breaking existing extensions to fix. static GURL ResolvePossiblyRelativeURL(std::string url_string, - Extension* extension); + const Extension* extension); // Return the type name for a browser window type. static std::string GetWindowTypeText(Browser::Type type); @@ -705,7 +705,7 @@ bool UpdateTabFunction::RunImpl() { // JavaScript URLs can do the same kinds of things as cross-origin XHR, so // we need to check host permissions before allowing them. if (url.SchemeIs(chrome::kJavaScriptScheme)) { - Extension* extension = GetExtension(); + const Extension* extension = GetExtension(); const std::vector<URLPattern> host_permissions = extension->host_permissions(); if (!Extension::CanExecuteScriptOnPage( @@ -1149,7 +1149,7 @@ static std::string GetWindowTypeText(Browser::Type type) { } static GURL ResolvePossiblyRelativeURL(std::string url_string, - Extension* extension) { + const Extension* extension) { GURL url = GURL(url_string); if (!url.is_valid()) url = extension->GetResourceURL(url_string); diff --git a/chrome/browser/extensions/extension_toolbar_model.cc b/chrome/browser/extensions/extension_toolbar_model.cc index 086b8c4..4b55442 100644 --- a/chrome/browser/extensions/extension_toolbar_model.cc +++ b/chrome/browser/extensions/extension_toolbar_model.cc @@ -45,7 +45,7 @@ void ExtensionToolbarModel::RemoveObserver(Observer* observer) { observers_.RemoveObserver(observer); } -void ExtensionToolbarModel::MoveBrowserAction(Extension* extension, +void ExtensionToolbarModel::MoveBrowserAction(const Extension* extension, int index) { ExtensionList::iterator pos = std::find(begin(), end(), extension); if (pos == end()) { @@ -93,7 +93,7 @@ void ExtensionToolbarModel::Observe(NotificationType type, if (!service_->is_ready()) return; - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (type == NotificationType::EXTENSION_LOADED) { AddExtension(extension); } else if (type == NotificationType::EXTENSION_UNLOADED || @@ -104,7 +104,7 @@ void ExtensionToolbarModel::Observe(NotificationType type, } } -void ExtensionToolbarModel::AddExtension(Extension* extension) { +void ExtensionToolbarModel::AddExtension(const Extension* extension) { // We only care about extensions with browser actions. if (!extension->browser_action()) return; @@ -126,7 +126,7 @@ void ExtensionToolbarModel::AddExtension(Extension* extension) { UpdatePrefs(); } -void ExtensionToolbarModel::RemoveExtension(Extension* extension) { +void ExtensionToolbarModel::RemoveExtension(const Extension* extension) { ExtensionList::iterator pos = std::find(begin(), end(), extension); if (pos == end()) { return; @@ -162,7 +162,7 @@ void ExtensionToolbarModel::InitializeExtensionList() { // Create the lists. for (size_t i = 0; i < service_->extensions()->size(); ++i) { - Extension* extension = service_->extensions()->at(i); + const Extension* extension = service_->extensions()->at(i); if (!extension->browser_action()) continue; @@ -208,7 +208,7 @@ void ExtensionToolbarModel::UpdatePrefs() { service_->extension_prefs()->SetToolbarOrder(ids); } -Extension* ExtensionToolbarModel::GetExtensionByIndex(int index) const { +const Extension* ExtensionToolbarModel::GetExtensionByIndex(int index) const { return toolitems_.at(index); } diff --git a/chrome/browser/extensions/extension_toolbar_model.h b/chrome/browser/extensions/extension_toolbar_model.h index a38fc8c..37c3a08 100644 --- a/chrome/browser/extensions/extension_toolbar_model.h +++ b/chrome/browser/extensions/extension_toolbar_model.h @@ -30,13 +30,13 @@ class ExtensionToolbarModel : public NotificationObserver { public: // An extension with a browser action button has been added, and should go // in the toolbar at |index|. - virtual void BrowserActionAdded(Extension* extension, int index) {} + virtual void BrowserActionAdded(const Extension* extension, int index) {} // The browser action button for |extension| should no longer show. - virtual void BrowserActionRemoved(Extension* extension) {} + virtual void BrowserActionRemoved(const Extension* extension) {} // The browser action button for |extension| has been moved to |index|. - virtual void BrowserActionMoved(Extension* extension, int index) {} + virtual void BrowserActionMoved(const Extension* extension, int index) {} // Called when the model has finished loading. virtual void ModelLoaded() {} @@ -48,7 +48,7 @@ class ExtensionToolbarModel : public NotificationObserver { // Functions called by the view. void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); - void MoveBrowserAction(Extension* extension, int index); + void MoveBrowserAction(const Extension* extension, int index); // If count == size(), this will set the visible icon count to -1, meaning // "show all actions". void SetVisibleIconCount(int count); @@ -69,7 +69,7 @@ class ExtensionToolbarModel : public NotificationObserver { return toolitems_.end(); } - Extension* GetExtensionByIndex(int index) const; + const Extension* GetExtensionByIndex(int index) const; // Utility functions for converting between an index into the list of // incognito-enabled browser actions, and the list of all browser actions. @@ -93,8 +93,8 @@ class ExtensionToolbarModel : public NotificationObserver { // Our observers. ObserverList<Observer> observers_; - void AddExtension(Extension* extension); - void RemoveExtension(Extension* extension); + void AddExtension(const Extension* extension); + void RemoveExtension(const Extension* extension); // Our ExtensionsService, guaranteed to outlive us. ExtensionsService* service_; diff --git a/chrome/browser/extensions/extension_toolbar_model_browsertest.cc b/chrome/browser/extensions/extension_toolbar_model_browsertest.cc index 031672e..45c936e 100644 --- a/chrome/browser/extensions/extension_toolbar_model_browsertest.cc +++ b/chrome/browser/extensions/extension_toolbar_model_browsertest.cc @@ -37,19 +37,19 @@ class ExtensionToolbarModelTest : public ExtensionBrowserTest, model_->RemoveObserver(this); } - virtual void BrowserActionAdded(Extension* extension, int index) { + virtual void BrowserActionAdded(const Extension* extension, int index) { inserted_count_++; } - virtual void BrowserActionRemoved(Extension* extension) { + virtual void BrowserActionRemoved(const Extension* extension) { removed_count_++; } - virtual void BrowserActionMoved(Extension* extension, int index) { + virtual void BrowserActionMoved(const Extension* extension, int index) { moved_count_++; } - Extension* ExtensionAt(int index) { + const Extension* ExtensionAt(int index) { for (ExtensionList::iterator i = model_->begin(); i < model_->end(); ++i) { if (index-- == 0) return *i; @@ -87,7 +87,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, Basic) { // We should now find our extension in the model. EXPECT_EQ(1, inserted_count_); EXPECT_EQ(1u, model_->size()); - Extension* extension = ExtensionAt(0); + const Extension* extension = ExtensionAt(0); ASSERT_TRUE(NULL != extension); EXPECT_STREQ("A browser action with no icon that makes the page red", extension->name().c_str()); @@ -96,7 +96,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, Basic) { model_->MoveBrowserAction(extension, 0); EXPECT_EQ(1, moved_count_); EXPECT_EQ(1u, model_->size()); - Extension* extension2 = ExtensionAt(0); + const Extension* extension2 = ExtensionAt(0); EXPECT_EQ(extension, extension2); UnloadExtension(extension->id()); @@ -118,7 +118,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, ReorderAndReinsert) { // First extension loaded. EXPECT_EQ(1, inserted_count_); EXPECT_EQ(1u, model_->size()); - Extension* extensionA = ExtensionAt(0); + const Extension* extensionA = ExtensionAt(0); ASSERT_TRUE(NULL != extensionA); EXPECT_STREQ("A browser action with no icon that makes the page red", extensionA->name().c_str()); @@ -132,7 +132,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, ReorderAndReinsert) { // Second extension loaded. EXPECT_EQ(2, inserted_count_); EXPECT_EQ(2u, model_->size()); - Extension* extensionB = ExtensionAt(1); + const Extension* extensionB = ExtensionAt(1); ASSERT_TRUE(NULL != extensionB); EXPECT_STREQ("Popup tester", extensionB->name().c_str()); @@ -145,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, ReorderAndReinsert) { // Third extension loaded. EXPECT_EQ(3, inserted_count_); EXPECT_EQ(3u, model_->size()); - Extension* extensionC = ExtensionAt(2); + const Extension* extensionC = ExtensionAt(2); ASSERT_TRUE(NULL != extensionC); EXPECT_STREQ("A page action which removes a popup.", extensionC->name().c_str()); diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index abdba15..df19489 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -734,7 +734,7 @@ bool ExtensionUpdater::GetExistingVersion(const std::string& id, *version = prefs_->GetString(kExtensionBlacklistUpdateVersion); return true; } - Extension* extension = service_->GetExtensionById(id, false); + const Extension* extension = service_->GetExtensionById(id, false); if (!extension) { return false; } diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc index bae09c6..581be2b 100644 --- a/chrome/browser/extensions/extension_updater_unittest.cc +++ b/chrome/browser/extensions/extension_updater_unittest.cc @@ -57,7 +57,7 @@ class MockService : public ExtensionUpdateService { FAIL(); } - virtual Extension* GetExtensionById(const std::string& id, bool) { + virtual const Extension* GetExtensionById(const std::string& id, bool) { ADD_FAILURE(); return NULL; } @@ -142,7 +142,7 @@ class ServiceForManifestTests : public MockService { virtual ~ServiceForManifestTests() {} - virtual Extension* GetExtensionById(const std::string& id, bool) { + virtual const Extension* GetExtensionById(const std::string& id, bool) { for (ExtensionList::iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { if ((*iter)->id() == id) { @@ -194,7 +194,7 @@ class ServiceForDownloadTests : public MockService { return pending_extensions_; } - virtual Extension* GetExtensionById(const std::string& id, bool) { + virtual const Extension* GetExtensionById(const std::string& id, bool) { last_inquired_extension_id_ = id; return NULL; } @@ -803,7 +803,7 @@ class ExtensionUpdaterTest : public testing::Test { service.set_extensions(tmp); ManifestFetchData fetch_data(update_url); - Extension* extension = tmp[0]; + const Extension* extension = tmp[0]; fetch_data.AddExtension(extension->id(), extension->VersionString(), ManifestFetchData::kNeverPinged); UpdateManifest::Results results; diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc index 3471cd4..5744beb 100644 --- a/chrome/browser/extensions/extension_webstore_private_api.cc +++ b/chrome/browser/extensions/extension_webstore_private_api.cc @@ -53,7 +53,7 @@ BrowserSignin* GetBrowserSignin(Profile* profile) { bool IsWebStoreURL(Profile* profile, const GURL& url) { ExtensionsService* service = profile->GetExtensionsService(); - Extension* store = service->GetWebStoreApp(); + const Extension* store = service->GetWebStoreApp(); DCHECK(store); return (service->GetExtensionByWebExtent(url) == store); } diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index f48445e..5c81670 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -94,7 +94,7 @@ bool ShouldReloadExtensionManifest(const ExtensionInfo& info) { return extension_l10n_util::ShouldRelocalizeManifest(info); } -void GetExplicitOriginsInExtent(Extension* extension, +void GetExplicitOriginsInExtent(const Extension* extension, std::vector<GURL>* origins) { typedef std::vector<URLPattern> PatternList; std::set<GURL> set; @@ -224,7 +224,7 @@ class ExtensionsServiceBackend // Note: We take ownership of |extension|. void OnExtensionUnpacked(const FilePath& crx_path, const FilePath& unpacked_path, - Extension* extension, + const Extension* extension, const std::string expected_id); // Notify the frontend that there was an error loading an extension. @@ -295,7 +295,7 @@ void ExtensionsServiceBackend::LoadSingleExtension( file_util::AbsolutePath(&extension_path); std::string error; - scoped_refptr<Extension> extension = extension_file_util::LoadExtension( + scoped_refptr<const Extension> extension = extension_file_util::LoadExtension( extension_path, Extension::LOAD, false, // Don't require id @@ -439,7 +439,7 @@ void ExtensionsServiceBackend::ReloadExtensionManifests( // We need to reload original manifest in order to localize properly. std::string error; - scoped_refptr<Extension> extension(extension_file_util::LoadExtension( + scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( info->extension_path, info->extension_location, false, &error)); if (extension.get()) @@ -469,9 +469,9 @@ bool ExtensionsService::IsDownloadFromGallery(const GURL& download_url, return true; } - Extension* download_extension = GetExtensionByWebExtent(download_url); - Extension* referrer_extension = GetExtensionByWebExtent(referrer_url); - Extension* webstore_app = GetWebStoreApp(); + const Extension* download_extension = GetExtensionByWebExtent(download_url); + const Extension* referrer_extension = GetExtensionByWebExtent(referrer_url); + const Extension* webstore_app = GetWebStoreApp(); bool referrer_valid = (referrer_extension == webstore_app); bool download_valid = (download_extension == webstore_app); @@ -762,7 +762,7 @@ void ExtensionsService::AddPendingExtensionInternal( void ExtensionsService::ReloadExtension(const std::string& extension_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); FilePath path; - Extension* current_extension = GetExtensionById(extension_id, false); + const Extension* current_extension = GetExtensionById(extension_id, false); // Disable the extension if it's loaded. It might not be loaded if it crashed. if (current_extension) { @@ -806,7 +806,8 @@ void ExtensionsService::UninstallExtension(const std::string& extension_id, bool external_uninstall) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - Extension* extension = GetExtensionByIdInternal(extension_id, true, true); + const Extension* extension = + GetExtensionByIdInternal(extension_id, true, true); // Callers should not send us nonexistent extensions. DCHECK(extension); @@ -862,7 +863,8 @@ void ExtensionsService::ClearExtensionData(const GURL& extension_url) { void ExtensionsService::EnableExtension(const std::string& extension_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - Extension* extension = GetExtensionByIdInternal(extension_id, false, true); + const Extension* extension = + GetExtensionByIdInternal(extension_id, false, true); if (!extension) { return; } @@ -886,7 +888,8 @@ void ExtensionsService::EnableExtension(const std::string& extension_id) { void ExtensionsService::DisableExtension(const std::string& extension_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - Extension* extension = GetExtensionByIdInternal(extension_id, true, false); + const Extension* extension = + GetExtensionByIdInternal(extension_id, true, false); // The extension may have been disabled already. if (!extension) return; @@ -928,7 +931,7 @@ void ExtensionsService::LoadComponentExtensions() { } std::string error; - scoped_refptr<Extension> extension(Extension::Create( + scoped_refptr<const Extension> extension(Extension::Create( it->root_directory, Extension::COMPONENT, *static_cast<DictionaryValue*>(manifest.get()), @@ -1068,7 +1071,7 @@ void ExtensionsService::ContinueLoadAllExtensions( void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info, bool write_to_prefs) { std::string error; - scoped_refptr<Extension> extension(NULL); + scoped_refptr<const Extension> extension(NULL); if (!extension_prefs_->IsExtensionAllowedByPolicy(info.extension_id)) { error = errors::kDisabledByPolicy; } else if (info.extension_manifest.get()) { @@ -1104,7 +1107,7 @@ void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info, } } -void ExtensionsService::NotifyExtensionLoaded(Extension* extension) { +void ExtensionsService::NotifyExtensionLoaded(const Extension* extension) { // The ChromeURLRequestContexts need to be first to know that the extension // was loaded, otherwise a race can arise where a renderer that is created // for the extension may try to load an extension URL with an extension id @@ -1127,14 +1130,14 @@ void ExtensionsService::NotifyExtensionLoaded(Extension* extension) { NotificationService::current()->Notify( NotificationType::EXTENSION_LOADED, Source<Profile>(profile_), - Details<Extension>(extension)); + Details<const Extension>(extension)); } -void ExtensionsService::NotifyExtensionUnloaded(Extension* extension) { +void ExtensionsService::NotifyExtensionUnloaded(const Extension* extension) { NotificationService::current()->Notify( NotificationType::EXTENSION_UNLOADED, Source<Profile>(profile_), - Details<Extension>(extension)); + Details<const Extension>(extension)); if (profile_) { profile_->UnregisterExtensionWithRequestContexts(extension); @@ -1150,7 +1153,7 @@ void ExtensionsService::NotifyExtensionUnloaded(Extension* extension) { } } -void ExtensionsService::GrantProtectedStorage(Extension* extension) { +void ExtensionsService::GrantProtectedStorage(const Extension* extension) { DCHECK(extension->is_app()) << "Only Apps are allowed protected storage."; std::vector<GURL> origins; GetExplicitOriginsInExtent(extension, &origins); @@ -1158,7 +1161,7 @@ void ExtensionsService::GrantProtectedStorage(Extension* extension) { ++protected_storage_map_[origins[i]]; } -void ExtensionsService::RevokeProtectedStorage(Extension* extension) { +void ExtensionsService::RevokeProtectedStorage(const Extension* extension) { DCHECK(extension->is_app()) << "Attempting to revoke protected storage from " << " a non-app extension."; std::vector<GURL> origins; @@ -1171,7 +1174,7 @@ void ExtensionsService::RevokeProtectedStorage(Extension* extension) { } } -void ExtensionsService::GrantUnlimitedStorage(Extension* extension) { +void ExtensionsService::GrantUnlimitedStorage(const Extension* extension) { DCHECK(extension->HasApiPermission(Extension::kUnlimitedStoragePermission)); std::vector<GURL> origins; GetExplicitOriginsInExtent(extension, &origins); @@ -1206,7 +1209,7 @@ void ExtensionsService::GrantUnlimitedStorage(Extension* extension) { } } -void ExtensionsService::RevokeUnlimitedStorage(Extension* extension) { +void ExtensionsService::RevokeUnlimitedStorage(const Extension* extension) { DCHECK(extension->HasApiPermission(Extension::kUnlimitedStoragePermission)); std::vector<GURL> origins; GetExplicitOriginsInExtent(extension, &origins); @@ -1255,7 +1258,7 @@ void ExtensionsService::UpdateExtensionBlacklist( // Loop current extensions, unload installed extensions. for (ExtensionList::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { - Extension* extension = (*iter); + const Extension* extension = (*iter); if (blacklist_set.find(extension->id()) != blacklist_set.end()) { to_be_removed.push_back(extension->id()); } @@ -1279,7 +1282,7 @@ void ExtensionsService::CheckAdminBlacklist() { // Loop through extensions list, unload installed extensions. for (ExtensionList::const_iterator iter = extensions_.begin(); iter != extensions_.end(); ++iter) { - Extension* extension = (*iter); + const Extension* extension = (*iter); if (!extension_prefs_->IsExtensionAllowedByPolicy(extension->id())) to_be_removed.push_back(extension->id()); } @@ -1300,7 +1303,7 @@ bool ExtensionsService::IsIncognitoEnabled(const Extension* extension) { return extension_prefs_->IsIncognitoEnabled(extension->id()); } -void ExtensionsService::SetIsIncognitoEnabled(Extension* extension, +void ExtensionsService::SetIsIncognitoEnabled(const Extension* extension, bool enabled) { extension_prefs_->SetIsIncognitoEnabled(extension->id(), enabled); @@ -1320,12 +1323,13 @@ bool ExtensionsService::AllowFileAccess(const Extension* extension) { extension_prefs_->AllowFileAccess(extension->id())); } -void ExtensionsService::SetAllowFileAccess(Extension* extension, bool allow) { +void ExtensionsService::SetAllowFileAccess(const Extension* extension, + bool allow) { extension_prefs_->SetAllowFileAccess(extension->id(), allow); NotificationService::current()->Notify( NotificationType::EXTENSION_USER_SCRIPTS_UPDATED, Source<Profile>(profile_), - Details<Extension>(extension)); + Details<const Extension>(extension)); } void ExtensionsService::CheckForExternalUpdates() { @@ -1343,7 +1347,7 @@ void ExtensionsService::CheckForExternalUpdates() { void ExtensionsService::UnloadExtension(const std::string& extension_id) { // Make sure the extension gets deleted after we return from this function. - scoped_refptr<Extension> extension( + scoped_refptr<const Extension> extension( GetExtensionByIdInternal(extension_id, true, true)); // Callers should not send us nonexistent extensions. @@ -1367,7 +1371,7 @@ void ExtensionsService::UnloadExtension(const std::string& extension_id) { NotificationService::current()->Notify( NotificationType::EXTENSION_UNLOADED_DISABLED, Source<Profile>(profile_), - Details<Extension>(extension.get())); + Details<const Extension>(extension.get())); return; } @@ -1423,10 +1427,10 @@ void ExtensionsService::OnLoadedInstalledExtensions() { NotificationService::NoDetails()); } -void ExtensionsService::OnExtensionLoaded(Extension* extension, +void ExtensionsService::OnExtensionLoaded(const Extension* extension, bool allow_privilege_increase) { // Ensure extension is deleted unless we transfer ownership. - scoped_refptr<Extension> scoped_extension(extension); + scoped_refptr<const Extension> scoped_extension(extension); // The extension is now loaded, remove its data from unloaded extension map. unloaded_extension_paths_.erase(extension->id()); @@ -1442,7 +1446,8 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension, extension->location() == Extension::LOAD || extension->location() == Extension::COMPONENT || Extension::IsExternalLocation(extension->location())) { - Extension* old = GetExtensionByIdInternal(extension->id(), true, true); + const Extension* old = GetExtensionByIdInternal(extension->id(), + true, true); if (old) { // CrxInstaller should have guaranteed that we aren't downgrading. CHECK(extension->version()->CompareTo(*(old->version())) >= 0); @@ -1485,7 +1490,7 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension, NotificationService::current()->Notify( NotificationType::EXTENSION_UPDATE_DISABLED, Source<Profile>(profile_), - Details<Extension>(extension)); + Details<const Extension>(extension)); break; default: NOTREACHED(); @@ -1518,12 +1523,12 @@ void ExtensionsService::UpdateActiveExtensionsInCrashReporter() { child_process_logging::SetActiveExtensions(extension_ids); } -void ExtensionsService::OnExtensionInstalled(Extension* extension, +void ExtensionsService::OnExtensionInstalled(const Extension* extension, bool allow_privilege_increase) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // Ensure extension is deleted unless we transfer ownership. - scoped_refptr<Extension> scoped_extension(extension); + scoped_refptr<const Extension> scoped_extension(extension); Extension::State initial_state = Extension::DISABLED; bool initial_enable_incognito = false; PendingExtensionMap::iterator it = @@ -1645,12 +1650,12 @@ void ExtensionsService::OnExtensionInstalled(Extension* extension, NotificationService::current()->Notify( NotificationType::THEME_INSTALLED, Source<Profile>(profile_), - Details<Extension>(extension)); + Details<const Extension>(extension)); } else { NotificationService::current()->Notify( NotificationType::EXTENSION_INSTALLED, Source<Profile>(profile_), - Details<Extension>(extension)); + Details<const Extension>(extension)); } if (extension->is_app()) { @@ -1663,9 +1668,8 @@ void ExtensionsService::OnExtensionInstalled(Extension* extension, OnExtensionLoaded(scoped_extension, allow_privilege_increase); } -Extension* ExtensionsService::GetExtensionByIdInternal(const std::string& id, - bool include_enabled, - bool include_disabled) { +const Extension* ExtensionsService::GetExtensionByIdInternal( + const std::string& id, bool include_enabled, bool include_disabled) { std::string lowercase_id = StringToLowerASCII(id); if (include_enabled) { for (ExtensionList::const_iterator iter = extensions_.begin(); @@ -1684,16 +1688,16 @@ Extension* ExtensionsService::GetExtensionByIdInternal(const std::string& id, return NULL; } -Extension* ExtensionsService::GetWebStoreApp() { +const Extension* ExtensionsService::GetWebStoreApp() { return GetExtensionById(extension_misc::kWebStoreAppId, false); } -Extension* ExtensionsService::GetExtensionByURL(const GURL& url) { +const Extension* ExtensionsService::GetExtensionByURL(const GURL& url) { return url.scheme() != chrome::kExtensionScheme ? NULL : GetExtensionById(url.host(), false); } -Extension* ExtensionsService::GetExtensionByWebExtent(const GURL& url) { +const Extension* ExtensionsService::GetExtensionByWebExtent(const GURL& url) { for (size_t i = 0; i < extensions_.size(); ++i) { if (extensions_[i]->web_extent().ContainsURL(url)) return extensions_[i]; @@ -1707,11 +1711,11 @@ bool ExtensionsService::ExtensionBindingsAllowed(const GURL& url) { return true; // Allow bindings for all component, hosted apps. - Extension* extension = GetExtensionByWebExtent(url); + const Extension* extension = GetExtensionByWebExtent(url); return (extension && extension->location() == Extension::COMPONENT); } -Extension* ExtensionsService::GetExtensionByOverlappingWebExtent( +const Extension* ExtensionsService::GetExtensionByOverlappingWebExtent( const ExtensionExtent& extent) { for (size_t i = 0; i < extensions_.size(); ++i) { if (extensions_[i]->web_extent().OverlapsWith(extent)) @@ -1757,7 +1761,7 @@ void ExtensionsService::OnExternalExtensionFileFound( // Before even bothering to unpack, check and see if we already have this // version. This is important because these extensions are going to get // installed on every startup. - Extension* existing = GetExtensionById(id, true); + const Extension* existing = GetExtensionById(id, true); scoped_ptr<Version> other(Version::GetVersionFromString(version)); if (existing) { switch (existing->version()->CompareTo(*other)) { diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index c00c264..213471c 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -89,8 +89,8 @@ class ExtensionUpdateService { virtual const PendingExtensionMap& pending_extensions() const = 0; virtual void UpdateExtension(const std::string& id, const FilePath& path, const GURL& download_url) = 0; - virtual Extension* GetExtensionById(const std::string& id, - bool include_disabled) = 0; + virtual const Extension* GetExtensionById(const std::string& id, + bool include_disabled) = 0; virtual void UpdateExtensionBlacklist( const std::vector<std::string>& blacklist) = 0; virtual void CheckAdminBlacklist() = 0; @@ -179,11 +179,11 @@ class ExtensionsService // Whether this extension can run in an incognito window. bool IsIncognitoEnabled(const Extension* extension); - void SetIsIncognitoEnabled(Extension* extension, bool enabled); + void SetIsIncognitoEnabled(const Extension* extension, bool enabled); // Whether this extension can inject scripts into pages with file URLs. bool AllowFileAccess(const Extension* extension); - void SetAllowFileAccess(Extension* extension, bool allow); + void SetAllowFileAccess(const Extension* extension, bool allow); // Initialize and start all installed extensions. void Init(); @@ -192,7 +192,8 @@ class ExtensionsService void InitEventRouters(); // Look up an extension by ID. - Extension* GetExtensionById(const std::string& id, bool include_disabled) { + const Extension* GetExtensionById(const std::string& id, + bool include_disabled) { return GetExtensionByIdInternal(id, true, include_disabled); } @@ -285,18 +286,19 @@ class ExtensionsService void GarbageCollectExtensions(); // The App that represents the web store. - Extension* GetWebStoreApp(); + const Extension* GetWebStoreApp(); // Lookup an extension by |url|. - Extension* GetExtensionByURL(const GURL& url); + const Extension* GetExtensionByURL(const GURL& url); // If there is an extension for the specified url it is returned. Otherwise // returns the extension whose web extent contains |url|. - Extension* GetExtensionByWebExtent(const GURL& url); + const Extension* GetExtensionByWebExtent(const GURL& url); // Returns an extension that contains any URL that overlaps with the given // extent, if one exists. - Extension* GetExtensionByOverlappingWebExtent(const ExtensionExtent& extent); + const Extension* GetExtensionByOverlappingWebExtent( + const ExtensionExtent& extent); // Returns true if |url| should get extension api bindings and be permitted // to make api calls. Note that this is independent of what extension @@ -321,11 +323,11 @@ class ExtensionsService virtual void OnLoadedInstalledExtensions(); // Called when an extension has been loaded. - void OnExtensionLoaded(Extension* extension, + void OnExtensionLoaded(const Extension* extension, bool allow_privilege_increase); // Called by the backend when an extension has been installed. - void OnExtensionInstalled(Extension* extension, + void OnExtensionInstalled(const Extension* extension, bool allow_privilege_increase); // Called by the backend when an external extension is found. @@ -411,9 +413,9 @@ class ExtensionsService // Look up an extension by ID, optionally including either or both of enabled // and disabled extensions. - Extension* GetExtensionByIdInternal(const std::string& id, - bool include_enabled, - bool include_disabled); + const Extension* GetExtensionByIdInternal(const std::string& id, + bool include_enabled, + bool include_disabled); // Like AddPendingExtension() but assumes an extension with the same // id is not already installed. @@ -425,10 +427,10 @@ class ExtensionsService Extension::Location install_source); // Handles sending notification that |extension| was loaded. - void NotifyExtensionLoaded(Extension* extension); + void NotifyExtensionLoaded(const Extension* extension); // Handles sending notification that |extension| was unloaded. - void NotifyExtensionUnloaded(Extension* extension); + void NotifyExtensionUnloaded(const Extension* extension); // Helper that updates the active extension list used for crash reporting. void UpdateActiveExtensionsInCrashReporter(); @@ -437,10 +439,10 @@ class ExtensionsService void LoadInstalledExtension(const ExtensionInfo& info, bool write_to_prefs); // Helper methods to configure the storage services accordingly. - void GrantProtectedStorage(Extension* extension); - void RevokeProtectedStorage(Extension* extension); - void GrantUnlimitedStorage(Extension* extension); - void RevokeUnlimitedStorage(Extension* extension); + void GrantProtectedStorage(const Extension* extension); + void RevokeProtectedStorage(const Extension* extension); + void GrantUnlimitedStorage(const Extension* extension); + void RevokeUnlimitedStorage(const Extension* extension); // The profile this ExtensionsService is part of. Profile* profile_; diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 18210a9..bcb3f86 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -421,7 +421,7 @@ class ExtensionsServiceTest const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSION_LOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); loaded_.push_back(extension); // The tests rely on the errors being in a certain order, which can vary // depending on how filesystem iteration works. @@ -430,7 +430,7 @@ class ExtensionsServiceTest } case NotificationType::EXTENSION_UNLOADED: { - Extension* e = Details<Extension>(details).ptr(); + const Extension* e = Details<const Extension>(details).ptr(); unloaded_id_ = e->id(); ExtensionList::iterator i = std::find(loaded_.begin(), loaded_.end(), e); @@ -443,7 +443,7 @@ class ExtensionsServiceTest } case NotificationType::EXTENSION_INSTALLED: case NotificationType::THEME_INSTALLED: - installed_ = Details<Extension>(details).ptr(); + installed_ = Details<const Extension>(details).ptr(); break; default: @@ -678,7 +678,7 @@ class ExtensionsServiceTest protected: ExtensionList loaded_; std::string unloaded_id_; - Extension* installed_; + const Extension* installed_; private: NotificationRegistrar registrar_; @@ -776,7 +776,7 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) { ValidateIntegerPref(good2, "state", Extension::ENABLED); ValidateIntegerPref(good2, "location", Extension::INTERNAL); - Extension* extension = loaded_[0]; + const Extension* extension = loaded_[0]; const UserScriptList& scripts = extension->content_scripts(); ASSERT_EQ(2u, scripts.size()); EXPECT_EQ(3u, scripts[0].url_patterns().size()); @@ -1276,7 +1276,7 @@ TEST_F(ExtensionsServiceTest, InstallAppsWithUnlimtedStorage) { PackAndInstallExtension(extensions_path.AppendASCII("app1"), true); ValidatePrefKeyCount(++pref_count); ASSERT_EQ(1u, service_->extensions()->size()); - Extension* extension = service_->extensions()->at(0); + const Extension* extension = service_->extensions()->at(0); const std::string id1 = extension->id(); EXPECT_TRUE(extension->HasApiPermission( Extension::kUnlimitedStoragePermission)); @@ -1334,7 +1334,7 @@ TEST_F(ExtensionsServiceTest, InstallAppsAndCheckStorageProtection) { PackAndInstallExtension(extensions_path.AppendASCII("app1"), true); ValidatePrefKeyCount(++pref_count); ASSERT_EQ(1u, service_->extensions()->size()); - Extension* extension = service_->extensions()->at(0); + const Extension* extension = service_->extensions()->at(0); EXPECT_TRUE(extension->is_app()); const std::string id1 = extension->id(); EXPECT_FALSE(service_->protected_storage_map_.empty()); @@ -1463,7 +1463,7 @@ TEST_F(ExtensionsServiceTest, UpdateExtension) { FilePath path = extensions_path.AppendASCII("good.crx"); InstallExtension(path, true); - Extension* good = service_->extensions()->at(0); + const Extension* good = service_->extensions()->at(0); ASSERT_EQ("1.0.0.0", good->VersionString()); ASSERT_EQ(good_crx, good->id()); @@ -1498,7 +1498,7 @@ TEST_F(ExtensionsServiceTest, UpdateWillNotDowngrade) { FilePath path = extensions_path.AppendASCII("good2.crx"); InstallExtension(path, true); - Extension* good = service_->extensions()->at(0); + const Extension* good = service_->extensions()->at(0); ASSERT_EQ("1.0.0.1", good->VersionString()); ASSERT_EQ(good_crx, good->id()); @@ -1518,7 +1518,7 @@ TEST_F(ExtensionsServiceTest, UpdateToSameVersionIsNoop) { FilePath path = extensions_path.AppendASCII("good.crx"); InstallExtension(path, true); - Extension* good = service_->extensions()->at(0); + const Extension* good = service_->extensions()->at(0); ASSERT_EQ(good_crx, good->id()); UpdateExtension(good_crx, path, FAILED_SILENTLY); } @@ -1533,7 +1533,7 @@ TEST_F(ExtensionsServiceTest, UpdateExtensionPreservesState) { FilePath path = extensions_path.AppendASCII("good.crx"); InstallExtension(path, true); - Extension* good = service_->extensions()->at(0); + const Extension* good = service_->extensions()->at(0); ASSERT_EQ("1.0.0.0", good->VersionString()); ASSERT_EQ(good_crx, good->id()); @@ -1545,7 +1545,7 @@ TEST_F(ExtensionsServiceTest, UpdateExtensionPreservesState) { path = extensions_path.AppendASCII("good2.crx"); UpdateExtension(good_crx, path, INSTALLED); ASSERT_EQ(1u, service_->disabled_extensions()->size()); - Extension* good2 = service_->disabled_extensions()->at(0); + const Extension* good2 = service_->disabled_extensions()->at(0); ASSERT_EQ("1.0.0.1", good2->version()->GetString()); EXPECT_TRUE(service_->IsIncognitoEnabled(good2)); } @@ -1603,7 +1603,7 @@ TEST_F(ExtensionsServiceTest, UpdatePendingExtension) { EXPECT_FALSE(ContainsKey(service_->pending_extensions(), kGoodId)); - Extension* extension = service_->GetExtensionById(kGoodId, true); + const Extension* extension = service_->GetExtensionById(kGoodId, true); ASSERT_TRUE(extension); bool enabled = service_->GetExtensionById(kGoodId, false); @@ -1630,7 +1630,7 @@ TEST_F(ExtensionsServiceTest, UpdatePendingTheme) { EXPECT_FALSE(ContainsKey(service_->pending_extensions(), theme_crx)); - Extension* extension = service_->GetExtensionById(theme_crx, true); + const Extension* extension = service_->GetExtensionById(theme_crx, true); ASSERT_TRUE(extension); EXPECT_EQ(Extension::ENABLED, @@ -1655,7 +1655,7 @@ TEST_F(ExtensionsServiceTest, UpdatePendingExternalCrx) { EXPECT_FALSE(ContainsKey(service_->pending_extensions(), theme_crx)); - Extension* extension = service_->GetExtensionById(theme_crx, true); + const Extension* extension = service_->GetExtensionById(theme_crx, true); ASSERT_TRUE(extension); EXPECT_EQ(Extension::ENABLED, @@ -1682,7 +1682,7 @@ TEST_F(ExtensionsServiceTest, UpdatePendingCrxThemeMismatch) { EXPECT_FALSE(ContainsKey(service_->pending_extensions(), theme_crx)); - Extension* extension = service_->GetExtensionById(theme_crx, true); + const Extension* extension = service_->GetExtensionById(theme_crx, true); ASSERT_FALSE(extension); } @@ -1739,7 +1739,7 @@ TEST_F(ExtensionsServiceTest, UpdatePendingExtensionAlreadyInstalled) { FilePath path = extensions_path.AppendASCII("good.crx"); InstallExtension(path, true); ASSERT_EQ(1u, service_->extensions()->size()); - Extension* good = service_->extensions()->at(0); + const Extension* good = service_->extensions()->at(0); EXPECT_FALSE(good->is_theme()); @@ -1794,7 +1794,7 @@ TEST_F(ExtensionsServiceTest, UnloadBlacklistedExtension) { FilePath path = extensions_path.AppendASCII("good.crx"); InstallExtension(path, true); - Extension* good = service_->extensions()->at(0); + const Extension* good = service_->extensions()->at(0); EXPECT_EQ(good_crx, good->id()); UpdateExtension(good_crx, path, FAILED_SILENTLY); @@ -2127,7 +2127,7 @@ TEST_F(ExtensionsServiceTest, ClearExtensionData) { path = path.AppendASCII("extensions"); path = path.AppendASCII("good.crx"); InstallExtension(path, true); - Extension* extension = service_->GetExtensionById(good_crx, false); + const Extension* extension = service_->GetExtensionById(good_crx, false); ASSERT_TRUE(extension); GURL ext_url(extension->url()); string16 origin_id = diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 45b1cb6..d3f6a6c 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -58,8 +58,7 @@ namespace { -bool ShouldShowExtension(Extension* extension) { - +bool ShouldShowExtension(const Extension* extension) { // Don't show themes since this page's UI isn't really useful for themes. if (extension->is_theme()) return false; @@ -407,7 +406,7 @@ void ExtensionsDOMHandler::OnIconsLoaded(DictionaryValue* json) { } ExtensionResource ExtensionsDOMHandler::PickExtensionIcon( - Extension* extension) { + const Extension* extension) { return extension->GetIconResource(Extension::EXTENSION_ICON_MEDIUM, ExtensionIconSet::MATCH_BIGGER); } @@ -459,7 +458,7 @@ void ExtensionsDOMHandler::HandleEnableMessage(const ListValue* args) { if (enable_str == "true") { ExtensionPrefs* prefs = extensions_service_->extension_prefs(); if (prefs->DidExtensionEscalatePermissions(extension_id)) { - Extension* extension = + const Extension* extension = extensions_service_->GetExtensionById(extension_id, true); ShowExtensionDisabledDialog(extensions_service_, dom_ui_->GetProfile(), extension); @@ -476,8 +475,8 @@ void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const ListValue* args) { std::string extension_id, enable_str; CHECK(args->GetString(0, &extension_id)); CHECK(args->GetString(1, &enable_str)); - Extension* extension = extensions_service_->GetExtensionById(extension_id, - true); + const Extension* extension = + extensions_service_->GetExtensionById(extension_id, true); DCHECK(extension); // Flipping the incognito bit will generate unload/load notifications for the @@ -501,15 +500,15 @@ void ExtensionsDOMHandler::HandleAllowFileAccessMessage(const ListValue* args) { std::string extension_id, allow_str; CHECK(args->GetString(0, &extension_id)); CHECK(args->GetString(1, &allow_str)); - Extension* extension = extensions_service_->GetExtensionById(extension_id, - true); + const Extension* extension = + extensions_service_->GetExtensionById(extension_id, true); DCHECK(extension); extensions_service_->SetAllowFileAccess(extension, allow_str == "true"); } void ExtensionsDOMHandler::HandleUninstallMessage(const ListValue* args) { - Extension* extension = GetExtension(args); + const Extension* extension = GetExtension(args); if (!extension) return; @@ -527,7 +526,7 @@ void ExtensionsDOMHandler::InstallUIProceed() { // The extension can be uninstalled in another window while the UI was // showing. Do nothing in that case. - Extension* extension = + const Extension* extension = extensions_service_->GetExtensionById(extension_id_prompting_, true); if (!extension) return; @@ -542,7 +541,7 @@ void ExtensionsDOMHandler::InstallUIAbort() { } void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { - Extension* extension = GetExtension(args); + const Extension* extension = GetExtension(args); if (!extension || extension->options_url().is_empty()) return; dom_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( @@ -703,7 +702,7 @@ void ExtensionsDOMHandler::Observe(NotificationType type, } } -Extension* ExtensionsDOMHandler::GetExtension(const ListValue* args) { +const Extension* ExtensionsDOMHandler::GetExtension(const ListValue* args) { std::string extension_id = WideToASCII(ExtractStringValue(args)); CHECK(!extension_id.empty()); return extensions_service_->GetExtensionById(extension_id, true); @@ -846,7 +845,7 @@ DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( } std::vector<ExtensionPage> ExtensionsDOMHandler::GetActivePagesForExtension( - Extension* extension) { + const Extension* extension) { std::vector<ExtensionPage> result; // Get the extension process's active views. @@ -872,7 +871,7 @@ std::vector<ExtensionPage> ExtensionsDOMHandler::GetActivePagesForExtension( void ExtensionsDOMHandler::GetActivePagesForExtensionProcess( RenderProcessHost* process, - Extension* extension, + const Extension* extension, std::vector<ExtensionPage> *result) { if (!process) return; diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h index 5660eaa..c8c6143 100644 --- a/chrome/browser/extensions/extensions_ui.h +++ b/chrome/browser/extensions/extensions_ui.h @@ -178,7 +178,7 @@ class ExtensionsDOMHandler void HandleSelectFilePathMessage(const ListValue* args); // Utility for callbacks that get an extension ID as the sole argument. - Extension* GetExtension(const ListValue* args); + const Extension* GetExtension(const ListValue* args); // Forces a UI update if appropriate after a notification is received. void MaybeUpdateAfterNotification(); @@ -198,15 +198,16 @@ class ExtensionsDOMHandler const NotificationDetails& details); // Helper that lists the current active html pages for an extension. - std::vector<ExtensionPage> GetActivePagesForExtension(Extension* extension); + std::vector<ExtensionPage> GetActivePagesForExtension( + const Extension* extension); void GetActivePagesForExtensionProcess( RenderProcessHost* process, - Extension* extension, + const Extension* extension, std::vector<ExtensionPage> *result); // Returns the best icon to display in the UI for an extension, or an empty // ExtensionResource if no good icon exists. - ExtensionResource PickExtensionIcon(Extension* extension); + ExtensionResource PickExtensionIcon(const Extension* extension); // Loads the extension resources into the json data, then calls OnIconsLoaded. // Takes ownership of |icons|. diff --git a/chrome/browser/extensions/image_loading_tracker.cc b/chrome/browser/extensions/image_loading_tracker.cc index f4f9bfd..496c3ad 100644 --- a/chrome/browser/extensions/image_loading_tracker.cc +++ b/chrome/browser/extensions/image_loading_tracker.cc @@ -134,7 +134,7 @@ ImageLoadingTracker::~ImageLoadingTracker() { loader_->StopTracking(); } -void ImageLoadingTracker::LoadImage(Extension* extension, +void ImageLoadingTracker::LoadImage(const Extension* extension, const ExtensionResource& resource, const gfx::Size& max_size, CacheParam cache) { @@ -187,7 +187,7 @@ void ImageLoadingTracker::Observe(NotificationType type, DCHECK(type == NotificationType::EXTENSION_UNLOADED || type == NotificationType::EXTENSION_UNLOADED_DISABLED); - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); // Remove all entries in the load_map_ referencing the extension. This ensures // we don't attempt to cache the image when the load completes. diff --git a/chrome/browser/extensions/image_loading_tracker.h b/chrome/browser/extensions/image_loading_tracker.h index bac2f04..0ce3703 100644 --- a/chrome/browser/extensions/image_loading_tracker.h +++ b/chrome/browser/extensions/image_loading_tracker.h @@ -64,13 +64,13 @@ class ImageLoadingTracker : public NotificationObserver { // |max_size| it will be resized to those dimensions. IMPORTANT NOTE: this // function may call back your observer synchronously (ie before it returns) // if the image was found in the cache. - void LoadImage(Extension* extension, + void LoadImage(const Extension* extension, const ExtensionResource& resource, const gfx::Size& max_size, CacheParam cache); private: - typedef std::map<int, Extension*> LoadMap; + typedef std::map<int, const Extension*> LoadMap; class ImageLoader; diff --git a/chrome/browser/extensions/image_loading_tracker_unittest.cc b/chrome/browser/extensions/image_loading_tracker_unittest.cc index d23e2f6..57b5268 100644 --- a/chrome/browser/extensions/image_loading_tracker_unittest.cc +++ b/chrome/browser/extensions/image_loading_tracker_unittest.cc @@ -163,7 +163,7 @@ TEST_F(ImageLoadingTrackerTest, DeleteExtensionWhileWaitingForCache) { NotificationService::current()->Notify( NotificationType::EXTENSION_UNLOADED, NotificationService::AllSources(), - Details<Extension>(extension.get())); + Details<const Extension>(extension.get())); // Chuck the extension, that way if anyone tries to access it we should crash // or get valgrind errors. diff --git a/chrome/browser/extensions/page_action_apitest.cc b/chrome/browser/extensions/page_action_apitest.cc index c03c030..95e029e 100644 --- a/chrome/browser/extensions/page_action_apitest.cc +++ b/chrome/browser/extensions/page_action_apitest.cc @@ -18,7 +18,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) { ASSERT_TRUE(test_server()->Start()); ASSERT_TRUE(RunExtensionTest("page_action/basics")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; { // Tell the extension to update the page action state. @@ -62,7 +62,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) { IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { // Load the extension, which has no default popup. ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); @@ -107,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionRemovePopup) { // Load the extension, which has a page action with a default popup. ASSERT_TRUE(RunExtensionTest("page_action/remove_popup")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); @@ -136,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionRemovePopup) { // break. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OldPageActions) { ASSERT_TRUE(RunExtensionTest("page_action/old_api")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; // Have the extension enable the page action. @@ -161,7 +161,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OldPageActions) { // Tests popups in page actions. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ShowPageActionPopup) { ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; - Extension* extension = GetSingleLoadedExtension(); + const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.h b/chrome/browser/extensions/sandboxed_extension_unpacker.h index 383156b..8438482 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.h +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.h @@ -29,7 +29,7 @@ class SandboxedExtensionUnpackerClient // for deleting this memory. virtual void OnUnpackSuccess(const FilePath& temp_dir, const FilePath& extension_root, - Extension* extension) = 0; + const Extension* extension) = 0; virtual void OnUnpackFailure(const std::string& error) = 0; protected: diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc index 0ba87d5..4d893e1 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc @@ -25,7 +25,7 @@ using testing::Invoke; void OnUnpackSuccess(const FilePath& temp_dir, const FilePath& extension_root, - Extension* extension) { + const Extension* extension) { // Don't delete temp_dir here, we need to do some post op checking. } @@ -37,7 +37,7 @@ class MockSandboxedExtensionUnpackerClient MOCK_METHOD3(OnUnpackSuccess, void(const FilePath& temp_dir, const FilePath& extension_root, - Extension* extension)); + const Extension* extension)); MOCK_METHOD1(OnUnpackFailure, void(const std::string& error)); diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 6d00c22..ebfbe98 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -81,7 +81,7 @@ bool ThemeInstalledInfoBarDelegate::Cancel() { if (!previous_theme_id_.empty()) { ExtensionsService* service = profile_->GetExtensionsService(); if (service) { - Extension* previous_theme = + const Extension* previous_theme = service->GetExtensionById(previous_theme_id_, true); if (previous_theme) { profile_->SetTheme(previous_theme); @@ -102,7 +102,7 @@ void ThemeInstalledInfoBarDelegate::Observe( case NotificationType::BROWSER_THEME_CHANGED: { // If the new theme is different from what this info bar is associated // with, close this info bar since it is no longer relevant. - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (!extension || theme_id_ != extension->id()) tab_contents_->RemoveInfoBar(this); break; @@ -113,6 +113,6 @@ void ThemeInstalledInfoBarDelegate::Observe( } } -bool ThemeInstalledInfoBarDelegate::MatchesTheme(Extension* theme) { +bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) { return (theme && theme->id() == theme_id_); } diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index 2c54fa5..b1ed99e 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -33,7 +33,7 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, // Returns true if the given theme is the same as the one associated with this // info bar. - bool MatchesTheme(Extension* theme); + bool MatchesTheme(const Extension* theme); // NotificationObserver implementation. virtual void Observe(NotificationType type, diff --git a/chrome/browser/extensions/user_script_listener.cc b/chrome/browser/extensions/user_script_listener.cc index 4e84045..c553b1f 100644 --- a/chrome/browser/extensions/user_script_listener.cc +++ b/chrome/browser/extensions/user_script_listener.cc @@ -98,7 +98,7 @@ void UserScriptListener::ReplaceURLPatterns(const URLPatterns& patterns) { url_patterns_ = patterns; } -void UserScriptListener::CollectURLPatterns(Extension* extension, +void UserScriptListener::CollectURLPatterns(const Extension* extension, URLPatterns* patterns) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -118,12 +118,13 @@ void UserScriptListener::Observe(NotificationType type, switch (type.value) { case NotificationType::EXTENSION_LOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension->content_scripts().empty()) return; // no new patterns from this extension. URLPatterns new_patterns; - CollectURLPatterns(Details<Extension>(details).ptr(), &new_patterns); + CollectURLPatterns(Details<const Extension>(details).ptr(), + &new_patterns); if (!new_patterns.empty()) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, @@ -134,7 +135,8 @@ void UserScriptListener::Observe(NotificationType type, } case NotificationType::EXTENSION_UNLOADED: { - Extension* unloaded_extension = Details<Extension>(details).ptr(); + const Extension* unloaded_extension = + Details<const Extension>(details).ptr(); if (unloaded_extension->content_scripts().empty()) return; // no patterns to delete for this extension. diff --git a/chrome/browser/extensions/user_script_listener.h b/chrome/browser/extensions/user_script_listener.h index 05de21a..3ac83ed 100644 --- a/chrome/browser/extensions/user_script_listener.h +++ b/chrome/browser/extensions/user_script_listener.h @@ -82,7 +82,7 @@ class UserScriptListener // Helper to collect the extension's user script URL patterns in a list and // return it. - void CollectURLPatterns(Extension* extension, URLPatterns* patterns); + void CollectURLPatterns(const Extension* extension, URLPatterns* patterns); // NotificationObserver virtual void Observe(NotificationType type, diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 55c6df2..1712bb6 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -339,7 +339,7 @@ void UserScriptMaster::Observe(NotificationType type, break; case NotificationType::EXTENSION_LOADED: { // Add any content scripts inside the extension. - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); bool incognito_enabled = profile_->GetExtensionsService()-> IsIncognitoEnabled(extension); bool allow_file_access = profile_->GetExtensionsService()-> @@ -357,7 +357,7 @@ void UserScriptMaster::Observe(NotificationType type, } case NotificationType::EXTENSION_UNLOADED: { // Remove any content scripts. - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); UserScriptList new_lone_scripts; for (UserScriptList::iterator iter = lone_scripts_.begin(); iter != lone_scripts_.end(); ++iter) { @@ -373,7 +373,7 @@ void UserScriptMaster::Observe(NotificationType type, break; } case NotificationType::EXTENSION_USER_SCRIPTS_UPDATED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); UserScriptList new_lone_scripts; bool incognito_enabled = profile_->GetExtensionsService()-> IsIncognitoEnabled(extension); |