diff options
author | mtytel@chromium.org <mtytel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 01:34:15 +0000 |
---|---|---|
committer | mtytel@chromium.org <mtytel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 01:34:15 +0000 |
commit | e3c0bc2ff182bfe27448b3ad590e91f6f9626f1c (patch) | |
tree | 06f394bc5aea2c911d2c44cb1a31dd1cec2c23f1 /chrome/browser | |
parent | bc95a82163a28b9bf5b17685321a9bf8d6b55113 (diff) | |
download | chromium_src-e3c0bc2ff182bfe27448b3ad590e91f6f9626f1c.zip chromium_src-e3c0bc2ff182bfe27448b3ad590e91f6f9626f1c.tar.gz chromium_src-e3c0bc2ff182bfe27448b3ad590e91f6f9626f1c.tar.bz2 |
Support for 512px and 256px icons in extensions
BUG=63406
TEST=Install an extension with only a 256x256 or 512x512 icon
Review URL: http://codereview.chromium.org/9025034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123391 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
23 files changed, 79 insertions, 75 deletions
diff --git a/chrome/browser/background/background_application_list_model.cc b/chrome/browser/background/background_application_list_model.cc index d7d4740..cc05fc5 100644 --- a/chrome/browser/background/background_application_list_model.cc +++ b/chrome/browser/background/background_application_list_model.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,6 +18,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/extension_resource.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" @@ -60,7 +61,7 @@ class BackgroundApplicationListModel::Application // Uses the FILE thread to request this extension's icon, sized // appropriately. - void RequestIcon(Extension::Icons size); + void RequestIcon(ExtensionIconSet::Icons size); const Extension* extension_; scoped_ptr<SkBitmap> icon_; @@ -138,7 +139,7 @@ void BackgroundApplicationListModel::Application::OnImageLoaded( } void BackgroundApplicationListModel::Application::RequestIcon( - Extension::Icons size) { + ExtensionIconSet::Icons size) { ExtensionResource resource = extension_->GetIconResource( size, ExtensionIconSet::MATCH_BIGGER); tracker_.LoadImage(extension_, resource, gfx::Size(size, size), @@ -189,7 +190,7 @@ void BackgroundApplicationListModel::AssociateApplicationData( application = new Application(this, extension); applications_[extension->id()] = application; Update(); - application->RequestIcon(Extension::EXTENSION_ICON_BITTY); + application->RequestIcon(ExtensionIconSet::EXTENSION_ICON_BITTY); } } diff --git a/chrome/browser/background/background_application_list_model.h b/chrome/browser/background/background_application_list_model.h index 44248c8..8e7b798 100644 --- a/chrome/browser/background/background_application_list_model.h +++ b/chrome/browser/background/background_application_list_model.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,7 +55,8 @@ class BackgroundApplicationListModel : public content::NotificationObserver { // // NOTE: The model manages the SkBitmap result, that is it "owns" the memory, // releasing it if the associated background application is unloaded. - // NOTE: All icons are currently sized as Extension::EXTENSION_ICON_BITTY. + // NOTE: All icons are currently sized as + // ExtensionIconSet::EXTENSION_ICON_BITTY. const SkBitmap* GetIcon(const Extension* extension); // Return the position of |extension| within this list model. diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index b90d52c..39969c3 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -26,6 +26,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" #include "content/public/browser/notification_service.h" @@ -105,7 +106,7 @@ void ShowBalloon(const Extension* extension, Profile* profile) { IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, UTF8ToUTF16(extension->name())); string16 content_url = DesktopNotificationService::CreateDataUrl( - extension->GetIconURL(Extension::EXTENSION_ICON_SMALLISH, + extension->GetIconURL(ExtensionIconSet::EXTENSION_ICON_SMALLISH, ExtensionIconSet::MATCH_BIGGER), string16(), message, WebKit::WebTextDirectionDefault); Notification notification( diff --git a/chrome/browser/chromeos/offline/offline_load_page.cc b/chrome/browser/chromeos/offline/offline_load_page.cc index 4c6be59..e7bce3b 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.cc +++ b/chrome/browser/chromeos/offline/offline_load_page.cc @@ -20,6 +20,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" @@ -140,8 +141,8 @@ void OfflineLoadPage::GetAppOfflineStrings( DictionaryValue* strings) const { strings->SetString("title", app->name()); - GURL icon_url = app->GetIconURL(Extension::EXTENSION_ICON_LARGE, - ExtensionIconSet::MATCH_EXACTLY); + GURL icon_url = app->GetIconURL(ExtensionIconSet::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER); if (icon_url.is_empty()) { strings->SetString("display_icon", "none"); strings->SetString("icon", string16()); diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 4b923e9..a3edce8 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -25,6 +25,7 @@ #include "chrome/browser/extensions/convert_web_app.h" #include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_error_reporter.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/permissions_updater.h" #include "chrome/browser/shell_integration.h" @@ -361,7 +362,9 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir, } if (client_) { - Extension::DecodeIcon(extension_.get(), Extension::EXTENSION_ICON_LARGE, + Extension::DecodeIcon(extension_.get(), + ExtensionIconSet::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER, &install_icon_); } diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc index 1f77679..aaf7aab 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.cc +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc @@ -30,6 +30,7 @@ #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/file_browser_handler.h" #include "chrome/common/pref_names.h" #include "content/browser/renderer_host/render_view_host.h" @@ -678,7 +679,7 @@ bool GetFileTasksFileBrowserFunction::RunImpl() { // manifest instead of the default extension icon. GURL icon = ExtensionIconSource::GetIconURL(extension, - Extension::EXTENSION_ICON_BITTY, + ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER, false, NULL); // grayscale task->SetString("iconUrl", icon.spec()); diff --git a/chrome/browser/extensions/extension_icon_manager.cc b/chrome/browser/extensions/extension_icon_manager.cc index 8e3e396..298ab22 100644 --- a/chrome/browser/extensions/extension_icon_manager.cc +++ b/chrome/browser/extensions/extension_icon_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -48,7 +48,7 @@ ExtensionIconManager::~ExtensionIconManager() { void ExtensionIconManager::LoadIcon(const Extension* extension) { ExtensionResource icon_resource = extension->GetIconResource( - Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER); + ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER); if (!icon_resource.extension_root().empty()) { // Insert into pending_icons_ first because LoadImage can call us back // synchronously if the image is already cached. diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 1ae8529..268a239 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -416,8 +416,8 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { // Load the image asynchronously. For the response, check OnImageLoaded. prompt_type_ = prompt_type; ExtensionResource image = - extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE, - ExtensionIconSet::MATCH_EXACTLY); + extension_->GetIconResource(ExtensionIconSet::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER); tracker_.LoadImage(extension_, image, gfx::Size(kIconSize, kIconSize), ImageLoadingTracker::DONT_CACHE); diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc index 7233585..7d50a04 100644 --- a/chrome/browser/extensions/extension_management_api.cc +++ b/chrome/browser/extensions/extension_management_api.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -81,10 +81,10 @@ static DictionaryValue* CreateExtensionInfo(const Extension& extension, const ExtensionIconSet::IconMap& icons = extension.icons().map(); if (!icons.empty()) { ListValue* icon_list = new ListValue(); - std::map<int, std::string>::const_iterator icon_iter; + std::map<ExtensionIconSet::Icons, std::string>::const_iterator icon_iter; for (icon_iter = icons.begin(); icon_iter != icons.end(); ++icon_iter) { DictionaryValue* icon_info = new DictionaryValue(); - Extension::Icons size = static_cast<Extension::Icons>(icon_iter->first); + ExtensionIconSet::Icons size = icon_iter->first; GURL url = ExtensionIconSource::GetIconURL( &extension, size, ExtensionIconSet::MATCH_EXACTLY, false, NULL); icon_info->SetInteger(keys::kSizeKey, icon_iter->first); diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc index 1b4b4a4..6ec0221 100644 --- a/chrome/browser/extensions/extension_tab_helper.cc +++ b/chrome/browser/extensions/extension_tab_helper.cc @@ -241,10 +241,10 @@ void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) { extension_app_image_loader_.reset(new ImageLoadingTracker(this)); extension_app_image_loader_->LoadImage( extension, - extension->GetIconResource(Extension::EXTENSION_ICON_SMALLISH, + extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALLISH, ExtensionIconSet::MATCH_EXACTLY), - gfx::Size(Extension::EXTENSION_ICON_SMALLISH, - Extension::EXTENSION_ICON_SMALLISH), + gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALLISH, + ExtensionIconSet::EXTENSION_ICON_SMALLISH), ImageLoadingTracker::CACHE); } else { extension_app_image_loader_.reset(NULL); diff --git a/chrome/browser/extensions/extension_uninstall_dialog.cc b/chrome/browser/extensions/extension_uninstall_dialog.cc index d5bed37..d3044d7 100644 --- a/chrome/browser/extensions/extension_uninstall_dialog.cc +++ b/chrome/browser/extensions/extension_uninstall_dialog.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,8 +33,8 @@ void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) { extension_ = extension; ExtensionResource image = - extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE, - ExtensionIconSet::MATCH_EXACTLY); + extension_->GetIconResource(ExtensionIconSet::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER); // Load the image asynchronously. The response will be sent to OnImageLoaded. tracker_.LoadImage(extension_, image, gfx::Size(kIconSize, kIconSize), diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc index c74c433..a1f48b2 100644 --- a/chrome/browser/extensions/extension_web_ui.cc +++ b/chrome/browser/extensions/extension_web_ui.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -77,7 +77,7 @@ class ExtensionWebUIImageLoadingTracker : public ImageLoadingTracker::Observer { void Init() { if (extension_) { ExtensionResource icon_resource = - extension_->GetIconResource(Extension::EXTENSION_ICON_BITTY, + extension_->GetIconResource(ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); tracker_.LoadImage(extension_, icon_resource, diff --git a/chrome/browser/extensions/image_loading_tracker_unittest.cc b/chrome/browser/extensions/image_loading_tracker_unittest.cc index 5bdb118..820bde0 100644 --- a/chrome/browser/extensions/image_loading_tracker_unittest.cc +++ b/chrome/browser/extensions/image_loading_tracker_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -102,10 +102,10 @@ TEST_F(ImageLoadingTrackerTest, Cache) { ASSERT_TRUE(extension.get() != NULL); ExtensionResource image_resource = - extension->GetIconResource(Extension::EXTENSION_ICON_SMALLISH, + extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALLISH, ExtensionIconSet::MATCH_EXACTLY); - gfx::Size max_size(Extension::EXTENSION_ICON_SMALLISH, - Extension::EXTENSION_ICON_SMALLISH); + gfx::Size max_size(ExtensionIconSet::EXTENSION_ICON_SMALLISH, + ExtensionIconSet::EXTENSION_ICON_SMALLISH); ImageLoadingTracker loader(static_cast<ImageLoadingTracker::Observer*>(this)); loader.LoadImage(extension.get(), image_resource, @@ -121,13 +121,13 @@ TEST_F(ImageLoadingTrackerTest, Cache) { EXPECT_EQ(1, image_loaded_count()); // Check that the image was loaded. - EXPECT_EQ(Extension::EXTENSION_ICON_SMALLISH, image_.width()); + EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, image_.width()); // The image should be cached in the Extension. EXPECT_TRUE(extension->HasCachedImage(image_resource, max_size)); // Make sure the image is in the extension. - EXPECT_EQ(Extension::EXTENSION_ICON_SMALLISH, + EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, extension->GetCachedImage(image_resource, max_size).width()); // Ask the tracker for the image again, this should call us back immediately. @@ -139,7 +139,7 @@ TEST_F(ImageLoadingTrackerTest, Cache) { EXPECT_EQ(1, image_loaded_count()); // Check that the image was loaded. - EXPECT_EQ(Extension::EXTENSION_ICON_SMALLISH, image_.width()); + EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, image_.width()); } // Tests deleting an extension while waiting for the image to load doesn't cause @@ -149,13 +149,13 @@ TEST_F(ImageLoadingTrackerTest, DeleteExtensionWhileWaitingForCache) { ASSERT_TRUE(extension.get() != NULL); ExtensionResource image_resource = - extension->GetIconResource(Extension::EXTENSION_ICON_SMALLISH, + extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALLISH, ExtensionIconSet::MATCH_EXACTLY); ImageLoadingTracker loader(static_cast<ImageLoadingTracker::Observer*>(this)); loader.LoadImage(extension.get(), image_resource, - gfx::Size(Extension::EXTENSION_ICON_SMALLISH, - Extension::EXTENSION_ICON_SMALLISH), + gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALLISH, + ExtensionIconSet::EXTENSION_ICON_SMALLISH), ImageLoadingTracker::CACHE); // The image isn't cached, so we should not have received notification. @@ -180,5 +180,5 @@ TEST_F(ImageLoadingTrackerTest, DeleteExtensionWhileWaitingForCache) { EXPECT_EQ(1, image_loaded_count()); // Check that the image was loaded. - EXPECT_EQ(Extension::EXTENSION_ICON_SMALLISH, image_.width()); + EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, image_.width()); } diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index a3d40a5..f3353ec 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -69,12 +69,13 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, // Load the Extension's icon image. void LoadIcon() { const Extension* extension = delegate_->extension_host()->extension(); - ExtensionResource icon_resource = extension->GetIconResource( - Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); + ExtensionResource icon_resource = + extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_BITTY, + ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { tracker_.LoadImage(extension, icon_resource, - gfx::Size(Extension::EXTENSION_ICON_BITTY, - Extension::EXTENSION_ICON_BITTY), + gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY, + ExtensionIconSet::EXTENSION_ICON_BITTY), ImageLoadingTracker::DONT_CACHE); } else { OnImageLoaded(NULL, icon_resource, 0); @@ -100,7 +101,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); - const int image_size = Extension::EXTENSION_ICON_BITTY; + const int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; scoped_ptr<gfx::CanvasSkia> canvas( new gfx::CanvasSkia( gfx::Size(image_size + kDropArrowLeftMarginPx + drop_image->width(), diff --git a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc index d405107..4251b18 100644 --- a/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc @@ -77,7 +77,7 @@ void ExtensionInfoBarGtk::OnImageLoaded( SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); - int image_size = Extension::EXTENSION_ICON_BITTY; + int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; // The margin between the extension icon and the drop-down arrow bitmap. static const int kDropArrowLeftMargin = 3; scoped_ptr<gfx::CanvasSkia> canvas(new gfx::CanvasSkia( @@ -109,12 +109,12 @@ void ExtensionInfoBarGtk::BuildWidgets() { // Start loading the image for the menu button. const Extension* extension = delegate_->extension_host()->extension(); ExtensionResource icon_resource = extension->GetIconResource( - Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); + ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { // Create a tracker to load the image. It will report back on OnImageLoaded. tracker_.LoadImage(extension, icon_resource, - gfx::Size(Extension::EXTENSION_ICON_BITTY, - Extension::EXTENSION_ICON_BITTY), + gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY, + ExtensionIconSet::EXTENSION_ICON_BITTY), ImageLoadingTracker::DONT_CACHE); } else { OnImageLoaded(NULL, icon_resource, 0); diff --git a/chrome/browser/ui/views/aura/app_list/extension_app_item.cc b/chrome/browser/ui/views/aura/app_list/extension_app_item.cc index a93ad1b..3abb60a 100644 --- a/chrome/browser/ui/views/aura/app_list/extension_app_item.cc +++ b/chrome/browser/ui/views/aura/app_list/extension_app_item.cc @@ -86,8 +86,7 @@ const Extension* ExtensionAppItem::GetExtension() const { void ExtensionAppItem::LoadImage(const Extension* extension) { ExtensionResource icon = extension->GetIconResource( - ash::AppListItemView::kIconSize, - ExtensionIconSet::MATCH_BIGGER); + ash::AppListItemView::kIconSize, ExtensionIconSet::MATCH_BIGGER); if (icon.relative_path().empty()) { LoadDefaultImage(); return; diff --git a/chrome/browser/ui/views/aura/launcher/launcher_icon_loader.cc b/chrome/browser/ui/views/aura/launcher/launcher_icon_loader.cc index 1d7020c..0d82d21 100644 --- a/chrome/browser/ui/views/aura/launcher/launcher_icon_loader.cc +++ b/chrome/browser/ui/views/aura/launcher/launcher_icon_loader.cc @@ -44,10 +44,10 @@ void LauncherIconLoader::FetchImage(const std::string& id) { map_[image_loader_->next_id()] = id; image_loader_->LoadImage( extension, - extension->GetIconResource(Extension::EXTENSION_ICON_SMALL, + extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALL, ExtensionIconSet::MATCH_BIGGER), - gfx::Size(Extension::EXTENSION_ICON_SMALL, - Extension::EXTENSION_ICON_SMALL), + gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALL, + ExtensionIconSet::EXTENSION_ICON_SMALL), ImageLoadingTracker::CACHE); } diff --git a/chrome/browser/ui/views/infobars/extension_infobar.cc b/chrome/browser/ui/views/infobars/extension_infobar.cc index 343bbd1..db272a9 100644 --- a/chrome/browser/ui/views/infobars/extension_infobar.cc +++ b/chrome/browser/ui/views/infobars/extension_infobar.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -90,7 +90,7 @@ void ExtensionInfoBar::ViewHierarchyChanged(bool is_add, // which assumes that particular children (e.g. the close button) have already // been added. const Extension* extension = extension_host->extension(); - int image_size = Extension::EXTENSION_ICON_BITTY; + ExtensionIconSet::Icons image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; ExtensionResource icon_resource = extension->GetIconResource( image_size, ExtensionIconSet::MATCH_EXACTLY); if (!icon_resource.relative_path().empty()) { @@ -119,7 +119,7 @@ void ExtensionInfoBar::OnImageLoaded(SkBitmap* image, SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); - int image_size = Extension::EXTENSION_ICON_BITTY; + int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; // The margin between the extension icon and the drop-down arrow bitmap. static const int kDropArrowLeftMargin = 3; scoped_ptr<gfx::CanvasSkia> canvas(new gfx::CanvasSkia( diff --git a/chrome/browser/ui/webui/extensions/extension_activity_ui.cc b/chrome/browser/ui/webui/extensions/extension_activity_ui.cc index dbcb6fa..1b8c517 100644 --- a/chrome/browser/ui/webui/extensions/extension_activity_ui.cc +++ b/chrome/browser/ui/webui/extensions/extension_activity_ui.cc @@ -69,7 +69,7 @@ void ExtensionActivityUI::HandleRequestExtensionData( GURL icon = ExtensionIconSource::GetIconURL(extension_, - Extension::EXTENSION_ICON_MEDIUM, + ExtensionIconSet::EXTENSION_ICON_MEDIUM, ExtensionIconSet::MATCH_BIGGER, false, NULL); diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index 802dbe8..0aa3066 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -62,7 +62,7 @@ struct ExtensionIconSource::ExtensionIconRequest { int request_id; const Extension* extension; bool grayscale; - Extension::Icons size; + int size; ExtensionIconSet::MatchType match; }; @@ -73,7 +73,7 @@ ExtensionIconSource::~ExtensionIconSource() { // static GURL ExtensionIconSource::GetIconURL(const Extension* extension, - Extension::Icons icon_size, + int icon_size, ExtensionIconSet::MatchType match, bool grayscale, bool* exists) { @@ -139,7 +139,7 @@ void ExtensionIconSource::LoadIconFailed(int request_id) { ExtensionResource icon = request->extension->GetIconResource(request->size, request->match); - if (request->size == Extension::EXTENSION_ICON_BITTY) + if (request->size == ExtensionIconSet::EXTENSION_ICON_BITTY) LoadFaviconImage(request_id); else LoadDefaultImage(request_id); @@ -300,14 +300,9 @@ bool ExtensionIconSource::ParseData(const std::string& path, std::string match_param = path_parts.at(2); match_param = match_param.substr(0, match_param.find('?')); - // The icon size and match types are encoded as string representations of - // their enum values, so to get the enum back, we read the string as an int - // and then cast to the enum. - Extension::Icons size; - int size_num; - if (!base::StringToInt(size_param, &size_num)) + int size; + if (!base::StringToInt(size_param, &size)) return false; - size = static_cast<Extension::Icons>(size_num); if (size <= 0) return false; @@ -344,7 +339,7 @@ void ExtensionIconSource::SendDefaultResponse(int request_id) { void ExtensionIconSource::SetData(int request_id, const Extension* extension, bool grayscale, - Extension::Icons size, + int size, ExtensionIconSet::MatchType match) { ExtensionIconRequest* request = new ExtensionIconRequest(); request->request_id = request_id; diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.h b/chrome/browser/ui/webui/extensions/extension_icon_source.h index c17c018..d790748c 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.h +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,7 +13,7 @@ #include "chrome/browser/extensions/image_loading_tracker.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "third_party/skia/include/core/SkBitmap.h" class ExtensionIconSet; @@ -51,13 +51,13 @@ class ExtensionIconSource : public ChromeURLDataManager::DataSource, explicit ExtensionIconSource(Profile* profile); virtual ~ExtensionIconSource(); - // Gets the URL of the |extension| icon in the given |size|, falling back + // Gets the URL of the |extension| icon in the given |icon_size|, falling back // based on the |match| type. If |grayscale|, the URL will be for the // desaturated version of the icon. |exists|, if non-NULL, will be set to true // if the icon exists; false if it will lead to a default or not-present // image. static GURL GetIconURL(const Extension* extension, - Extension::Icons icon_size, + int icon_size, ExtensionIconSet::MatchType match, bool grayscale, bool* exists); @@ -138,7 +138,7 @@ class ExtensionIconSource : public ChromeURLDataManager::DataSource, void SetData(int request_id, const Extension* extension, bool grayscale, - Extension::Icons size, + int size, ExtensionIconSet::MatchType match); // Returns the ExtensionIconRequest for the given |request_id|. diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 3c0513d..2b98929 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -108,13 +108,13 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension, // Instead of setting grayscale here, we do it in apps_page.js. GURL icon_big = ExtensionIconSource::GetIconURL(extension, - Extension::EXTENSION_ICON_LARGE, - ExtensionIconSet::MATCH_EXACTLY, + ExtensionIconSet::EXTENSION_ICON_LARGE, + ExtensionIconSet::MATCH_BIGGER, false, &icon_big_exists); bool icon_small_exists = true; GURL icon_small = ExtensionIconSource::GetIconURL(extension, - Extension::EXTENSION_ICON_BITTY, + ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_BIGGER, false, &icon_small_exists); diff --git a/chrome/browser/ui/webui/options/extension_settings_handler.cc b/chrome/browser/ui/webui/options/extension_settings_handler.cc index a23106f..128afb9 100644 --- a/chrome/browser/ui/webui/options/extension_settings_handler.cc +++ b/chrome/browser/ui/webui/options/extension_settings_handler.cc @@ -29,6 +29,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_view_type.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" @@ -653,7 +654,7 @@ DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( DictionaryValue* extension_data = new DictionaryValue(); GURL icon = ExtensionIconSource::GetIconURL(extension, - Extension::EXTENSION_ICON_MEDIUM, + ExtensionIconSet::EXTENSION_ICON_MEDIUM, ExtensionIconSet::MATCH_BIGGER, !enabled, NULL); extension_data->SetString("id", extension->id()); |