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 | |
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')
159 files changed, 693 insertions, 633 deletions
diff --git a/chrome/browser/app_launched_animation.h b/chrome/browser/app_launched_animation.h index 278b228..91c029f 100644 --- a/chrome/browser/app_launched_animation.h +++ b/chrome/browser/app_launched_animation.h @@ -18,7 +18,7 @@ class AppLaunchedAnimation { public: // Starts an animation of the |extension| being launched. The |rect| is the // rect of the app icon. - static void Show(Extension* extension, const gfx::Rect& rect); + static void Show(const Extension* extension, const gfx::Rect& rect); private: AppLaunchedAnimation() { } diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index 8bc133e..3111812 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -186,7 +186,7 @@ void KeywordProvider::Start(const AutocompleteInput& input, // If this extension keyword is disabled, make sure we don't add any // matches (including the synchronous one below). ExtensionsService* service = profile_->GetExtensionsService(); - Extension* extension = service->GetExtensionById( + const Extension* extension = service->GetExtensionById( template_url->GetExtensionId(), false); bool enabled = extension && (!profile_->IsOffTheRecord() || service->IsIncognitoEnabled(extension)); diff --git a/chrome/browser/automation/automation_extension_tracker.cc b/chrome/browser/automation/automation_extension_tracker.cc index cd816d3..8ab734d 100644 --- a/chrome/browser/automation/automation_extension_tracker.cc +++ b/chrome/browser/automation/automation_extension_tracker.cc @@ -10,7 +10,7 @@ AutomationExtensionTracker::AutomationExtensionTracker( IPC::Message::Sender* automation) - : AutomationResourceTracker<Extension*>(automation) { + : AutomationResourceTracker<const Extension*>(automation) { registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, @@ -20,9 +20,9 @@ AutomationExtensionTracker::AutomationExtensionTracker( AutomationExtensionTracker::~AutomationExtensionTracker() { } -void AutomationExtensionTracker::AddObserver(Extension* resource) {} +void AutomationExtensionTracker::AddObserver(const Extension* resource) {} -void AutomationExtensionTracker::RemoveObserver(Extension* resource) {} +void AutomationExtensionTracker::RemoveObserver(const Extension* resource) {} void AutomationExtensionTracker::Observe(NotificationType type, const NotificationSource& source, @@ -31,7 +31,7 @@ void AutomationExtensionTracker::Observe(NotificationType type, type != NotificationType::EXTENSION_UNLOADED_DISABLED) return; - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); Profile* profile = Source<Profile>(source).ptr(); if (profile) { ExtensionsService* service = profile->GetExtensionsService(); diff --git a/chrome/browser/automation/automation_extension_tracker.h b/chrome/browser/automation/automation_extension_tracker.h index c1b7ed7..05f16b5 100644 --- a/chrome/browser/automation/automation_extension_tracker.h +++ b/chrome/browser/automation/automation_extension_tracker.h @@ -12,7 +12,7 @@ class Extension; // Tracks an Extension. An Extension is removed on uninstall, not on disable. class AutomationExtensionTracker - : public AutomationResourceTracker<Extension*> { + : public AutomationResourceTracker<const Extension*> { public: explicit AutomationExtensionTracker(IPC::Message::Sender* automation); @@ -23,10 +23,10 @@ class AutomationExtensionTracker // extension, is the one who sends the notification about extension // uninstalls. Instead of using this method, one observer is added for all // extensions in the constructor. - virtual void AddObserver(Extension* resource); + virtual void AddObserver(const Extension* resource); // See related comment above as to why this method is empty. - virtual void RemoveObserver(Extension* resource); + virtual void RemoveObserver(const Extension* resource); // Overriding AutomationResourceTracker Observe. AutomationResourceTracker's // Observe expects the NotificationSource to be the object that is closing. diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index db4ad51..60ed6ef 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -258,7 +258,7 @@ int AutomationProvider::GetIndexForNavigationController( return parent->GetIndexOfController(controller); } -int AutomationProvider::AddExtension(Extension* extension) { +int AutomationProvider::AddExtension(const Extension* extension) { DCHECK(extension); return extension_tracker_->Add(extension); } @@ -299,12 +299,13 @@ DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( return dl_item_value; } -Extension* AutomationProvider::GetExtension(int extension_handle) { +const Extension* AutomationProvider::GetExtension(int extension_handle) { return extension_tracker_->GetResource(extension_handle); } -Extension* AutomationProvider::GetEnabledExtension(int extension_handle) { - Extension* extension = extension_tracker_->GetResource(extension_handle); +const Extension* AutomationProvider::GetEnabledExtension(int extension_handle) { + const Extension* extension = + extension_tracker_->GetResource(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); if (extension && service && service->GetExtensionById(extension->id(), false)) @@ -312,8 +313,10 @@ Extension* AutomationProvider::GetEnabledExtension(int extension_handle) { return NULL; } -Extension* AutomationProvider::GetDisabledExtension(int extension_handle) { - Extension* extension = extension_tracker_->GetResource(extension_handle); +const Extension* AutomationProvider::GetDisabledExtension( + int extension_handle) { + const Extension* extension = + extension_tracker_->GetResource(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); if (extension && service && service->GetExtensionById(extension->id(), true) && @@ -799,7 +802,7 @@ void AutomationProvider::GetEnabledExtensions( const ExtensionList* extensions = service->extensions(); DCHECK(extensions); for (size_t i = 0; i < extensions->size(); ++i) { - Extension* extension = (*extensions)[i]; + const Extension* extension = (*extensions)[i]; DCHECK(extension); if (extension->location() == Extension::INTERNAL || extension->location() == Extension::LOAD) { @@ -848,7 +851,7 @@ void AutomationProvider::InstallExtensionAndGetHandle( void AutomationProvider::UninstallExtension(int extension_handle, bool* success) { *success = false; - Extension* extension = GetExtension(extension_handle); + const Extension* extension = GetExtension(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); if (extension && service) { ExtensionUnloadNotificationObserver observer; @@ -861,7 +864,7 @@ void AutomationProvider::UninstallExtension(int extension_handle, void AutomationProvider::EnableExtension(int extension_handle, IPC::Message* reply_message) { - Extension* extension = GetDisabledExtension(extension_handle); + const Extension* extension = GetDisabledExtension(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); // Only enable if this extension is disabled. @@ -882,7 +885,7 @@ void AutomationProvider::EnableExtension(int extension_handle, void AutomationProvider::DisableExtension(int extension_handle, bool* success) { *success = false; - Extension* extension = GetEnabledExtension(extension_handle); + const Extension* extension = GetEnabledExtension(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); if (extension && service) { ExtensionUnloadNotificationObserver observer; @@ -897,7 +900,7 @@ void AutomationProvider::ExecuteExtensionActionInActiveTabAsync( int extension_handle, int browser_handle, IPC::Message* reply_message) { bool success = false; - Extension* extension = GetEnabledExtension(extension_handle); + const Extension* extension = GetEnabledExtension(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); ExtensionMessageService* message_service = profile_->GetExtensionMessageService(); @@ -922,7 +925,7 @@ void AutomationProvider::ExecuteExtensionActionInActiveTabAsync( void AutomationProvider::MoveExtensionBrowserAction( int extension_handle, int index, bool* success) { *success = false; - Extension* extension = GetEnabledExtension(extension_handle); + const Extension* extension = GetEnabledExtension(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); if (extension && service) { ExtensionToolbarModel* toolbar = service->toolbar_model(); @@ -943,7 +946,7 @@ void AutomationProvider::GetExtensionProperty( bool* success, std::string* value) { *success = false; - Extension* extension = GetExtension(extension_handle); + const Extension* extension = GetExtension(extension_handle); ExtensionsService* service = profile_->GetExtensionsService(); if (extension && service) { ExtensionToolbarModel* toolbar = service->toolbar_model(); diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 5a29b04..66d084a 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -150,7 +150,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Adds the extension passed in to the extension tracker, and returns // the associated handle. If the tracker already contains the extension, // the handle is simply returned. - int AddExtension(Extension* extension); + int AddExtension(const Extension* extension); #if defined(OS_WIN) // Adds the external tab passed in to the tab tracker. @@ -323,15 +323,15 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Returns the extension for the given handle. Returns NULL if there is // no extension for the handle. - Extension* GetExtension(int extension_handle); + const Extension* GetExtension(int extension_handle); // Returns the extension for the given handle, if the handle is valid and // the associated extension is enabled. Returns NULL otherwise. - Extension* GetEnabledExtension(int extension_handle); + const Extension* GetEnabledExtension(int extension_handle); // Returns the extension for the given handle, if the handle is valid and // the associated extension is disabled. Returns NULL otherwise. - Extension* GetDisabledExtension(int extension_handle); + const Extension* GetDisabledExtension(int extension_handle); // Method called by the popup menu tracker when a popup menu is opened. void NotifyPopupMenuOpened(); diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index aeabd00..7cfa96f 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -494,7 +494,7 @@ void ExtensionReadyNotificationObserver::Observe( success = true; break; case NotificationType::EXTENSION_LOADED: - extension_ = Details<Extension>(details).ptr(); + extension_ = Details<const Extension>(details).ptr(); if (!DidExtensionHostsStopLoading(manager_)) return; success = true; diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index de20990..7b76638 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -273,7 +273,7 @@ class ExtensionReadyNotificationObserver : public NotificationObserver { scoped_refptr<AutomationProvider> automation_; int id_; IPC::Message* reply_message_; - Extension* extension_; + const Extension* extension_; DISALLOW_COPY_AND_ASSIGN(ExtensionReadyNotificationObserver); }; diff --git a/chrome/browser/automation/automation_resource_tracker.cc b/chrome/browser/automation/automation_resource_tracker.cc index c233b41..a82265d 100644 --- a/chrome/browser/automation/automation_resource_tracker.cc +++ b/chrome/browser/automation/automation_resource_tracker.cc @@ -15,7 +15,7 @@ AutomationResourceTrackerImpl::AutomationResourceTrackerImpl( AutomationResourceTrackerImpl::~AutomationResourceTrackerImpl() { } -int AutomationResourceTrackerImpl::AddImpl(void* resource) { +int AutomationResourceTrackerImpl::AddImpl(const void* resource) { if (ContainsResourceImpl(resource)) return resource_to_handle_[resource]; @@ -30,7 +30,7 @@ int AutomationResourceTrackerImpl::AddImpl(void* resource) { return handle; } -void AutomationResourceTrackerImpl::RemoveImpl(void* resource) { +void AutomationResourceTrackerImpl::RemoveImpl(const void* resource) { if (!ContainsResourceImpl(resource)) return; @@ -48,7 +48,7 @@ int AutomationResourceTrackerImpl::GenerateHandle() { return ++handle; } -bool AutomationResourceTrackerImpl::ContainsResourceImpl(void* resource) { +bool AutomationResourceTrackerImpl::ContainsResourceImpl(const void* resource) { return resource_to_handle_.find(resource) != resource_to_handle_.end(); } @@ -56,7 +56,7 @@ bool AutomationResourceTrackerImpl::ContainsHandleImpl(int handle) { return handle_to_resource_.find(handle) != handle_to_resource_.end(); } -void* AutomationResourceTrackerImpl::GetResourceImpl(int handle) { +const void* AutomationResourceTrackerImpl::GetResourceImpl(int handle) { HandleToResourceMap::const_iterator iter = handle_to_resource_.find(handle); if (iter == handle_to_resource_.end()) return NULL; @@ -64,7 +64,7 @@ void* AutomationResourceTrackerImpl::GetResourceImpl(int handle) { return iter->second; } -int AutomationResourceTrackerImpl::GetHandleImpl(void* resource) { +int AutomationResourceTrackerImpl::GetHandleImpl(const void* resource) { ResourceToHandleMap::const_iterator iter = resource_to_handle_.find(resource); if (iter == resource_to_handle_.end()) @@ -73,7 +73,8 @@ int AutomationResourceTrackerImpl::GetHandleImpl(void* resource) { return iter->second; } -void AutomationResourceTrackerImpl::HandleCloseNotification(void* resource) { +void AutomationResourceTrackerImpl::HandleCloseNotification( + const void* resource) { if (!ContainsResourceImpl(resource)) return; diff --git a/chrome/browser/automation/automation_resource_tracker.h b/chrome/browser/automation/automation_resource_tracker.h index 671f72b..2d6b0cd 100644 --- a/chrome/browser/automation/automation_resource_tracker.h +++ b/chrome/browser/automation/automation_resource_tracker.h @@ -38,21 +38,21 @@ class AutomationResourceTrackerImpl { // These need to be implemented in AutomationResourceTracker, // since it needs to call the subclass's type-specific notification // registration functions. - virtual void AddObserverTypeProxy(void* resource) = 0; - virtual void RemoveObserverTypeProxy(void* resource) = 0; + virtual void AddObserverTypeProxy(const void* resource) = 0; + virtual void RemoveObserverTypeProxy(const void* resource) = 0; - int AddImpl(void* resource); - void RemoveImpl(void* resource); + int AddImpl(const void* resource); + void RemoveImpl(const void* resource); int GenerateHandle(); - bool ContainsResourceImpl(void* resource); + bool ContainsResourceImpl(const void* resource); bool ContainsHandleImpl(int handle); - void* GetResourceImpl(int handle); - int GetHandleImpl(void* resource); - void HandleCloseNotification(void* resource); + const void* GetResourceImpl(int handle); + int GetHandleImpl(const void* resource); + void HandleCloseNotification(const void* resource); protected: - typedef std::map<void*, int> ResourceToHandleMap; - typedef std::map<int, void*> HandleToResourceMap; + typedef std::map<const void*, int> ResourceToHandleMap; + typedef std::map<int, const void*> HandleToResourceMap; ResourceToHandleMap resource_to_handle_; HandleToResourceMap handle_to_resource_; @@ -109,8 +109,9 @@ class AutomationResourceTracker : public NotificationObserver, // Returns the resource pointer associated with a given handle, or NULL // if that handle is not present in the mapping. + // The casts here allow this to compile with both T = Foo and T = const Foo. T GetResource(int handle) { - return static_cast<T>(GetResourceImpl(handle)); + return static_cast<T>(const_cast<void*>(GetResourceImpl(handle))); } // Returns the handle associated with a given resource pointer, or 0 if @@ -144,11 +145,12 @@ class AutomationResourceTracker : public NotificationObserver, private: // These proxy calls from the base Impl class to the template's subclss. - virtual void AddObserverTypeProxy(void* resource) { - AddObserver(static_cast<T>(resource)); + // The casts here allow this to compile with both T = Foo and T = const Foo. + virtual void AddObserverTypeProxy(const void* resource) { + AddObserver(static_cast<T>(const_cast<void*>(resource))); } - virtual void RemoveObserverTypeProxy(void* resource) { - RemoveObserver(static_cast<T>(resource)); + virtual void RemoveObserverTypeProxy(const void* resource) { + RemoveObserver(static_cast<T>(const_cast<void*>(resource))); } DISALLOW_COPY_AND_ASSIGN(AutomationResourceTracker); diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 8f648d0..ec10dfa 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -3672,7 +3672,7 @@ void TestingAutomationProvider::GetThemeInfo( DictionaryValue* args, IPC::Message* reply_message) { scoped_ptr<DictionaryValue> return_value(new DictionaryValue); - Extension* theme = browser->profile()->GetTheme(); + const Extension* theme = browser->profile()->GetTheme(); if (theme) { return_value->SetString("name", theme->name()); return_value->Set("images", theme->GetThemeImages()->DeepCopy()); diff --git a/chrome/browser/background_contents_service.cc b/chrome/browser/background_contents_service.cc index 1c9b71e..8517d97 100644 --- a/chrome/browser/background_contents_service.cc +++ b/chrome/browser/background_contents_service.cc @@ -110,7 +110,7 @@ void BackgroundContentsService::Observe(NotificationType type, break; case NotificationType::EXTENSION_UNLOADED: ShutdownAssociatedBackgroundContents( - ASCIIToUTF16(Details<Extension>(details)->id())); + ASCIIToUTF16(Details<const Extension>(details)->id())); break; default: NOTREACHED(); @@ -157,7 +157,7 @@ void BackgroundContentsService::CreateBackgroundContents( // Check to make sure that the parent extension is still enabled. ExtensionsService* extensions_service = profile->GetExtensionsService(); - Extension* extension = extensions_service->GetExtensionById( + const Extension* extension = extensions_service->GetExtensionById( UTF16ToASCII(application_id), false); if (!extension) { diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index 080e3b2..0fc898f 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -239,15 +239,15 @@ void BackgroundModeManager::Observe(NotificationType type, #endif break; case NotificationType::EXTENSION_LOADED: - if (IsBackgroundApp(*Details<Extension>(details).ptr())) + if (IsBackgroundApp(*Details<const Extension>(details).ptr())) OnBackgroundAppLoaded(); break; case NotificationType::EXTENSION_UNLOADED: - if (IsBackgroundApp(*Details<Extension>(details).ptr())) + if (IsBackgroundApp(*Details<const Extension>(details).ptr())) OnBackgroundAppUnloaded(); break; case NotificationType::EXTENSION_INSTALLED: - if (IsBackgroundApp(*Details<Extension>(details).ptr())) + if (IsBackgroundApp(*Details<const Extension>(details).ptr())) OnBackgroundAppInstalled(); break; case NotificationType::EXTENSION_UNINSTALLED: diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 12d2338..7c1c05a 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -345,7 +345,7 @@ Browser* Browser::CreateForType(Type type, Profile* profile) { // static Browser* Browser::CreateForApp(const std::string& app_name, - Extension* extension, + const Extension* extension, Profile* profile, bool is_panel) { Browser::Type type = TYPE_APP; @@ -499,7 +499,8 @@ TabContents* Browser::OpenApplication(Profile* profile, // If the extension with |app_id| could't be found, most likely because it // was uninstalled. - Extension* extension = extensions_service->GetExtensionById(app_id, false); + const Extension* extension = + extensions_service->GetExtensionById(app_id, false); if (!extension) return NULL; @@ -510,7 +511,7 @@ TabContents* Browser::OpenApplication(Profile* profile, // static TabContents* Browser::OpenApplication( Profile* profile, - Extension* extension, + const Extension* extension, extension_misc::LaunchContainer container, TabContents* existing_tab) { TabContents* tab = NULL; @@ -538,7 +539,7 @@ TabContents* Browser::OpenApplication( // static TabContents* Browser::OpenApplicationWindow( Profile* profile, - Extension* extension, + const Extension* extension, extension_misc::LaunchContainer container, const GURL& url_input) { GURL url; @@ -589,7 +590,7 @@ TabContents* Browser::OpenApplicationWindow(Profile* profile, GURL& url) { // static TabContents* Browser::OpenApplicationTab(Profile* profile, - Extension* extension, + const Extension* extension, TabContents* existing_tab) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); TabContents* contents = NULL; @@ -3273,7 +3274,7 @@ void Browser::Observe(NotificationType type, if (profile_->IsSameProfile(profile)) { ExtensionsService* service = profile->GetExtensionsService(); DCHECK(service); - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (service->extension_prefs()->DidExtensionEscalatePermissions( extension->id())) ShowExtensionDisabledUI(service, profile_, extension); @@ -3286,7 +3287,7 @@ void Browser::Observe(NotificationType type, window()->GetLocationBar()->UpdatePageActions(); // Close any tabs from the unloaded extension. - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); TabStripModel* model = tab_handler_->GetTabStripModel(); for (int i = model->count() - 1; i >= 0; --i) { TabContents* tc = model->GetTabContentsAt(i); @@ -3322,7 +3323,7 @@ void Browser::Observe(NotificationType type, TabContents* tab_contents = GetSelectedTabContents(); if (!tab_contents) break; - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); CrashedExtensionInfoBarDelegate* delegate = NULL; for (int i = 0; i < tab_contents->infobar_delegate_count();) { delegate = tab_contents->GetInfoBarDelegateAt(i)-> diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index f0e8783..5654106 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -145,7 +145,7 @@ class Browser : public TabHandlerDelegate, // shell. |extension| is optional. If supplied, we create a window with // a bigger icon and title text, that supports tabs. static Browser* CreateForApp(const std::string& app_name, - Extension* extension, + const Extension* extension, Profile* profile, bool is_panel); @@ -154,7 +154,7 @@ class Browser : public TabHandlerDelegate, static Browser* CreateForDevTools(Profile* profile); // Returns the extension app associated with this window, if any. - Extension* extension_app() { return extension_app_; } + const Extension* extension_app() { return extension_app_; } // Set overrides for the initial window bounds and maximized state. void set_override_bounds(const gfx::Rect& bounds) { @@ -235,7 +235,7 @@ class Browser : public TabHandlerDelegate, // NULL. static TabContents* OpenApplication( Profile* profile, - Extension* extension, + const Extension* extension, extension_misc::LaunchContainer container, TabContents* existing_tab); @@ -246,7 +246,7 @@ class Browser : public TabHandlerDelegate, // Browser::Type::EXTENSION_APP (if |extension| is non-NULL). static TabContents* OpenApplicationWindow( Profile* profile, - Extension* extension, + const Extension* extension, extension_misc::LaunchContainer container, const GURL& url); @@ -257,7 +257,7 @@ class Browser : public TabHandlerDelegate, // |existing_tab| if not NULL. Returns NULL if there are no appropriate // existing browser windows for |profile|. static TabContents* OpenApplicationTab(Profile* profile, - Extension* extension, + const Extension* extension, TabContents* existing_tab); // Opens a new window and opens the bookmark manager. @@ -1124,7 +1124,7 @@ class Browser : public TabHandlerDelegate, WebAppAction pending_web_app_action_; // The extension app associated with this window, if any. - Extension* extension_app_; + const Extension* extension_app_; // Tracks the display mode of the tabstrip. mutable BooleanPrefMember use_vertical_tabs_; diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 5f2e1e9..6c57f93 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -156,7 +156,7 @@ class BrowserTest : public ExtensionBrowserTest { } // Returns the app extension aptly named "App Test". - Extension* GetExtension() { + const Extension* GetExtension() { const ExtensionList* extensions = browser()->profile()->GetExtensionsService()->extensions(); for (size_t i = 0; i < extensions->size(); ++i) { @@ -426,7 +426,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); - Extension* extension_app = GetExtension(); + const Extension* extension_app = GetExtension(); ui_test_utils::NavigateToURL(browser(), url); @@ -509,7 +509,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { GURL url(test_server()->GetURL("empty.html")); TabStripModel* model = browser()->tabstrip_model(); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); - Extension* extension_app = GetExtension(); + const Extension* extension_app = GetExtension(); ui_test_utils::NavigateToURL(browser(), url); TabContents* app_contents = new TabContents(browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); diff --git a/chrome/browser/cocoa/extension_install_prompt.mm b/chrome/browser/cocoa/extension_install_prompt.mm index cb33136..3306806 100644 --- a/chrome/browser/cocoa/extension_install_prompt.mm +++ b/chrome/browser/cocoa/extension_install_prompt.mm @@ -20,7 +20,10 @@ class Profile; void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, ExtensionInstallUI::PromptType type) { NSAlert* alert = [[[NSAlert alloc] init] autorelease]; diff --git a/chrome/browser/cocoa/extension_installed_bubble_bridge.h b/chrome/browser/cocoa/extension_installed_bubble_bridge.h index 999fd0a..d878d70 100644 --- a/chrome/browser/cocoa/extension_installed_bubble_bridge.h +++ b/chrome/browser/cocoa/extension_installed_bubble_bridge.h @@ -20,7 +20,7 @@ namespace ExtensionInstalledBubbleCocoa { // This function is called by the ExtensionInstallUI when an extension has been // installed. void ShowExtensionInstalledBubble(gfx::NativeWindow window, - Extension* extension, + const Extension* extension, Browser* browser, SkBitmap icon); } diff --git a/chrome/browser/cocoa/extension_installed_bubble_bridge.mm b/chrome/browser/cocoa/extension_installed_bubble_bridge.mm index e43b956..9c15e97 100644 --- a/chrome/browser/cocoa/extension_installed_bubble_bridge.mm +++ b/chrome/browser/cocoa/extension_installed_bubble_bridge.mm @@ -12,7 +12,7 @@ void ExtensionInstalledBubbleCocoa::ShowExtensionInstalledBubble( gfx::NativeWindow window, - Extension* extension, + const Extension* extension, Browser* browser, SkBitmap icon) { // The controller is deallocated when the window is closed, so no need to diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.h b/chrome/browser/cocoa/extension_installed_bubble_controller.h index bec656d..e5f50a3 100644 --- a/chrome/browser/cocoa/extension_installed_bubble_controller.h +++ b/chrome/browser/cocoa/extension_installed_bubble_controller.h @@ -47,7 +47,7 @@ typedef enum { NSWindowController<NSWindowDelegate> { @private NSWindow* parentWindow_; // weak - Extension* extension_; // weak + const Extension* extension_; // weak Browser* browser_; // weak scoped_nsobject<NSImage> icon_; @@ -72,13 +72,13 @@ typedef enum { IBOutlet NSTextField* extensionInstalledInfoMsg_; } -@property (nonatomic, readonly) Extension* extension; +@property (nonatomic, readonly) const Extension* extension; @property (nonatomic) BOOL pageActionRemoved; // Initialize the window, and then create observers to wait for the extension // to complete loading, or the browser window to close. - (id)initWithParentWindow:(NSWindow*)parentWindow - extension:(Extension*)extension + extension:(const Extension*)extension browser:(Browser*)browser icon:(SkBitmap)icon; diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm index b83b303..b1263fd 100644 --- a/chrome/browser/cocoa/extension_installed_bubble_controller.mm +++ b/chrome/browser/cocoa/extension_installed_bubble_controller.mm @@ -46,7 +46,7 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::EXTENSION_LOADED) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == [controller_ extension]) { [controller_ performSelectorOnMainThread:@selector(showWindow:) withObject:controller_ @@ -74,7 +74,7 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver { @synthesize pageActionRemoved = pageActionRemoved_; // Exposed for unit test. - (id)initWithParentWindow:(NSWindow*)parentWindow - extension:(Extension*)extension + extension:(const Extension*)extension browser:(Browser*)browser icon:(SkBitmap)icon { NSString* nibPath = diff --git a/chrome/browser/cocoa/extensions/browser_action_button.h b/chrome/browser/cocoa/extensions/browser_action_button.h index 606b033..1205c80 100644 --- a/chrome/browser/cocoa/extensions/browser_action_button.h +++ b/chrome/browser/cocoa/extensions/browser_action_button.h @@ -42,7 +42,7 @@ extern NSString* const kBrowserActionButtonDragEndNotification; scoped_nsobject<NSViewAnimation> moveAnimation_; // The extension for this button. Weak. - Extension* extension_; + const Extension* extension_; // The ID of the active tab. int tabId_; @@ -57,7 +57,7 @@ extern NSString* const kBrowserActionButtonDragEndNotification; } - (id)initWithFrame:(NSRect)frame - extension:(Extension*)extension + extension:(const Extension*)extension profile:(Profile*)profile tabId:(int)tabId; @@ -76,7 +76,7 @@ extern NSString* const kBrowserActionButtonDragEndNotification; - (NSImage*)compositedImage; @property(readonly, nonatomic) BOOL isBeingDragged; -@property(readonly, nonatomic) Extension* extension; +@property(readonly, nonatomic) const Extension* extension; @property(readwrite, nonatomic) int tabId; @end diff --git a/chrome/browser/cocoa/extensions/browser_action_button.mm b/chrome/browser/cocoa/extensions/browser_action_button.mm index 70f15ee..0cdaee5 100644 --- a/chrome/browser/cocoa/extensions/browser_action_button.mm +++ b/chrome/browser/cocoa/extensions/browser_action_button.mm @@ -45,7 +45,8 @@ const CGFloat kShadowOffset = 2.0; class ExtensionImageTrackerBridge : public NotificationObserver, public ImageLoadingTracker::Observer { public: - ExtensionImageTrackerBridge(BrowserActionButton* owner, Extension* extension) + ExtensionImageTrackerBridge(BrowserActionButton* owner, + const Extension* extension) : owner_(owner), tracker_(this) { // The Browser Action API does not allow the default icon path to be @@ -113,7 +114,7 @@ class ExtensionImageTrackerBridge : public NotificationObserver, } - (id)initWithFrame:(NSRect)frame - extension:(Extension*)extension + extension:(const Extension*)extension profile:(Profile*)profile tabId:(int)tabId { if ((self = [super initWithFrame:frame])) { diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.h b/chrome/browser/cocoa/extensions/browser_actions_controller.h index 21b0b95..8f039ce 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.h +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.h @@ -88,7 +88,7 @@ extern NSString* const kBrowserActionVisibilityChangedNotification; - (void)resizeContainerAndAnimate:(BOOL)animate; // Returns the NSView for the action button associated with an extension. -- (NSView*)browserActionViewForExtension:(Extension*)extension; +- (NSView*)browserActionViewForExtension:(const Extension*)extension; // Returns the saved width determined by the number of shown Browser Actions // preference property. If no preference is found, then the width for the @@ -98,7 +98,7 @@ extern NSString* const kBrowserActionVisibilityChangedNotification; // Returns where the popup arrow should point to for a given Browser Action. If // it is passed an extension that is not a Browser Action, then it will return // NSZeroPoint. -- (NSPoint)popupPointForBrowserAction:(Extension*)extension; +- (NSPoint)popupPointForBrowserAction:(const Extension*)extension; // Returns whether the chevron button is currently hidden or in the process of // being hidden (fading out). Will return NO if it is not hidden or is in the diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm index e5a58ad..456ceba 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm @@ -70,13 +70,13 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0; // Creates and then adds the given extension's action button to the container // at the given index within the container. It does not affect the toolbar model // object since it is called when the toolbar model changes. -- (void)createActionButtonForExtension:(Extension*)extension +- (void)createActionButtonForExtension:(const Extension*)extension withIndex:(NSUInteger)index; // Removes an action button for the given extension from the container. This // method also does not affect the underlying toolbar model since it is called // when the toolbar model changes. -- (void)removeActionButtonForExtension:(Extension*)extension; +- (void)removeActionButtonForExtension:(const Extension*)extension; // Useful in the case of a Browser Action being added/removed from the middle of // the container, this method repositions each button according to the current @@ -90,7 +90,7 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0; // Returns the existing button with the given extension backing it; nil if it // cannot be found or the extension's ID is invalid. -- (BrowserActionButton*)buttonForExtension:(Extension*)extension; +- (BrowserActionButton*)buttonForExtension:(const Extension*)extension; // Returns the preferred width of the container given the number of visible // buttons |buttonCount|. @@ -141,7 +141,7 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0; // Returns whether the given extension should be displayed. Only displays // incognito-enabled extensions in incognito mode. Otherwise returns YES. -- (BOOL)shouldDisplayBrowserAction:(Extension*)extension; +- (BOOL)shouldDisplayBrowserAction:(const Extension*)extension; // The reason |frame| is specified in these chevron functions is because the // container may be animating and the end frame of the animation should be @@ -203,12 +203,12 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, } // ExtensionToolbarModel::Observer implementation. - void BrowserActionAdded(Extension* extension, int index) { + void BrowserActionAdded(const Extension* extension, int index) { [owner_ createActionButtonForExtension:extension withIndex:index]; [owner_ resizeContainerAndAnimate:NO]; } - void BrowserActionRemoved(Extension* extension) { + void BrowserActionRemoved(const Extension* extension) { [owner_ removeActionButtonForExtension:extension]; [owner_ resizeContainerAndAnimate:NO]; } @@ -342,7 +342,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, } } -- (NSView*)browserActionViewForExtension:(Extension*)extension { +- (NSView*)browserActionViewForExtension:(const Extension*)extension { for (BrowserActionButton* button in [buttons_ allValues]) { if ([button extension] == extension) return button; @@ -374,7 +374,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, return [self containerWidthWithButtonCount:savedButtonCount]; } -- (NSPoint)popupPointForBrowserAction:(Extension*)extension { +- (NSPoint)popupPointForBrowserAction:(const Extension*)extension { if (!extension->browser_action()) return NSZeroPoint; @@ -446,7 +446,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, [containerView_ resizeToWidth:width animate:NO]; } -- (void)createActionButtonForExtension:(Extension*)extension +- (void)createActionButtonForExtension:(const Extension*)extension withIndex:(NSUInteger)index { if (!extension->browser_action()) return; @@ -491,7 +491,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, [containerView_ setNeedsDisplay:YES]; } -- (void)removeActionButtonForExtension:(Extension*)extension { +- (void)removeActionButtonForExtension:(const Extension*)extension { if (!extension->browser_action()) return; @@ -555,7 +555,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, } } -- (BrowserActionButton*)buttonForExtension:(Extension*)extension { +- (BrowserActionButton*)buttonForExtension:(const Extension*)extension { NSString* extensionId = base::SysUTF8ToNSString(extension->id()); DCHECK(extensionId); if (!extensionId) @@ -744,7 +744,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, } } -- (BOOL)shouldDisplayBrowserAction:(Extension*)extension { +- (BOOL)shouldDisplayBrowserAction:(const Extension*)extension { // Only display incognito-enabled extensions while in incognito mode. return (!profile_->IsOffTheRecord() || profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); @@ -854,7 +854,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, if (profile_->IsOffTheRecord()) index = toolbarModel_->IncognitoIndexToOriginal(index); if (index < toolbarModel_->size()) { - Extension* extension = toolbarModel_->GetExtensionByIndex(index); + const Extension* extension = toolbarModel_->GetExtensionByIndex(index); return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; } return nil; diff --git a/chrome/browser/cocoa/extensions/extension_action_context_menu.h b/chrome/browser/cocoa/extensions/extension_action_context_menu.h index 3c9e216..80e8398 100644 --- a/chrome/browser/cocoa/extensions/extension_action_context_menu.h +++ b/chrome/browser/cocoa/extensions/extension_action_context_menu.h @@ -28,7 +28,7 @@ class DevmodeObserver; @interface ExtensionActionContextMenu : NSMenu { @private // The extension that this menu belongs to. Weak. - Extension* extension_; + const Extension* extension_; // The extension action this menu belongs to. Weak. ExtensionAction* action_; @@ -48,7 +48,7 @@ class DevmodeObserver; } // Initializes and returns a context menu for the given extension and profile. -- (id)initWithExtension:(Extension*)extension +- (id)initWithExtension:(const Extension*)extension profile:(Profile*)profile extensionAction:(ExtensionAction*)action; diff --git a/chrome/browser/cocoa/extensions/extension_action_context_menu.mm b/chrome/browser/cocoa/extensions/extension_action_context_menu.mm index 81aa61e..36ff520 100644 --- a/chrome/browser/cocoa/extensions/extension_action_context_menu.mm +++ b/chrome/browser/cocoa/extensions/extension_action_context_menu.mm @@ -36,7 +36,7 @@ // Also acts as the extension's UI delegate in order to display the dialog. class AsyncUninstaller : public ExtensionInstallUI::Delegate { public: - AsyncUninstaller(Extension* extension, Profile* profile) + AsyncUninstaller(const Extension* extension, Profile* profile) : extension_(extension), profile_(profile) { install_ui_.reset(new ExtensionInstallUI(profile)); @@ -55,7 +55,7 @@ class AsyncUninstaller : public ExtensionInstallUI::Delegate { private: // The extension that we're loading the icon for. Weak. - Extension* extension_; + const Extension* extension_; // The current profile. Weak. Profile* profile_; @@ -125,7 +125,7 @@ int CurrentTabId() { } // namespace -- (id)initWithExtension:(Extension*)extension +- (id)initWithExtension:(const Extension*)extension profile:(Profile*)profile extensionAction:(ExtensionAction*)action{ if ((self = [super initWithTitle:@""])) { diff --git a/chrome/browser/cocoa/extensions/extension_infobar_controller.mm b/chrome/browser/cocoa/extensions/extension_infobar_controller.mm index 1bb1a5f..a2a38f2 100644 --- a/chrome/browser/cocoa/extensions/extension_infobar_controller.mm +++ b/chrome/browser/cocoa/extensions/extension_infobar_controller.mm @@ -65,7 +65,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, // Load the Extension's icon image. void LoadIcon() { - Extension* extension = delegate_->extension_host()->extension(); + const Extension* extension = delegate_->extension_host()->extension(); ExtensionResource icon_resource = extension->GetIconResource( Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { diff --git a/chrome/browser/cocoa/extensions/extension_install_prompt_controller.h b/chrome/browser/cocoa/extensions/extension_install_prompt_controller.h index 0fb4d4e..8a6a4ce 100644 --- a/chrome/browser/cocoa/extensions/extension_install_prompt_controller.h +++ b/chrome/browser/cocoa/extensions/extension_install_prompt_controller.h @@ -49,7 +49,7 @@ class Profile; - (id)initWithParentWindow:(NSWindow*)window profile:(Profile*)profile - extension:(Extension*)extension + extension:(const Extension*)extension delegate:(ExtensionInstallUI::Delegate*)delegate icon:(SkBitmap*)bitmap warnings:(const std::vector<string16>&)warnings; diff --git a/chrome/browser/cocoa/extensions/extension_install_prompt_controller.mm b/chrome/browser/cocoa/extensions/extension_install_prompt_controller.mm index 9ba758b..10f4f81 100644 --- a/chrome/browser/cocoa/extensions/extension_install_prompt_controller.mm +++ b/chrome/browser/cocoa/extensions/extension_install_prompt_controller.mm @@ -58,7 +58,7 @@ void OffsetControlVertically(NSControl* control, CGFloat amount) { - (id)initWithParentWindow:(NSWindow*)window profile:(Profile*)profile - extension:(Extension*)extension + extension:(const Extension*)extension delegate:(ExtensionInstallUI::Delegate*)delegate icon:(SkBitmap*)icon warnings:(const std::vector<string16>&)warnings { @@ -185,7 +185,10 @@ void OffsetControlVertically(NSControl* control, CGFloat amount) { void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, const std::vector<string16>& warnings) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { diff --git a/chrome/browser/cocoa/location_bar/page_action_decoration.mm b/chrome/browser/cocoa/location_bar/page_action_decoration.mm index 572a65a..79636b2 100644 --- a/chrome/browser/cocoa/location_bar/page_action_decoration.mm +++ b/chrome/browser/cocoa/location_bar/page_action_decoration.mm @@ -39,8 +39,8 @@ PageActionDecoration::PageActionDecoration( current_tab_id_(-1), preview_enabled_(false) { DCHECK(profile); - Extension* extension = profile->GetExtensionsService()->GetExtensionById( - page_action->extension_id(), false); + const Extension* extension = profile->GetExtensionsService()-> + GetExtensionById(page_action->extension_id(), false); DCHECK(extension); // Load all the icons declared in the manifest. This is the contents of the @@ -219,7 +219,7 @@ NSMenu* PageActionDecoration::GetMenu() { ExtensionsService* service = profile_->GetExtensionsService(); if (!service) return nil; - Extension* extension = service->GetExtensionById( + const Extension* extension = service->GetExtensionById( page_action_->extension_id(), false); DCHECK(extension); if (!extension) diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc index f3309c92..9bc27d2 100644 --- a/chrome/browser/dom_ui/app_launcher_handler.cc +++ b/chrome/browser/dom_ui/app_launcher_handler.cc @@ -44,7 +44,7 @@ bool ExtractInt(const ListValue* list, size_t index, int* out_int) { return false; } -std::string GetIconURL(Extension* extension, Extension::Icons icon, +std::string GetIconURL(const Extension* extension, Extension::Icons icon, const std::string& default_val) { GURL url = extension->GetIconURL(icon, ExtensionIconSet::MATCH_EXACTLY); if (!url.is_empty()) @@ -103,7 +103,7 @@ void AppLauncherHandler::Observe(NotificationType type, } // static -void AppLauncherHandler::CreateAppInfo(Extension* extension, +void AppLauncherHandler::CreateAppInfo(const Extension* extension, ExtensionPrefs* extension_prefs, DictionaryValue* value) { value->Clear(); @@ -202,7 +202,7 @@ void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { dom_ui_->tab_contents()->GetContainerBounds(&tab_contents_bounds); rect.Offset(tab_contents_bounds.origin()); - Extension* extension = + const Extension* extension = extensions_service_->GetExtensionById(extension_id, false); DCHECK(extension); Profile* profile = extensions_service_->profile(); @@ -231,7 +231,7 @@ void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { return; } - Extension* extension = + const Extension* extension = extensions_service_->GetExtensionById(extension_id, false); DCHECK(extension); @@ -240,7 +240,7 @@ void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { static_cast<ExtensionPrefs::LaunchType>(launch_type)); } -void AppLauncherHandler::AnimateAppIcon(Extension* extension, +void AppLauncherHandler::AnimateAppIcon(const Extension* extension, const gfx::Rect& rect) { // We make this check for the case of minimized windows, unit tests, etc. if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && @@ -255,7 +255,7 @@ void AppLauncherHandler::AnimateAppIcon(Extension* extension, void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { std::string extension_id = WideToUTF8(ExtractStringValue(args)); - Extension* extension = extensions_service_->GetExtensionById( + const Extension* extension = extensions_service_->GetExtensionById( extension_id, false); if (!extension) return; @@ -295,7 +295,7 @@ void AppLauncherHandler::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; diff --git a/chrome/browser/dom_ui/app_launcher_handler.h b/chrome/browser/dom_ui/app_launcher_handler.h index c3ca622..5a3478e 100644 --- a/chrome/browser/dom_ui/app_launcher_handler.h +++ b/chrome/browser/dom_ui/app_launcher_handler.h @@ -42,7 +42,7 @@ class AppLauncherHandler const NotificationDetails& details); // Populate a dictionary with the information from an extension. - static void CreateAppInfo(Extension* extension, + static void CreateAppInfo(const Extension* extension, ExtensionPrefs* extension_prefs, DictionaryValue* value); @@ -75,7 +75,7 @@ class AppLauncherHandler ExtensionInstallUI* GetExtensionInstallUI(); // Starts the animation of the app icon. - void AnimateAppIcon(Extension* extension, const gfx::Rect& rect); + void AnimateAppIcon(const Extension* extension, const gfx::Rect& rect); // The apps are represented in the extensions model. scoped_refptr<ExtensionsService> extensions_service_; 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); diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc index 7fb9aae..4d7c848 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -362,7 +362,7 @@ void GeolocationPermissionContext::RequestGeolocationPermission( ExtensionsService* extensions = profile_->GetExtensionsService(); if (extensions) { - Extension* ext = extensions->GetExtensionByURL(requesting_frame); + const Extension* ext = extensions->GetExtensionByURL(requesting_frame); if (!ext) ext = extensions->GetExtensionByWebExtent(requesting_frame); if (ext && ext->HasApiPermission(Extension::kGeolocationPermission)) { diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc index 53776cf..4ee92b1 100644 --- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc @@ -83,7 +83,7 @@ class BrowserActionButton : public NotificationObserver, public MenuGtk::Delegate { public: BrowserActionButton(BrowserActionsToolbarGtk* toolbar, - Extension* extension, + const Extension* extension, GtkThemeProvider* theme_provider) : toolbar_(toolbar), extension_(extension), @@ -143,7 +143,7 @@ class BrowserActionButton : public NotificationObserver, GtkWidget* widget() { return alignment_.get(); } - Extension* extension() { return extension_; } + const Extension* extension() { return extension_; } // NotificationObserver implementation. void Observe(NotificationType type, @@ -312,7 +312,7 @@ class BrowserActionButton : public NotificationObserver, BrowserActionsToolbarGtk* toolbar_; // The extension that contains this browser action. - Extension* extension_; + const Extension* extension_; // The button for this browser action. scoped_ptr<CustomDrawButton> button_; @@ -497,8 +497,8 @@ void BrowserActionsToolbarGtk::SetContainerWidth() { SetButtonHBoxWidth(WidthForIconCount(showing_actions)); } -void BrowserActionsToolbarGtk::CreateButtonForExtension(Extension* extension, - int index) { +void BrowserActionsToolbarGtk::CreateButtonForExtension( + const Extension* extension, int index) { if (!ShouldDisplayBrowserAction(extension)) return; @@ -535,7 +535,7 @@ void BrowserActionsToolbarGtk::CreateButtonForExtension(Extension* extension, } GtkWidget* BrowserActionsToolbarGtk::GetBrowserActionWidget( - Extension* extension) { + const Extension* extension) { ExtensionButtonMap::iterator it = extension_button_map_.find( extension->id()); if (it == extension_button_map_.end()) @@ -544,7 +544,8 @@ GtkWidget* BrowserActionsToolbarGtk::GetBrowserActionWidget( return it->second.get()->widget(); } -void BrowserActionsToolbarGtk::RemoveButtonForExtension(Extension* extension) { +void BrowserActionsToolbarGtk::RemoveButtonForExtension( + const Extension* extension) { if (extension_button_map_.erase(extension->id())) UpdateVisibility(); UpdateChevronVisibility(); @@ -558,7 +559,7 @@ void BrowserActionsToolbarGtk::UpdateVisibility() { } bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction( - Extension* extension) { + const Extension* extension) { // Only display incognito-enabled extensions while in incognito mode. return (!profile_->IsOffTheRecord() || profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); @@ -577,7 +578,7 @@ void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) { resize_animation_.Show(); } -void BrowserActionsToolbarGtk::BrowserActionAdded(Extension* extension, +void BrowserActionsToolbarGtk::BrowserActionAdded(const Extension* extension, int index) { overflow_menu_.reset(); @@ -594,7 +595,8 @@ void BrowserActionsToolbarGtk::BrowserActionAdded(Extension* extension, } } -void BrowserActionsToolbarGtk::BrowserActionRemoved(Extension* extension) { +void BrowserActionsToolbarGtk::BrowserActionRemoved( + const Extension* extension) { overflow_menu_.reset(); if (drag_button_ != NULL) { @@ -610,7 +612,7 @@ void BrowserActionsToolbarGtk::BrowserActionRemoved(Extension* extension) { } } -void BrowserActionsToolbarGtk::BrowserActionMoved(Extension* extension, +void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension, int index) { // We initiated this move action, and have already moved the button. if (drag_button_ != NULL) @@ -648,7 +650,7 @@ void BrowserActionsToolbarGtk::AnimationEnded(const Animation* animation) { } void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) { - Extension* extension = model_->GetExtensionByIndex(command_id); + const Extension* extension = model_->GetExtensionByIndex(command_id); ExtensionAction* browser_action = extension->browser_action(); int tab_id = GetCurrentTabId(); @@ -870,7 +872,7 @@ gboolean BrowserActionsToolbarGtk::OnOverflowButtonPress( if (profile_->IsOffTheRecord()) model_index = model_->IncognitoIndexToOriginal(i); - Extension* extension = model_->GetExtensionByIndex(model_index); + const Extension* extension = model_->GetExtensionByIndex(model_index); BrowserActionButton* button = extension_button_map_[extension->id()].get(); overflow_menu_model_->AddItem(model_index, UTF8ToUTF16(extension->name())); @@ -910,7 +912,7 @@ gboolean BrowserActionsToolbarGtk::OnOverflowMenuButtonPress( if (profile_->IsOffTheRecord()) item_index = model_->IncognitoIndexToOriginal(item_index); - Extension* extension = model_->GetExtensionByIndex(item_index); + const Extension* extension = model_->GetExtensionByIndex(item_index); ExtensionButtonMap::iterator it = extension_button_map_.find( extension->id()); if (it == extension_button_map_.end()) { diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.h b/chrome/browser/gtk/browser_actions_toolbar_gtk.h index 455efee..72cf960 100644 --- a/chrome/browser/gtk/browser_actions_toolbar_gtk.h +++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.h @@ -47,7 +47,7 @@ class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer, // Returns the widget in use by the BrowserActionButton corresponding to // |extension|. Used in positioning the ExtensionInstalledBubble for // BrowserActions. - GtkWidget* GetBrowserActionWidget(Extension* extension); + GtkWidget* GetBrowserActionWidget(const Extension* extension); int button_count() { return extension_button_map_.size(); } @@ -83,10 +83,10 @@ class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer, // Create the UI for a single browser action. This will stick the button // at the end of the toolbar. - void CreateButtonForExtension(Extension* extension, int index); + void CreateButtonForExtension(const Extension* extension, int index); // Delete resources associated with UI for a browser action. - void RemoveButtonForExtension(Extension* extension); + void RemoveButtonForExtension(const Extension* extension); // Change the visibility of widget() based on whether we have any buttons // to show. @@ -102,12 +102,12 @@ class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer, // Returns true if this extension should be shown in this toolbar. This can // return false if we are in an incognito window and the extension is disabled // for incognito. - bool ShouldDisplayBrowserAction(Extension* extension); + bool ShouldDisplayBrowserAction(const Extension* extension); // ExtensionToolbarModel::Observer implementation. - virtual void BrowserActionAdded(Extension* extension, int index); - virtual void BrowserActionRemoved(Extension* extension); - virtual void BrowserActionMoved(Extension* extension, int index); + virtual void BrowserActionAdded(const Extension* extension, int index); + virtual void BrowserActionRemoved(const Extension* extension); + virtual void BrowserActionMoved(const Extension* extension, int index); virtual void ModelLoaded(); // AnimationDelegate implementation. diff --git a/chrome/browser/gtk/extension_infobar_gtk.cc b/chrome/browser/gtk/extension_infobar_gtk.cc index b7355b1..35d86c0 100644 --- a/chrome/browser/gtk/extension_infobar_gtk.cc +++ b/chrome/browser/gtk/extension_infobar_gtk.cc @@ -47,7 +47,7 @@ void ExtensionInfoBarGtk::OnImageLoaded( void ExtensionInfoBarGtk::BuildWidgets() { // Start loading the image for the menu button. - Extension* extension = delegate_->extension_host()->extension(); + const Extension* extension = delegate_->extension_host()->extension(); ExtensionResource icon_resource = extension->GetIconResource( Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { diff --git a/chrome/browser/gtk/extension_install_prompt2_gtk.cc b/chrome/browser/gtk/extension_install_prompt2_gtk.cc index 9c66c20..cf78028 100644 --- a/chrome/browser/gtk/extension_install_prompt2_gtk.cc +++ b/chrome/browser/gtk/extension_install_prompt2_gtk.cc @@ -53,7 +53,7 @@ void OnDialogResponse(GtkDialog* dialog, int response_id, } void ShowInstallPromptDialog2(GtkWindow* parent, SkBitmap* skia_icon, - Extension* extension, + const Extension* extension, ExtensionInstallUI::Delegate *delegate, const std::vector<string16>& permissions) { // Build the dialog. @@ -172,7 +172,10 @@ void ShowInstallPromptDialog2(GtkWindow* parent, SkBitmap* skia_icon, } // namespace void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, const std::vector<string16>& permissions) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { diff --git a/chrome/browser/gtk/extension_install_prompt_gtk.cc b/chrome/browser/gtk/extension_install_prompt_gtk.cc index bcb7c0a..a1166d0 100644 --- a/chrome/browser/gtk/extension_install_prompt_gtk.cc +++ b/chrome/browser/gtk/extension_install_prompt_gtk.cc @@ -38,7 +38,7 @@ void OnDialogResponse(GtkDialog* dialog, int response_id, } void ShowInstallPromptDialog(GtkWindow* parent, SkBitmap* skia_icon, - Extension *extension, + const Extension* extension, ExtensionInstallUI::Delegate *delegate, ExtensionInstallUI::PromptType type) { // Build the dialog. @@ -87,7 +87,10 @@ void ShowInstallPromptDialog(GtkWindow* parent, SkBitmap* skia_icon, } // namespace void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, ExtensionInstallUI::PromptType type) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.cc b/chrome/browser/gtk/extension_installed_bubble_gtk.cc index 0e54c14..af9c915 100644 --- a/chrome/browser/gtk/extension_installed_bubble_gtk.cc +++ b/chrome/browser/gtk/extension_installed_bubble_gtk.cc @@ -43,14 +43,14 @@ const int kContentBorder = 7; } // namespace -void ExtensionInstalledBubbleGtk::Show(Extension* extension, Browser* browser, +void ExtensionInstalledBubbleGtk::Show(const Extension* extension, + Browser* browser, SkBitmap icon) { new ExtensionInstalledBubbleGtk(extension, browser, icon); } -ExtensionInstalledBubbleGtk::ExtensionInstalledBubbleGtk(Extension *extension, - Browser *browser, - SkBitmap icon) +ExtensionInstalledBubbleGtk::ExtensionInstalledBubbleGtk( + const Extension* extension, Browser *browser, SkBitmap icon) : extension_(extension), browser_(browser), icon_(icon), @@ -83,7 +83,7 @@ void ExtensionInstalledBubbleGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::EXTENSION_LOADED) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == extension_) { // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.h b/chrome/browser/gtk/extension_installed_bubble_gtk.h index 9b8483c..08d6fec 100644 --- a/chrome/browser/gtk/extension_installed_bubble_gtk.h +++ b/chrome/browser/gtk/extension_installed_bubble_gtk.h @@ -45,13 +45,13 @@ class ExtensionInstalledBubbleGtk // the extension has loaded. |extension| is the installed extension. |browser| // is the browser window which will host the bubble. |icon| is the install // icon of the extension. - static void Show(Extension *extension, Browser *browser, SkBitmap icon); + static void Show(const Extension* extension, Browser *browser, SkBitmap icon); private: friend class base::RefCountedThreadSafe<ExtensionInstalledBubbleGtk>; // Private ctor. Registers a listener for EXTENSION_LOADED. - ExtensionInstalledBubbleGtk(Extension *extension, Browser *browser, + ExtensionInstalledBubbleGtk(const Extension* extension, Browser *browser, SkBitmap icon); virtual ~ExtensionInstalledBubbleGtk(); @@ -74,7 +74,7 @@ class ExtensionInstalledBubbleGtk static void OnButtonClick(GtkWidget* button, ExtensionInstalledBubbleGtk* toolbar); - Extension *extension_; + const Extension* extension_; Browser *browser_; SkBitmap icon_; NotificationRegistrar registrar_; diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index f33ccc2..6d04b57 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -319,7 +319,7 @@ void GtkThemeProvider::InitThemesFor(NotificationObserver* observer) { NotificationService::NoDetails()); } -void GtkThemeProvider::SetTheme(Extension* extension) { +void GtkThemeProvider::SetTheme(const Extension* extension) { profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); LoadDefaultValues(); BrowserThemeProvider::SetTheme(extension); @@ -580,7 +580,7 @@ void GtkThemeProvider::LoadThemePrefs() { RebuildMenuIconSets(); } -void GtkThemeProvider::NotifyThemeChanged(Extension* extension) { +void GtkThemeProvider::NotifyThemeChanged(const Extension* extension) { BrowserThemeProvider::NotifyThemeChanged(extension); // Notify all GtkChromeButtons of their new rendering mode: diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index 9a4d59c..f31d974 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -51,7 +51,7 @@ class GtkThemeProvider : public BrowserThemeProvider, virtual SkBitmap* GetBitmapNamed(int id) const; virtual SkColor GetColor(int id) const; virtual bool HasCustomImage(int id) const; - virtual void SetTheme(Extension* extension); + virtual void SetTheme(const Extension* extension); virtual void UseDefaultTheme(); virtual void SetNativeTheme(); virtual bool UsingDefaultTheme(); @@ -153,7 +153,7 @@ class GtkThemeProvider : public BrowserThemeProvider, virtual void LoadThemePrefs(); // Let all the browser views know that themes have changed. - virtual void NotifyThemeChanged(Extension* extension); + virtual void NotifyThemeChanged(const Extension* extension); // Additionally frees the CairoCachedSurfaces. virtual void FreePlatformCaches(); diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index c16b38c..1b5d398 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -1330,8 +1330,8 @@ LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( image_.Own(gtk_image_new()); gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); - Extension* extension = profile->GetExtensionsService()->GetExtensionById( - page_action->extension_id(), false); + const Extension* extension = profile->GetExtensionsService()-> + GetExtensionById(page_action->extension_id(), false); DCHECK(extension); // Load all the icons declared in the manifest. This is the contents of the @@ -1494,8 +1494,8 @@ gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( event->button.button); } } else { - Extension* extension = profile_->GetExtensionsService()->GetExtensionById( - page_action()->extension_id(), false); + const Extension* extension = profile_->GetExtensionsService()-> + GetExtensionById(page_action()->extension_id(), false); context_menu_model_ = new ExtensionContextMenuModel(extension, owner_->browser_, this); diff --git a/chrome/browser/message_box_handler.cc b/chrome/browser/message_box_handler.cc index c39d1b7..4150945 100644 --- a/chrome/browser/message_box_handler.cc +++ b/chrome/browser/message_box_handler.cc @@ -28,7 +28,8 @@ static std::wstring GetTitle(Profile* profile, const GURL& frame_url) { ExtensionsService* extensions_service = profile->GetExtensionsService(); if (extensions_service) { - Extension* extension = extensions_service->GetExtensionByURL(frame_url); + const Extension* extension = + extensions_service->GetExtensionByURL(frame_url); if (!extension) extension = extensions_service->GetExtensionByWebExtent(frame_url); diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index a4c45d5..e7530e4 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -600,7 +600,7 @@ string16 DesktopNotificationService::DisplayNameForOrigin( if (origin.SchemeIs(chrome::kExtensionScheme)) { ExtensionsService* ext_service = profile_->GetExtensionsService(); if (ext_service) { - Extension* extension = ext_service->GetExtensionByURL(origin); + const Extension* extension = ext_service->GetExtensionByURL(origin); if (extension) return UTF8ToUTF16(extension->name()); } diff --git a/chrome/browser/notifications/notification_options_menu_model.cc b/chrome/browser/notifications/notification_options_menu_model.cc index 60b41869..97d269c 100644 --- a/chrome/browser/notifications/notification_options_menu_model.cc +++ b/chrome/browser/notifications/notification_options_menu_model.cc @@ -68,7 +68,7 @@ string16 NotificationOptionsMenuModel::GetLabelForCommandId(int command_id) if (origin.SchemeIs(chrome::kExtensionScheme)) { ExtensionsService* ext_service = balloon_->profile()->GetExtensionsService(); - Extension* extension = ext_service->GetExtensionByURL(origin); + const Extension* extension = ext_service->GetExtensionByURL(origin); if (extension) { ExtensionPrefs* extension_prefs = ext_service->extension_prefs(); const std::string& id = extension->id(); @@ -126,7 +126,7 @@ void NotificationOptionsMenuModel::ExecuteCommand(int command_id) { service->GrantPermission(origin); break; case kToggleExtensionCommand: { - Extension* extension = ext_service->GetExtensionByURL(origin); + const Extension* extension = ext_service->GetExtensionByURL(origin); if (extension) { ExtensionPrefs* extension_prefs = ext_service->extension_prefs(); const std::string& id = extension->id(); diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index a3d636b..b8c54f3 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -364,7 +364,7 @@ void PluginService::Observe(NotificationType type, const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSION_LOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); bool plugins_changed = false; for (size_t i = 0; i < extension->plugins().size(); ++i) { const Extension::PluginInfo& plugin = extension->plugins()[i]; @@ -380,7 +380,7 @@ void PluginService::Observe(NotificationType type, } case NotificationType::EXTENSION_UNLOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); bool plugins_changed = false; for (size_t i = 0; i < extension->plugins().size(); ++i) { const Extension::PluginInfo& plugin = extension->plugins()[i]; diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 6c3a928..bd0c5c8 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -335,7 +335,7 @@ class OffTheRecordProfileImpl : public Profile, profile_->InitThemes(); } - virtual void SetTheme(Extension* extension) { + virtual void SetTheme(const Extension* extension) { profile_->SetTheme(extension); } @@ -347,7 +347,7 @@ class OffTheRecordProfileImpl : public Profile, profile_->ClearTheme(); } - virtual Extension* GetTheme() { + virtual const Extension* GetTheme() { return profile_->GetTheme(); } diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index 31b3fc8..fac699d 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -297,7 +297,7 @@ class Profile { virtual void InitThemes() = 0; // Set the theme to the specified extension. - virtual void SetTheme(Extension* extension) = 0; + virtual void SetTheme(const Extension* extension) = 0; // Set the theme to the machine's native theme. virtual void SetNativeTheme() = 0; @@ -307,7 +307,7 @@ class Profile { // Gets the theme that was last set. Returns NULL if the theme is no longer // installed, if there is no installed theme, or the theme was cleared. - virtual Extension* GetTheme() = 0; + virtual const Extension* GetTheme() = 0; // Returns or creates the ThemeProvider associated with this profile virtual BrowserThemeProvider* GetThemeProvider() = 0; @@ -330,12 +330,14 @@ class Profile { // notification has fired. The purpose for handling this event first is to // avoid race conditions by making sure URLRequestContexts learn about new // extensions before anything else needs them to know. - virtual void RegisterExtensionWithRequestContexts(Extension* extension) {} + virtual void RegisterExtensionWithRequestContexts( + const Extension* extension) {} // Called by the ExtensionsService that lives in this profile. Lets the // profile clean up its RequestContexts once all the listeners to the // EXTENSION_UNLOADED notification have finished running. - virtual void UnregisterExtensionWithRequestContexts(Extension* extension) {} + virtual void UnregisterExtensionWithRequestContexts( + const Extension* extension) {} // Returns the SSLConfigService for this profile. virtual net::SSLConfigService* GetSSLConfigService() = 0; diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index cce4096..c60c33b 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -774,7 +774,8 @@ URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { return extensions_request_context_; } -void ProfileImpl::RegisterExtensionWithRequestContexts(Extension* extension) { +void ProfileImpl::RegisterExtensionWithRequestContexts( + const Extension* extension) { // AddRef to ensure the data lives until the other thread gets it. Balanced in // OnNewExtensions. extension->static_data()->AddRef(); @@ -785,7 +786,8 @@ void ProfileImpl::RegisterExtensionWithRequestContexts(Extension* extension) { extension->static_data())); } -void ProfileImpl::UnregisterExtensionWithRequestContexts(Extension* extension) { +void ProfileImpl::UnregisterExtensionWithRequestContexts( + const Extension* extension) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableMethod(extension_info_map_.get(), @@ -1033,7 +1035,7 @@ void ProfileImpl::InitThemes() { } } -void ProfileImpl::SetTheme(Extension* extension) { +void ProfileImpl::SetTheme(const Extension* extension) { InitThemes(); theme_provider_.get()->SetTheme(extension); } @@ -1048,7 +1050,7 @@ void ProfileImpl::ClearTheme() { theme_provider_.get()->UseDefaultTheme(); } -Extension* ProfileImpl::GetTheme() { +const Extension* ProfileImpl::GetTheme() { InitThemes(); std::string id = theme_provider_.get()->GetThemeID(); @@ -1220,7 +1222,7 @@ void ProfileImpl::Observe(NotificationType type, Source<Profile>(this), NotificationService::NoDetails()); } } else if (NotificationType::THEME_INSTALLED == type) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); SetTheme(extension); } else if (NotificationType::BOOKMARK_MODEL_LOADED == type) { GetProfileSyncService(); // Causes lazy-load if sync is enabled. diff --git a/chrome/browser/profile_impl.h b/chrome/browser/profile_impl.h index ac3f631..6bad987 100644 --- a/chrome/browser/profile_impl.h +++ b/chrome/browser/profile_impl.h @@ -72,17 +72,18 @@ class ProfileImpl : public Profile, virtual PersonalDataManager* GetPersonalDataManager(); virtual FileSystemHostContext* GetFileSystemHostContext(); virtual void InitThemes(); - virtual void SetTheme(Extension* extension); + virtual void SetTheme(const Extension* extension); virtual void SetNativeTheme(); virtual void ClearTheme(); - virtual Extension* GetTheme(); + virtual const Extension* GetTheme(); virtual BrowserThemeProvider* GetThemeProvider(); virtual bool HasCreatedDownloadManager() const; virtual URLRequestContextGetter* GetRequestContext(); virtual URLRequestContextGetter* GetRequestContextForMedia(); virtual URLRequestContextGetter* GetRequestContextForExtensions(); - virtual void RegisterExtensionWithRequestContexts(Extension* extension); - virtual void UnregisterExtensionWithRequestContexts(Extension* extension); + virtual void RegisterExtensionWithRequestContexts(const Extension* extension); + virtual void UnregisterExtensionWithRequestContexts( + const Extension* extension); virtual net::SSLConfigService* GetSSLConfigService(); virtual HostContentSettingsMap* GetHostContentSettingsMap(); virtual HostZoomMap* GetHostZoomMap(); diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 9a4b0b7..e72c7b1 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -711,7 +711,7 @@ void BrowserRenderProcessHost::SendExtensionInfo() { return; ViewMsg_ExtensionsUpdated_Params params; for (size_t i = 0; i < service->extensions()->size(); ++i) { - Extension* extension = service->extensions()->at(i); + const Extension* extension = service->extensions()->at(i); ViewMsg_ExtensionRendererInfo info; info.id = extension->id(); info.web_extent = extension->web_extent(); diff --git a/chrome/browser/renderer_host/site_instance.cc b/chrome/browser/renderer_host/site_instance.cc index b0f4386..c6a660d 100644 --- a/chrome/browser/renderer_host/site_instance.cc +++ b/chrome/browser/renderer_host/site_instance.cc @@ -190,7 +190,7 @@ GURL SiteInstance::GetEffectiveURL(Profile* profile, const GURL& url) { if (!profile || !profile->GetExtensionsService()) return url; - Extension* extension = + const Extension* extension = profile->GetExtensionsService()->GetExtensionByWebExtent(url); if (extension) { // If the URL is part of an extension's web extent, convert it to an diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc index e7bcb92..5b5b02e 100644 --- a/chrome/browser/search_engines/template_url_model.cc +++ b/chrome/browser/search_engines/template_url_model.cc @@ -308,7 +308,7 @@ void TemplateURLModel::RemoveAutoGeneratedSince(Time created_after) { RemoveAutoGeneratedBetween(created_after, Time()); } -void TemplateURLModel::RegisterExtensionKeyword(Extension* extension) { +void TemplateURLModel::RegisterExtensionKeyword(const Extension* extension) { // TODO(mpcomplete): disable the keyword when the extension is disabled. if (extension->omnibox_keyword().empty()) return; @@ -342,14 +342,14 @@ void TemplateURLModel::RegisterExtensionKeyword(Extension* extension) { NotifyObservers(); } -void TemplateURLModel::UnregisterExtensionKeyword(Extension* extension) { +void TemplateURLModel::UnregisterExtensionKeyword(const Extension* extension) { const TemplateURL* url = GetTemplateURLForExtension(extension); if (url) Remove(url); } const TemplateURL* TemplateURLModel::GetTemplateURLForExtension( - Extension* extension) const { + const Extension* extension) const { for (TemplateURLVector::const_iterator i = template_urls_.begin(); i != template_urls_.end(); ++i) { if ((*i)->IsExtensionKeyword() && (*i)->url()->GetHost() == extension->id()) @@ -741,7 +741,7 @@ void TemplateURLModel::NotifyLoaded() { NotificationService::NoDetails()); for (size_t i = 0; i < pending_extension_ids_.size(); ++i) { - Extension* extension = profile_->GetExtensionsService()-> + const Extension* extension = profile_->GetExtensionsService()-> GetExtensionById(pending_extension_ids_[i], true); if (extension) RegisterExtensionKeyword(extension); diff --git a/chrome/browser/search_engines/template_url_model.h b/chrome/browser/search_engines/template_url_model.h index ce9a874..a16bad7 100644 --- a/chrome/browser/search_engines/template_url_model.h +++ b/chrome/browser/search_engines/template_url_model.h @@ -144,16 +144,17 @@ class TemplateURLModel : public WebDataServiceConsumer, // If the given extension has an omnibox keyword, adds a TemplateURL for that // keyword. Only 1 keyword is allowed for a given extension. If the keyword // already exists for this extension, does nothing. - void RegisterExtensionKeyword(Extension* extension); + void RegisterExtensionKeyword(const Extension* extension); // Removes the TemplateURL containing the keyword for the given extension, // if any. - void UnregisterExtensionKeyword(Extension* extension); + void UnregisterExtensionKeyword(const Extension* extension); // Returns the TemplateURL associated with the keyword for this extension. // This works by checking the extension ID, not the keyword, so it will work // even if the user changed the keyword. - const TemplateURL* GetTemplateURLForExtension(Extension* extension) const; + const TemplateURL* GetTemplateURLForExtension( + const Extension* extension) const; // Returns the set of URLs describing the keywords. The elements are owned // by TemplateURLModel and should not be deleted. diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index 3d78771..c295d767 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -476,7 +476,7 @@ void TabRestoreService::PopulateTab(Tab* tab, if (tab->current_navigation_index == -1 && entry_count > 0) tab->current_navigation_index = 0; - Extension* extension = controller->tab_contents()->extension_app(); + const Extension* extension = controller->tab_contents()->extension_app(); if (extension) tab->extension_app_id = extension->id(); diff --git a/chrome/browser/sync/glue/extension_change_processor.cc b/chrome/browser/sync/glue/extension_change_processor.cc index 0cc64a9..fcbbd01 100644 --- a/chrome/browser/sync/glue/extension_change_processor.cc +++ b/chrome/browser/sync/glue/extension_change_processor.cc @@ -71,7 +71,7 @@ void ExtensionChangeProcessor::Observe(NotificationType type, RemoveServerData(traits_, id, profile_->GetProfileSyncService()); } } else { - const Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); CHECK(extension); VLOG(1) << "Updating server data for extension " << extension->id() << " (notification type = " << type.value << ")"; diff --git a/chrome/browser/sync/glue/extension_sync.cc b/chrome/browser/sync/glue/extension_sync.cc index 51ccfd4..facf5f1 100644 --- a/chrome/browser/sync/glue/extension_sync.cc +++ b/chrome/browser/sync/glue/extension_sync.cc @@ -268,7 +268,7 @@ void TryUpdateClient( extension_data->merged_data(); DcheckIsExtensionSpecificsValid(specifics); const std::string& id = specifics.id(); - Extension* extension = extensions_service->GetExtensionById(id, true); + const Extension* extension = extensions_service->GetExtensionById(id, true); if (extension) { if (!IsExtensionValidAndSyncable(*extension, allowed_extension_types)) { LOG(DFATAL) << "TryUpdateClient() called for non-syncable extension " @@ -446,7 +446,7 @@ void UpdateClient(const ExtensionSyncTraits& traits, DcheckIsExtensionSpecificsValid(server_data); ExtensionData extension_data = ExtensionData::FromData(ExtensionData::SERVER, server_data); - Extension* extension = + const Extension* extension = extensions_service->GetExtensionById(server_data.id(), true); if (extension) { if (!IsExtensionValidAndSyncable( @@ -478,7 +478,7 @@ void UpdateClient(const ExtensionSyncTraits& traits, void RemoveFromClient(const ExtensionSyncTraits& traits, const std::string& id, ExtensionsService* extensions_service) { - Extension* extension = extensions_service->GetExtensionById(id, true); + const Extension* extension = extensions_service->GetExtensionById(id, true); if (extension) { if (IsExtensionValidAndSyncable(*extension, traits.allowed_extension_types)) { diff --git a/chrome/browser/sync/glue/extension_util.cc b/chrome/browser/sync/glue/extension_util.cc index a5d74d0..a0aa08e 100644 --- a/chrome/browser/sync/glue/extension_util.cc +++ b/chrome/browser/sync/glue/extension_util.cc @@ -232,7 +232,7 @@ bool IsExtensionOutdated(const Extension& extension, void SetExtensionProperties( const sync_pb::ExtensionSpecifics& specifics, - ExtensionsService* extensions_service, Extension* extension) { + ExtensionsService* extensions_service, const Extension* extension) { DcheckIsExtensionSpecificsValid(specifics); CHECK(extensions_service); CHECK(extension); diff --git a/chrome/browser/sync/glue/extension_util.h b/chrome/browser/sync/glue/extension_util.h index ca85e31..a46d1fb 100644 --- a/chrome/browser/sync/glue/extension_util.h +++ b/chrome/browser/sync/glue/extension_util.h @@ -132,7 +132,7 @@ bool IsExtensionOutdated(const Extension& extension, // valid. void SetExtensionProperties( const sync_pb::ExtensionSpecifics& specifics, - ExtensionsService* extensions_service, Extension* extension); + ExtensionsService* extensions_service, const Extension* extension); // Merge |specifics| into |merged_specifics|. Both must be valid and // have the same ID. The merge policy is currently to copy the diff --git a/chrome/browser/sync/glue/theme_change_processor.cc b/chrome/browser/sync/glue/theme_change_processor.cc index e22484c..55f9879 100644 --- a/chrome/browser/sync/glue/theme_change_processor.cc +++ b/chrome/browser/sync/glue/theme_change_processor.cc @@ -17,7 +17,7 @@ namespace browser_sync { namespace { -std::string GetThemeId(Extension* current_theme) { +std::string GetThemeId(const Extension* current_theme) { if (current_theme) { DCHECK(current_theme->is_theme()); } @@ -39,10 +39,10 @@ void ThemeChangeProcessor::Observe(NotificationType type, const NotificationDetails& details) { DCHECK(running()); DCHECK(profile_); - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); std::string current_or_future_theme_id = profile_->GetThemeProvider()->GetThemeID(); - Extension* current_theme = profile_->GetTheme(); + const Extension* current_theme = profile_->GetTheme(); switch (type.value) { case NotificationType::BROWSER_THEME_CHANGED: // We pay attention to this notification only when it signifies diff --git a/chrome/browser/sync/glue/theme_util.cc b/chrome/browser/sync/glue/theme_util.cc index f8b72d1..0f2a16b 100644 --- a/chrome/browser/sync/glue/theme_util.cc +++ b/chrome/browser/sync/glue/theme_util.cc @@ -87,7 +87,7 @@ void SetCurrentThemeFromThemeSpecifics( VLOG(1) << "Applying theme " << id << " with update_url " << update_url; ExtensionsService* extensions_service = profile->GetExtensionsService(); CHECK(extensions_service); - Extension* extension = extensions_service->GetExtensionById(id, true); + const Extension* extension = extensions_service->GetExtensionById(id, true); if (extension) { if (!extension->is_theme()) { VLOG(1) << "Extension " << id << " is not a theme; aborting"; diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 2d85f69..afd5ccb 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -180,7 +180,7 @@ void RenderViewContextMenu::AppendExtensionItems( const std::string& extension_id, int* index) { ExtensionsService* service = profile_->GetExtensionsService(); ExtensionMenuManager* manager = service->menu_manager(); - Extension* extension = service->GetExtensionById(extension_id, false); + const Extension* extension = service->GetExtensionById(extension_id, false); DCHECK_GE(*index, 0); int max_index = IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST - IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST; @@ -318,7 +318,7 @@ void RenderViewContextMenu::AppendAllExtensionItems() { std::set<std::string> ids = menu_manager->ExtensionIds(); std::vector<std::pair<std::string, std::string> > sorted_ids; for (std::set<std::string>::iterator i = ids.begin(); i != ids.end(); ++i) { - Extension* extension = service->GetExtensionById(*i, false); + const Extension* extension = service->GetExtensionById(*i, false); if (extension) sorted_ids.push_back( std::pair<std::string, std::string>(extension->name(), *i)); diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index b94ab7d..68ca49b 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -45,7 +45,8 @@ RenderViewHostDelegateViewHelper::MaybeCreateBackgroundContents( !extensions_service->is_ready()) return NULL; - Extension* extension = extensions_service->GetExtensionByURL(opener_url); + const Extension* extension = + extensions_service->GetExtensionByURL(opener_url); if (!extension) extension = extensions_service->GetExtensionByWebExtent(opener_url); if (!extension || diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 4e5e9b5..288b5b6 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -587,7 +587,7 @@ RenderProcessHost* TabContents::GetRenderProcessHost() const { return render_manager_.current_host()->process(); } -void TabContents::SetExtensionApp(Extension* extension) { +void TabContents::SetExtensionApp(const Extension* extension) { DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); extension_app_ = extension; @@ -605,7 +605,7 @@ void TabContents::SetExtensionAppById(const std::string& extension_app_id) { ExtensionsService* extension_service = profile()->GetExtensionsService(); if (extension_service && extension_service->is_ready()) { - Extension* extension = + const Extension* extension = extension_service->GetExtensionById(extension_app_id, false); if (extension) SetExtensionApp(extension); @@ -3157,7 +3157,7 @@ void TabContents::Observe(NotificationType type, } } -void TabContents::UpdateExtensionAppIcon(Extension* extension) { +void TabContents::UpdateExtensionAppIcon(const Extension* extension) { extension_app_icon_.reset(); if (extension) { @@ -3174,12 +3174,12 @@ void TabContents::UpdateExtensionAppIcon(Extension* extension) { } } -Extension* TabContents::GetExtensionContaining(const GURL& url) { +const Extension* TabContents::GetExtensionContaining(const GURL& url) { ExtensionsService* extensions_service = profile()->GetExtensionsService(); if (!extensions_service) return NULL; - Extension* extension = extensions_service->GetExtensionByURL(url); + const Extension* extension = extensions_service->GetExtensionByURL(url); return extension ? extension : extensions_service->GetExtensionByWebExtent(url); } diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index e6a834c..bfe9c55 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -208,14 +208,14 @@ class TabContents : public PageNavigator, // NOTE: this should only be manipulated before the tab is added to a browser. // TODO(sky): resolve if this is the right way to identify an app tab. If it // is, than this should be passed in the constructor. - void SetExtensionApp(Extension* extension); + void SetExtensionApp(const Extension* extension); // Convenience for setting the app extension by id. This does nothing if // |extension_app_id| is empty, or an extension can't be found given the // specified id. void SetExtensionAppById(const std::string& extension_app_id); - Extension* extension_app() const { return extension_app_; } + const Extension* extension_app() const { return extension_app_; } bool is_app() const { return extension_app_ != NULL; } // If an app extension has been explicitly set for this TabContents its icon @@ -1050,11 +1050,11 @@ class TabContents : public PageNavigator, // App extensions related methods: // Returns the first extension whose extent contains |url|. - Extension* GetExtensionContaining(const GURL& url); + const Extension* GetExtensionContaining(const GURL& url); // Resets app_icon_ and if |extension| is non-null creates a new // ImageLoadingTracker to load the extension's image. - void UpdateExtensionAppIcon(Extension* extension); + void UpdateExtensionAppIcon(const Extension* extension); // ImageLoadingTracker::Observer. virtual void OnImageLoaded(SkBitmap* image, ExtensionResource resource, @@ -1233,7 +1233,7 @@ class TabContents : public PageNavigator, // If non-null this tab is an app tab and this is the extension the tab was // created for. - Extension* extension_app_; + const Extension* extension_app_; // Icon for extension_app_ (if non-null) or extension_for_current_page_. SkBitmap extension_app_icon_; diff --git a/chrome/browser/tabs/pinned_tab_codec.cc b/chrome/browser/tabs/pinned_tab_codec.cc index 7b9e0b3..f6d2a08 100644 --- a/chrome/browser/tabs/pinned_tab_codec.cc +++ b/chrome/browser/tabs/pinned_tab_codec.cc @@ -43,7 +43,7 @@ static void EncodePinnedTab(TabStripModel* model, TabContents* tab_contents = model->GetTabContentsAt(index); if (model->IsAppTab(index)) { - Extension* extension = tab_contents->extension_app(); + const Extension* extension = tab_contents->extension_app(); DCHECK(extension); value->SetString(kAppID, extension->id()); // For apps we use the launch url. We do this for the following reason: diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 0d744e4..80f048b 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -756,7 +756,7 @@ void TabStripModel::Observe(NotificationType type, } case NotificationType::EXTENSION_UNLOADED: { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); // Iterate backwards as we may remove items while iterating. for (int i = count() - 1; i >= 0; i--) { TabContents* contents = GetTabContentsAt(i); diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index cd7c2f9..56cbdbf 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -326,7 +326,8 @@ BrowserThemePack::~BrowserThemePack() { } // static -BrowserThemePack* BrowserThemePack::BuildFromExtension(Extension* extension) { +BrowserThemePack* BrowserThemePack::BuildFromExtension( + const Extension* extension) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(extension); DCHECK(extension->is_theme()); @@ -576,7 +577,7 @@ BrowserThemePack::BrowserThemePack() source_images_(NULL) { } -void BrowserThemePack::BuildHeader(Extension* extension) { +void BrowserThemePack::BuildHeader(const Extension* extension) { header_ = new BrowserThemePackHeader; header_->version = kThemePackVersion; diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h index 5fa55e2..d66b99b 100644 --- a/chrome/browser/themes/browser_theme_pack.h +++ b/chrome/browser/themes/browser_theme_pack.h @@ -46,7 +46,7 @@ class BrowserThemePack : public base::RefCountedThreadSafe< // Builds the theme pack from all data from |extension|. This is often done // on a separate thread as it takes so long. This can fail and return NULL in // the case where the theme has invalid data. - static BrowserThemePack* BuildFromExtension(Extension* extension); + static BrowserThemePack* BuildFromExtension(const Extension* extension); // Builds the theme pack from a previously performed WriteToDisk(). This // operation should be relatively fast, as it should be an mmap() and some @@ -107,7 +107,7 @@ class BrowserThemePack : public base::RefCountedThreadSafe< virtual ~BrowserThemePack(); // Builds a header ready to write to disk. - void BuildHeader(Extension* extension); + void BuildHeader(const Extension* extension); // Transforms the JSON tint values into their final versions in the |tints_| // array. diff --git a/chrome/browser/themes/browser_theme_provider.cc b/chrome/browser/themes/browser_theme_provider.cc index 58a6c31..134d954 100644 --- a/chrome/browser/themes/browser_theme_provider.cc +++ b/chrome/browser/themes/browser_theme_provider.cc @@ -288,7 +288,7 @@ RefCountedMemory* BrowserThemeProvider::GetRawData(int id) const { return data; } -void BrowserThemeProvider::SetTheme(Extension* extension) { +void BrowserThemeProvider::SetTheme(const Extension* extension) { // Clear our image cache. FreePlatformCaches(); @@ -557,7 +557,8 @@ void BrowserThemeProvider::LoadThemePrefs() { // theme is being migrated. ExtensionsService* service = profile_->GetExtensionsService(); if (service) { - Extension* extension = service->GetExtensionById(current_id, false); + const Extension* extension = + service->GetExtensionById(current_id, false); if (extension) { DLOG(ERROR) << "Migrating theme"; BuildFromExtension(extension); @@ -573,13 +574,13 @@ void BrowserThemeProvider::LoadThemePrefs() { } } -void BrowserThemeProvider::NotifyThemeChanged(Extension* extension) { +void BrowserThemeProvider::NotifyThemeChanged(const Extension* extension) { VLOG(1) << "Sending BROWSER_THEME_CHANGED"; // Redraw! NotificationService* service = NotificationService::current(); service->Notify(NotificationType::BROWSER_THEME_CHANGED, Source<BrowserThemeProvider>(this), - Details<Extension>(extension)); + Details<const Extension>(extension)); #if defined(OS_MACOSX) NotifyPlatformThemeChanged(); #endif // OS_MACOSX @@ -600,7 +601,7 @@ void BrowserThemeProvider::SaveThemeID(const std::string& id) { profile_->GetPrefs()->SetString(prefs::kCurrentThemeID, id); } -void BrowserThemeProvider::BuildFromExtension(Extension* extension) { +void BrowserThemeProvider::BuildFromExtension(const Extension* extension) { scoped_refptr<BrowserThemePack> pack = BrowserThemePack::BuildFromExtension(extension); if (!pack.get()) { diff --git a/chrome/browser/themes/browser_theme_provider.h b/chrome/browser/themes/browser_theme_provider.h index f359072..a47f39c 100644 --- a/chrome/browser/themes/browser_theme_provider.h +++ b/chrome/browser/themes/browser_theme_provider.h @@ -152,7 +152,7 @@ class BrowserThemeProvider : public NonThreadSafe, #endif // Set the current theme to the theme defined in |extension|. - virtual void SetTheme(Extension* extension); + virtual void SetTheme(const Extension* extension); // Reset the theme to default. virtual void UseDefaultTheme(); @@ -221,7 +221,7 @@ class BrowserThemeProvider : public NonThreadSafe, // Let all the browser views know that themes have changed. // extension is NULL iff the theme is being set to the // default/system theme. - virtual void NotifyThemeChanged(Extension* extension); + virtual void NotifyThemeChanged(const Extension* extension); #if defined(OS_MACOSX) // Let all the browser views know that themes have changed in a platform way. @@ -245,7 +245,7 @@ class BrowserThemeProvider : public NonThreadSafe, // Implementation of SetTheme() (and the fallback from LoadThemePrefs() in // case we don't have a theme pack). - void BuildFromExtension(Extension* extension); + void BuildFromExtension(const Extension* extension); // Remove preference values for themes that are no longer in use. void RemoveUnusedThemes(); diff --git a/chrome/browser/views/app_launched_animation_win.cc b/chrome/browser/views/app_launched_animation_win.cc index 8a23d43..50efc5d 100644 --- a/chrome/browser/views/app_launched_animation_win.cc +++ b/chrome/browser/views/app_launched_animation_win.cc @@ -38,7 +38,7 @@ class AppLaunchedAnimationWin : public AnimationDelegate, public ImageLoadingTracker::Observer, public views::ImageView { public: - AppLaunchedAnimationWin(Extension* extension, const gfx::Rect& rect); + AppLaunchedAnimationWin(const Extension* extension, const gfx::Rect& rect); private: // AnimationDelegate @@ -65,7 +65,7 @@ class AppLaunchedAnimationWin : public AnimationDelegate, DISALLOW_COPY_AND_ASSIGN(AppLaunchedAnimationWin); }; -AppLaunchedAnimationWin::AppLaunchedAnimationWin(Extension* extension, +AppLaunchedAnimationWin::AppLaunchedAnimationWin(const Extension* extension, const gfx::Rect& rect) : popup_(NULL), rect_(rect), @@ -128,7 +128,8 @@ void AppLaunchedAnimationWin::OnImageLoaded(SkBitmap* image, } // namespace // static -void AppLaunchedAnimation::Show(Extension* extension, const gfx::Rect& rect) { +void AppLaunchedAnimation::Show(const Extension* extension, + const gfx::Rect& rect) { // The animation will delete itself when it's finished. new AppLaunchedAnimationWin(extension, rect); } diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index d2db56c..fb50270 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -58,7 +58,7 @@ bool BrowserActionsContainer::disable_animations_during_testing_ = false; //////////////////////////////////////////////////////////////////////////////// // BrowserActionButton -BrowserActionButton::BrowserActionButton(Extension* extension, +BrowserActionButton::BrowserActionButton(const Extension* extension, BrowserActionsContainer* panel) : ALLOW_THIS_IN_INITIALIZER_LIST( MenuButton(this, std::wstring(), NULL, false)), @@ -281,7 +281,7 @@ BrowserActionButton::~BrowserActionButton() { //////////////////////////////////////////////////////////////////////////////// // BrowserActionView -BrowserActionView::BrowserActionView(Extension* extension, +BrowserActionView::BrowserActionView(const Extension* extension, BrowserActionsContainer* panel) : panel_(panel) { button_ = new BrowserActionButton(extension, panel); @@ -838,7 +838,7 @@ void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id, size_t new_index) { ExtensionsService* service = profile_->GetExtensionsService(); if (service) { - Extension* extension = service->GetExtensionById(extension_id, false); + const Extension* extension = service->GetExtensionById(extension_id, false); model_->MoveBrowserAction(extension, new_index); SchedulePaint(); } @@ -886,7 +886,7 @@ int BrowserActionsContainer::IconHeight() { return icon_height; } -void BrowserActionsContainer::BrowserActionAdded(Extension* extension, +void BrowserActionsContainer::BrowserActionAdded(const Extension* extension, int index) { #if defined(DEBUG) for (size_t i = 0; i < browser_action_views_.size(); ++i) { @@ -924,7 +924,7 @@ void BrowserActionsContainer::BrowserActionAdded(Extension* extension, } } -void BrowserActionsContainer::BrowserActionRemoved(Extension* extension) { +void BrowserActionsContainer::BrowserActionRemoved(const Extension* extension) { CloseOverflowMenu(); if (popup_ && popup_->host()->extension() == extension) @@ -961,7 +961,7 @@ void BrowserActionsContainer::BrowserActionRemoved(Extension* extension) { } } -void BrowserActionsContainer::BrowserActionMoved(Extension* extension, +void BrowserActionsContainer::BrowserActionMoved(const Extension* extension, int index) { if (!ShouldDisplayBrowserAction(extension)) return; @@ -1091,7 +1091,8 @@ void BrowserActionsContainer::SaveDesiredSizeAndAnimate( } } -bool BrowserActionsContainer::ShouldDisplayBrowserAction(Extension* extension) { +bool BrowserActionsContainer::ShouldDisplayBrowserAction( + const Extension* extension) { // Only display incognito-enabled extensions while in incognito mode. return (!profile_->IsOffTheRecord() || profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h index cd376f7..0bc5fdd 100644 --- a/chrome/browser/views/browser_actions_container.h +++ b/chrome/browser/views/browser_actions_container.h @@ -54,13 +54,14 @@ class BrowserActionButton : public views::MenuButton, public ImageLoadingTracker::Observer, public NotificationObserver { public: - BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); + BrowserActionButton(const Extension* extension, + BrowserActionsContainer* panel); // Call this instead of delete. void Destroy(); ExtensionAction* browser_action() const { return browser_action_; } - Extension* extension() { return extension_; } + const Extension* extension() { return extension_; } // Called to update the display to match the browser action's state. void UpdateState(); @@ -112,7 +113,7 @@ class BrowserActionButton : public views::MenuButton, ExtensionAction* browser_action_; // The extension associated with the browser action we're displaying. - Extension* extension_; + const Extension* extension_; // The object that is waiting for the image loading to complete // asynchronously. @@ -146,7 +147,7 @@ class BrowserActionButton : public views::MenuButton, class BrowserActionView : public views::View { public: - BrowserActionView(Extension* extension, BrowserActionsContainer* panel); + BrowserActionView(const Extension* extension, BrowserActionsContainer* panel); virtual ~BrowserActionView(); BrowserActionButton* button() { return button_; } @@ -391,9 +392,9 @@ class BrowserActionsContainer static int IconHeight(); // ExtensionToolbarModel::Observer implementation. - virtual void BrowserActionAdded(Extension* extension, int index); - virtual void BrowserActionRemoved(Extension* extension); - virtual void BrowserActionMoved(Extension* extension, int index); + virtual void BrowserActionAdded(const Extension* extension, int index); + virtual void BrowserActionRemoved(const Extension* extension); + virtual void BrowserActionMoved(const Extension* extension, int index); virtual void ModelLoaded(); void LoadImages(); @@ -441,7 +442,7 @@ class BrowserActionsContainer // Returns true if this extension should be shown in this toolbar. This can // return false if we are in an incognito window and the extension is disabled // for incognito. - bool ShouldDisplayBrowserAction(Extension* extension); + bool ShouldDisplayBrowserAction(const Extension* extension); // The vector of browser actions (icons/image buttons for each action). Note // that not every BrowserAction in the ToolbarModel will necessarily be in diff --git a/chrome/browser/views/browser_actions_container_browsertest.cc b/chrome/browser/views/browser_actions_container_browsertest.cc index 664b510..ee30ddb 100644 --- a/chrome/browser/views/browser_actions_container_browsertest.cc +++ b/chrome/browser/views/browser_actions_container_browsertest.cc @@ -172,7 +172,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, TestCrash57536) { .AppendASCII("browser_action") .AppendASCII("crash_57536"))); - Extension* extension = service->extensions()->at(size_before); + const Extension* extension = service->extensions()->at(size_before); std::cout << "Creating bitmap\n" << std::flush; diff --git a/chrome/browser/views/extensions/extension_install_prompt.cc b/chrome/browser/views/extensions/extension_install_prompt.cc index 0aef60e..5cf1e7b 100644 --- a/chrome/browser/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/views/extensions/extension_install_prompt.cc @@ -36,8 +36,10 @@ const int kIconSize = 69; class InstallDialogContent : public views::View, public views::DialogDelegate { public: InstallDialogContent(ExtensionInstallUI::Delegate* delegate, - Extension* extension, SkBitmap* icon, ExtensionInstallUI::PromptType type) - : delegate_(delegate), icon_(NULL), type_(type) { + const Extension* extension, + SkBitmap* icon, + ExtensionInstallUI::PromptType type) + : delegate_(delegate), icon_(NULL), type_(type) { // Scale down to icon size, but allow smaller icons (don't scale up). gfx::Size size(icon->width(), icon->height()); if (size.width() > kIconSize || size.height() > kIconSize) @@ -142,7 +144,10 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { // static void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, PromptType type) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { diff --git a/chrome/browser/views/extensions/extension_install_prompt2.cc b/chrome/browser/views/extensions/extension_install_prompt2.cc index 467ae20..ba9631e 100644 --- a/chrome/browser/views/extensions/extension_install_prompt2.cc +++ b/chrome/browser/views/extensions/extension_install_prompt2.cc @@ -58,7 +58,7 @@ class InstallDialogContent2 : public views::View, public views::DialogDelegate { public: InstallDialogContent2(ExtensionInstallUI::Delegate* delegate, - Extension* extension, + const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions); @@ -109,7 +109,7 @@ class InstallDialogContent2 InstallDialogContent2::InstallDialogContent2( - ExtensionInstallUI::Delegate* delegate, Extension* extension, + ExtensionInstallUI::Delegate* delegate, const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions) : delegate_(delegate), icon_(NULL), @@ -292,7 +292,8 @@ void InstallDialogContent2::Layout() { // static void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, Delegate* delegate, const Extension* extension, + SkBitmap* icon, const std::vector<string16>& permissions) { #if defined(OS_CHROMEOS) // Use a normal browser window as parent on ChromeOS. diff --git a/chrome/browser/views/extensions/extension_installed_bubble.cc b/chrome/browser/views/extensions/extension_installed_bubble.cc index 27910e5..8cb9397 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.cc +++ b/chrome/browser/views/extensions/extension_installed_bubble.cc @@ -69,7 +69,7 @@ const int kAnimationWaitMaxRetry = 10; class InstalledBubbleContent : public views::View, public views::ButtonListener { public: - InstalledBubbleContent(Extension* extension, + InstalledBubbleContent(const Extension* extension, ExtensionInstalledBubble::BubbleType type, SkBitmap* icon) : info_bubble_(NULL), @@ -241,12 +241,13 @@ class InstalledBubbleContent : public views::View, DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); }; -void ExtensionInstalledBubble::Show(Extension *extension, Browser *browser, +void ExtensionInstalledBubble::Show(const Extension* extension, + Browser *browser, SkBitmap icon) { new ExtensionInstalledBubble(extension, browser, icon); } -ExtensionInstalledBubble::ExtensionInstalledBubble(Extension *extension, +ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon) : extension_(extension), @@ -281,7 +282,7 @@ void ExtensionInstalledBubble::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::EXTENSION_LOADED) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == extension_) { animation_wait_retries_ = 0; // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. diff --git a/chrome/browser/views/extensions/extension_installed_bubble.h b/chrome/browser/views/extensions/extension_installed_bubble.h index 81c12a6..a35f820 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.h +++ b/chrome/browser/views/extensions/extension_installed_bubble.h @@ -44,13 +44,13 @@ class ExtensionInstalledBubble // the extension has loaded. |extension| is the installed extension. |browser| // is the browser window which will host the bubble. |icon| is the install // icon of the extension. - static void Show(Extension *extension, Browser *browser, SkBitmap icon); + static void Show(const Extension* extension, Browser *browser, SkBitmap icon); private: friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>; // Private ctor. Registers a listener for EXTENSION_LOADED. - ExtensionInstalledBubble(Extension *extension, Browser *browser, + ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon); ~ExtensionInstalledBubble() {} @@ -69,7 +69,7 @@ class ExtensionInstalledBubble virtual bool CloseOnEscape() { return true; } virtual bool FadeInOnShow() { return true; } - Extension* extension_; + const Extension* extension_; Browser* browser_; SkBitmap icon_; NotificationRegistrar registrar_; diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc index 4ba38ca..fcace1a 100644 --- a/chrome/browser/views/extensions/extension_view.cc +++ b/chrome/browser/views/extensions/extension_view.cc @@ -39,7 +39,7 @@ ExtensionView::~ExtensionView() { CleanUp(); } -Extension* ExtensionView::extension() const { +const Extension* ExtensionView::extension() const { return host_->extension(); } diff --git a/chrome/browser/views/extensions/extension_view.h b/chrome/browser/views/extensions/extension_view.h index 6eded74a..037c2e8e 100644 --- a/chrome/browser/views/extensions/extension_view.h +++ b/chrome/browser/views/extensions/extension_view.h @@ -36,7 +36,7 @@ class ExtensionView : public views::NativeViewHost { ExtensionHost* host() const { return host_; } Browser* browser() const { return browser_; } - Extension* extension() const; + const Extension* extension() const; RenderViewHost* render_view_host() const; void DidStopLoading(); void SetIsClipped(bool is_clipped); diff --git a/chrome/browser/views/infobars/extension_infobar.cc b/chrome/browser/views/infobars/extension_infobar.cc index 441a95e..e2fb43f 100644 --- a/chrome/browser/views/infobars/extension_infobar.cc +++ b/chrome/browser/views/infobars/extension_infobar.cc @@ -164,7 +164,7 @@ void ExtensionInfoBar::SetupIconAndMenu() { menu_->SetVisible(false); AddChildView(menu_); - Extension* extension = delegate_->extension_host()->extension(); + const Extension* extension = delegate_->extension_host()->extension(); ExtensionResource icon_resource = extension->GetIconResource( Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { diff --git a/chrome/browser/views/location_bar/page_action_image_view.cc b/chrome/browser/views/location_bar/page_action_image_view.cc index aa739c0..c7155bf 100644 --- a/chrome/browser/views/location_bar/page_action_image_view.cc +++ b/chrome/browser/views/location_bar/page_action_image_view.cc @@ -26,8 +26,8 @@ PageActionImageView::PageActionImageView(LocationBarView* owner, current_tab_id_(-1), preview_enabled_(false), popup_(NULL) { - Extension* extension = profile->GetExtensionsService()->GetExtensionById( - page_action->extension_id(), false); + const Extension* extension = profile->GetExtensionsService()-> + GetExtensionById(page_action->extension_id(), false); DCHECK(extension); // Load all the icons declared in the manifest. This is the contents of the @@ -146,8 +146,8 @@ bool PageActionImageView::OnKeyPressed(const views::KeyEvent& e) { void PageActionImageView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { - Extension* extension = profile_->GetExtensionsService()->GetExtensionById( - page_action()->extension_id(), false); + const Extension* extension = profile_->GetExtensionsService()-> + GetExtensionById(page_action()->extension_id(), false); Browser* browser = BrowserView::GetBrowserViewForNativeWindow( platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser(); context_menu_contents_ = diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 8bf9938..dc11856 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -299,7 +299,7 @@ int Extension::GetPermissionMessageId(const std::string& permission) { return ExtensionConfig::GetSingleton()->GetPermissionMessageId(permission); } -std::vector<string16> Extension::GetPermissionMessages() { +std::vector<string16> Extension::GetPermissionMessages() const { std::vector<string16> messages; if (!plugins().empty()) { messages.push_back( @@ -317,7 +317,7 @@ std::vector<string16> Extension::GetPermissionMessages() { return messages; } -std::set<string16> Extension::GetSimplePermissionMessages() { +std::set<string16> Extension::GetSimplePermissionMessages() const { std::set<string16> messages; std::set<std::string>::const_iterator i; for (i = api_permissions().begin(); i != api_permissions().end(); ++i) { @@ -328,7 +328,7 @@ std::set<string16> Extension::GetSimplePermissionMessages() { return messages; } -std::vector<std::string> Extension::GetDistinctHosts() { +std::vector<std::string> Extension::GetDistinctHosts() const { return GetDistinctHosts(GetEffectiveHostPermissions().patterns()); } @@ -359,7 +359,7 @@ std::vector<std::string> Extension::GetDistinctHosts( return distinct_hosts; } -string16 Extension::GetHostPermissionMessage() { +string16 Extension::GetHostPermissionMessage() const { if (HasEffectiveAccessToAllHosts()) return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT2_WARNING_ALL_HOSTS); @@ -447,7 +447,7 @@ std::string Extension::GenerateIdForPath(const FilePath& path) { return id; } -Extension::HistogramType Extension::GetHistogramType() { +Extension::HistogramType Extension::GetHistogramType() const { if (is_theme()) return TYPE_THEME; if (converted_from_user_script()) @@ -782,7 +782,7 @@ ExtensionAction* Extension::LoadExtensionActionHelper( return result.release(); } -bool Extension::ContainsNonThemeKeys(const DictionaryValue& source) { +bool Extension::ContainsNonThemeKeys(const DictionaryValue& source) const { for (DictionaryValue::key_iterator key = source.begin_keys(); key != source.end_keys(); ++key) { if (!IsBaseCrxKey(*key) && *key != keys::kTheme) @@ -1019,7 +1019,8 @@ Extension::Extension(const FilePath& path, Location location) Extension::~Extension() { } -ExtensionResource Extension::GetResource(const std::string& relative_path) { +ExtensionResource Extension::GetResource( + const std::string& relative_path) const { #if defined(OS_POSIX) FilePath relative_file_path(relative_path); #elif defined(OS_WIN) @@ -1028,7 +1029,8 @@ ExtensionResource Extension::GetResource(const std::string& relative_path) { return ExtensionResource(id(), path(), relative_file_path); } -ExtensionResource Extension::GetResource(const FilePath& relative_file_path) { +ExtensionResource Extension::GetResource( + const FilePath& relative_file_path) const { return ExtensionResource(id(), path(), relative_file_path); } @@ -1108,8 +1110,8 @@ bool Extension::FormatPEMForFileOutput(const std::string input, // extensions that require less permissions than the current version, but then // we don't silently allow them to go back. In order to fix this, we would need // to remember the max set of permissions we ever granted a single extension. -bool Extension::IsPrivilegeIncrease(Extension* old_extension, - Extension* new_extension) { +bool Extension::IsPrivilegeIncrease(const Extension* old_extension, + const Extension* new_extension) { // If the old extension had native code access, we don't need to go any // further. Things can't get any worse. if (old_extension->plugins().size() > 0) @@ -1156,7 +1158,7 @@ bool Extension::IsPrivilegeIncrease(Extension* old_extension, } // static -void Extension::DecodeIcon(Extension* extension, +void Extension::DecodeIcon(const Extension* extension, Icons icon_size, scoped_ptr<SkBitmap>* result) { FilePath icon_path = extension->GetIconResource( @@ -1899,7 +1901,7 @@ GURL Extension::GetHomepageURL() const { return url; } -std::set<FilePath> Extension::GetBrowserImages() { +std::set<FilePath> Extension::GetBrowserImages() const { std::set<FilePath> image_paths; // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| // indicate that we're doing something wrong. @@ -1949,12 +1951,12 @@ GURL Extension::GetFullLaunchURL() const { return GURL(launch_web_url()); } -bool Extension::GetBackgroundPageReady() { +bool Extension::GetBackgroundPageReady() const { return (GetRuntimeData()->background_page_ready || background_url().is_empty()); } -void Extension::SetBackgroundPageReady() { +void Extension::SetBackgroundPageReady() const { DCHECK(!background_url().is_empty()); GetRuntimeData()->background_page_ready = true; NotificationService::current()->Notify( @@ -1982,7 +1984,7 @@ void Extension::SetScriptingWhitelist( void Extension::SetCachedImage(const ExtensionResource& source, const SkBitmap& image, - const gfx::Size& original_size) { + const gfx::Size& original_size) const { DCHECK(source.extension_root() == path()); // The resource must come from // this extension. const FilePath& path = source.relative_path(); @@ -1997,14 +1999,14 @@ void Extension::SetCachedImage(const ExtensionResource& source, } bool Extension::HasCachedImage(const ExtensionResource& source, - const gfx::Size& max_size) { + const gfx::Size& max_size) const { DCHECK(source.extension_root() == path()); // The resource must come from // this extension. return GetCachedImageImpl(source, max_size) != NULL; } SkBitmap Extension::GetCachedImage(const ExtensionResource& source, - const gfx::Size& max_size) { + const gfx::Size& max_size) const { DCHECK(source.extension_root() == path()); // The resource must come from // this extension. SkBitmap* image = GetCachedImageImpl(source, max_size); @@ -2012,7 +2014,7 @@ SkBitmap Extension::GetCachedImage(const ExtensionResource& source, } SkBitmap* Extension::GetCachedImageImpl(const ExtensionResource& source, - const gfx::Size& max_size) { + const gfx::Size& max_size) const { const FilePath& path = source.relative_path(); // Look for exact size match. @@ -2036,14 +2038,15 @@ SkBitmap* Extension::GetCachedImageImpl(const ExtensionResource& source, } ExtensionResource Extension::GetIconResource( - int size, ExtensionIconSet::MatchType match_type) { + int size, ExtensionIconSet::MatchType match_type) const { std::string path = icons().Get(size, match_type); if (path.empty()) return ExtensionResource(); return GetResource(path); } -GURL Extension::GetIconURL(int size, ExtensionIconSet::MatchType match_type) { +GURL Extension::GetIconURL(int size, + ExtensionIconSet::MatchType match_type) const { std::string path = icons().Get(size, match_type); if (path.empty()) return GURL(); @@ -2064,7 +2067,7 @@ bool Extension::CanSpecifyHostPermission(const URLPattern& pattern) const { return true; } -// static. +// static bool Extension::HasApiPermission( const std::set<std::string>& api_permissions, const std::string& function_name) { @@ -2204,7 +2207,7 @@ bool Extension::HasEffectiveAccessToAllHosts() const { return false; } -bool Extension::IsAPIPermission(const std::string& str) { +bool Extension::IsAPIPermission(const std::string& str) const { for (size_t i = 0; i < Extension::kNumPermissions; ++i) { if (str == Extension::kPermissions[i].name) { // Only allow the experimental API permission if the command line diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 82c007b..08e4bbb 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -285,7 +285,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Returns the full list of permission messages that this extension // should display at install time. - std::vector<string16> GetPermissionMessages(); + std::vector<string16> GetPermissionMessages() const; // Returns the distinct hosts that should be displayed in the install UI. This // discards some of the detail that is present in the manifest to make it as @@ -293,7 +293,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // and path components of URLPatterns and de-dupe the result. static std::vector<std::string> GetDistinctHosts( const URLPatternList& host_patterns); - std::vector<std::string> GetDistinctHosts(); + std::vector<std::string> GetDistinctHosts() const; // Icon sizes used by the extension system. static const int kIconSizes[]; @@ -378,7 +378,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { } // See HistogramType definition above. - HistogramType GetHistogramType(); + HistogramType GetHistogramType() const; // Returns an absolute url to a resource inside of an extension. The // |extension_url| argument should be the url() from an Extension object. The @@ -393,10 +393,10 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Returns an extension resource object. |relative_path| should be UTF8 // encoded. - ExtensionResource GetResource(const std::string& relative_path); + ExtensionResource GetResource(const std::string& relative_path) const; // As above, but with |relative_path| following the file system's encoding. - ExtensionResource GetResource(const FilePath& relative_path); + ExtensionResource GetResource(const FilePath& relative_path) const; // |input| is expected to be the text of an rsa public or private key. It // tolerates the presence or absence of bracking header/footer like this: @@ -418,14 +418,14 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Determine whether |new_extension| has increased privileges compared to // |old_extension|. - static bool IsPrivilegeIncrease(Extension* old_extension, - Extension* new_extension); + static bool IsPrivilegeIncrease(const Extension* old_extension, + const Extension* new_extension); // Given an extension and icon size, read it if present and decode it into // result. In the browser process, this will DCHECK if not called on the // file thread. To easily load extension images on the UI thread, see // ImageLoadingTracker. - static void DecodeIcon(Extension* extension, + static void DecodeIcon(const Extension* extension, Icons icon_size, scoped_ptr<SkBitmap>* result); @@ -560,12 +560,12 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Returns a list of paths (relative to the extension dir) for images that // the browser might load (like themes and page action icons). - std::set<FilePath> GetBrowserImages(); + std::set<FilePath> GetBrowserImages() const; // Get an extension icon as a resource or URL. - ExtensionResource GetIconResource(int size, - ExtensionIconSet::MatchType match_type); - GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type); + ExtensionResource GetIconResource( + int size, ExtensionIconSet::MatchType match_type) const; + GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const; const DictionaryValue* manifest_value() const { return static_data_->manifest_value.get(); @@ -609,13 +609,13 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Whether the background page, if any, is ready. We don't load other // components until then. If there is no background page, we consider it to // be ready. - bool GetBackgroundPageReady(); - void SetBackgroundPageReady(); + bool GetBackgroundPageReady() const; + void SetBackgroundPageReady() const; // Getter and setter for the flag that specifies whether the extension is // being upgraded. bool being_upgraded() const { return GetRuntimeData()->being_upgraded; } - void set_being_upgraded(bool value) { + void set_being_upgraded(bool value) const { GetRuntimeData()->being_upgraded = value; } @@ -625,11 +625,11 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // before any scaling may have been done to produce the pixels in |image|. void SetCachedImage(const ExtensionResource& source, const SkBitmap& image, - const gfx::Size& original_size); + const gfx::Size& original_size) const; bool HasCachedImage(const ExtensionResource& source, - const gfx::Size& max_size); + const gfx::Size& max_size) const; SkBitmap GetCachedImage(const ExtensionResource& source, - const gfx::Size& max_size); + const gfx::Size& max_size) const; bool is_hosted_app() const { return is_app() && !web_extent().is_empty(); } bool is_packaged_app() const { return is_app() && web_extent().is_empty(); } @@ -658,7 +658,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // value of NULL means there is no matching image cached (we allow caching an // empty SkBitmap). SkBitmap* GetCachedImageImpl(const ExtensionResource& source, - const gfx::Size& max_size); + const gfx::Size& max_size) const; // Helper method that loads a UserScript object from a // dictionary in the content_script list of the manifest. @@ -700,21 +700,21 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Figures out if a source contains keys not associated with themes - we // don't want to allow scripts and such to be bundled with themes. - bool ContainsNonThemeKeys(const DictionaryValue& source); + bool ContainsNonThemeKeys(const DictionaryValue& source) const; // Returns true if the string is one of the known api permissions (see // kPermissions). - bool IsAPIPermission(const std::string& permission); + bool IsAPIPermission(const std::string& permission) const; // The set of unique API install messages that the extension has. // NOTE: This only includes messages related to permissions declared in the // "permissions" key in the manifest. Permissions implied from other features // of the manifest, like plugins and content scripts are not included. - std::set<string16> GetSimplePermissionMessages(); + std::set<string16> GetSimplePermissionMessages() const; // The permission message displayed related to the host permissions for // this extension. - string16 GetHostPermissionMessage(); + string16 GetHostPermissionMessage() const; // Returns a mutable pointer to our runtime data. Can only be called on // the UI thread. @@ -739,7 +739,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { DISALLOW_COPY_AND_ASSIGN(Extension); }; -typedef std::vector< scoped_refptr<Extension> > ExtensionList; +typedef std::vector< scoped_refptr<const Extension> > ExtensionList; typedef std::set<std::string> ExtensionIdSet; // Handy struct to pass core extension info around. diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 55ca1df..7cbe718 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -201,10 +201,10 @@ class TestingProfile : public Profile { virtual BrowserSignin* GetBrowserSignin() { return NULL; } virtual bool HasCreatedDownloadManager() const { return false; } virtual void InitThemes(); - virtual void SetTheme(Extension* extension) {} + virtual void SetTheme(const Extension* extension) {} virtual void SetNativeTheme() {} virtual void ClearTheme() {} - virtual Extension* GetTheme() { return NULL; } + virtual const Extension* GetTheme() { return NULL; } virtual BrowserThemeProvider* GetThemeProvider() { InitThemes(); return theme_provider_.get(); |