| Index: chrome/browser/themes/browser_theme_pack.cc
|
| diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
|
| index a352c67826141a741a3250a9ad50002f8f22b15d..4f3da00892f7a834b1cd3985999ea460ed09c584 100644
|
| --- a/chrome/browser/themes/browser_theme_pack.cc
|
| +++ b/chrome/browser/themes/browser_theme_pack.cc
|
| @@ -546,13 +546,13 @@ BrowserThemePack::~BrowserThemePack() {
|
| }
|
|
|
| // static
|
| -scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension(
|
| - const Extension* extension) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +void BrowserThemePack::BuildFromExtension(
|
| + const extensions::Extension* extension,
|
| + scoped_refptr<BrowserThemePack> pack) {
|
| DCHECK(extension);
|
| DCHECK(extension->is_theme());
|
| + DCHECK(!pack->is_valid());
|
|
|
| - scoped_refptr<BrowserThemePack> pack(new BrowserThemePack);
|
| pack->BuildHeader(extension);
|
| pack->BuildTintsFromJSON(extensions::ThemeInfo::GetTints(extension));
|
| pack->BuildColorsFromJSON(extensions::ThemeInfo::GetColors(extension));
|
| @@ -567,14 +567,14 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension(
|
| &file_paths);
|
| pack->BuildSourceImagesArray(file_paths);
|
|
|
| - if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_on_ui_thread_))
|
| - return NULL;
|
| + if (!pack->LoadRawBitmapsTo(file_paths, &pack->images_))
|
| + return;
|
|
|
| - pack->CreateImages(&pack->images_on_ui_thread_);
|
| + pack->CreateImages(&pack->images_);
|
|
|
| // Make sure the |images_on_file_thread_| has bitmaps for supported
|
| // scale factors before passing to FILE thread.
|
| - pack->images_on_file_thread_ = pack->images_on_ui_thread_;
|
| + pack->images_on_file_thread_ = pack->images_;
|
| for (ImageCache::iterator it = pack->images_on_file_thread_.begin();
|
| it != pack->images_on_file_thread_.end(); ++it) {
|
| gfx::ImageSkia* image_skia =
|
| @@ -582,13 +582,13 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension(
|
| image_skia->MakeThreadSafe();
|
| }
|
|
|
| - // Set ThemeImageSource on |images_on_ui_thread_| to resample the source
|
| + // Set ThemeImageSource on |images_| to resample the source
|
| // image if a caller of BrowserThemePack::GetImageNamed() requests an
|
| // ImageSkiaRep for a scale factor not specified by the theme author.
|
| // Callers of BrowserThemePack::GetImageNamed() to be able to retrieve
|
| // ImageSkiaReps for all supported scale factors.
|
| - for (ImageCache::iterator it = pack->images_on_ui_thread_.begin();
|
| - it != pack->images_on_ui_thread_.end(); ++it) {
|
| + for (ImageCache::iterator it = pack->images_.begin();
|
| + it != pack->images_.end(); ++it) {
|
| const gfx::ImageSkia source_image_skia = it->second.AsImageSkia();
|
| ThemeImageSource* source = new ThemeImageSource(source_image_skia);
|
| // image_skia takes ownership of source.
|
| @@ -603,7 +603,7 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromExtension(
|
| }
|
|
|
| // The BrowserThemePack is now in a consistent state.
|
| - return pack;
|
| + pack->is_valid_ = true;
|
| }
|
|
|
| // static
|
| @@ -671,6 +671,7 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromDataPack(
|
| << "from those supported by platform.";
|
| return NULL;
|
| }
|
| + pack->is_valid_ = true;
|
| return pack;
|
| }
|
|
|
| @@ -683,6 +684,13 @@ bool BrowserThemePack::IsPersistentImageID(int id) {
|
| return false;
|
| }
|
|
|
| +BrowserThemePack::BrowserThemePack() : CustomThemeSupplier(EXTENSION) {
|
| + scale_factors_ = ui::GetSupportedScaleFactors();
|
| + // On Windows HiDPI SCALE_FACTOR_100P may not be supported by default.
|
| + if (!base::ContainsValue(scale_factors_, ui::SCALE_FACTOR_100P))
|
| + scale_factors_.push_back(ui::SCALE_FACTOR_100P);
|
| +}
|
| +
|
| bool BrowserThemePack::WriteToDisk(const base::FilePath& path) const {
|
| // Add resources for each of the property arrays.
|
| RawDataForWriting resources;
|
| @@ -771,8 +779,8 @@ gfx::Image BrowserThemePack::GetImageNamed(int idr_id) {
|
| return gfx::Image();
|
|
|
| // Check if the image is cached.
|
| - ImageCache::const_iterator image_iter = images_on_ui_thread_.find(prs_id);
|
| - if (image_iter != images_on_ui_thread_.end())
|
| + ImageCache::const_iterator image_iter = images_.find(prs_id);
|
| + if (image_iter != images_.end())
|
| return image_iter->second;
|
|
|
| ThemeImagePngSource::PngMap png_map;
|
| @@ -786,7 +794,7 @@ gfx::Image BrowserThemePack::GetImageNamed(int idr_id) {
|
| gfx::ImageSkia image_skia(new ThemeImagePngSource(png_map), 1.0f);
|
| // |image_skia| takes ownership of ThemeImagePngSource.
|
| gfx::Image ret = gfx::Image(image_skia);
|
| - images_on_ui_thread_[prs_id] = ret;
|
| + images_[prs_id] = ret;
|
| return ret;
|
| }
|
|
|
| @@ -830,19 +838,6 @@ bool BrowserThemePack::HasCustomImage(int idr_id) const {
|
|
|
| // private:
|
|
|
| -BrowserThemePack::BrowserThemePack()
|
| - : CustomThemeSupplier(EXTENSION),
|
| - header_(NULL),
|
| - tints_(NULL),
|
| - colors_(NULL),
|
| - display_properties_(NULL),
|
| - source_images_(NULL) {
|
| - scale_factors_ = ui::GetSupportedScaleFactors();
|
| - // On Windows HiDPI SCALE_FACTOR_100P may not be supported by default.
|
| - if (!base::ContainsValue(scale_factors_, ui::SCALE_FACTOR_100P))
|
| - scale_factors_.push_back(ui::SCALE_FACTOR_100P);
|
| -}
|
| -
|
| void BrowserThemePack::BuildHeader(const Extension* extension) {
|
| header_ = new BrowserThemePackHeader;
|
| header_->version = kThemePackVersion;
|
|
|