diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 23:14:02 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-29 23:14:02 +0000 |
commit | 9adb9693e8a90bb63be325dbb5d3391f47f839ba (patch) | |
tree | 555765afd7bc851de6f3a2bf4a35151435d58d77 /chrome/browser/themes | |
parent | 5b5a5c976aead85a87ced0847c068012d3979cae (diff) | |
download | chromium_src-9adb9693e8a90bb63be325dbb5d3391f47f839ba.zip chromium_src-9adb9693e8a90bb63be325dbb5d3391f47f839ba.tar.gz chromium_src-9adb9693e8a90bb63be325dbb5d3391f47f839ba.tar.bz2 |
Part 3 of immutable Extension refactor.
Make ExtensionsService hold const Extension pointers only. This ensures that
extensions can't be modified after they're created, and lets us share them
between threads.
BUG=56558
TEST=no functional change
Review URL: http://codereview.chromium.org/4138006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/themes')
-rw-r--r-- | chrome/browser/themes/browser_theme_pack.cc | 5 | ||||
-rw-r--r-- | chrome/browser/themes/browser_theme_pack.h | 4 | ||||
-rw-r--r-- | chrome/browser/themes/browser_theme_provider.cc | 11 | ||||
-rw-r--r-- | chrome/browser/themes/browser_theme_provider.h | 6 |
4 files changed, 14 insertions, 12 deletions
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(); |