diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 08:50:56 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 08:50:56 +0000 |
commit | 7eb20e39b770ec5d8eb118133cfc5ed291be0e0e (patch) | |
tree | c47cb63b276f1b02b8c5aadc3d6fbcd4d620f33d | |
parent | 1788ebba6cc645af4bea3e84ef5ab2c178496a81 (diff) | |
download | chromium_src-7eb20e39b770ec5d8eb118133cfc5ed291be0e0e.zip chromium_src-7eb20e39b770ec5d8eb118133cfc5ed291be0e0e.tar.gz chromium_src-7eb20e39b770ec5d8eb118133cfc5ed291be0e0e.tar.bz2 |
Break src/extensions dependency on Chrome's theme_resources.h / .pak
* Move GetDefaultAppIcon and GetDefaultExtensionIcon out of src/extensions
into chrome/browser.
* Inline one call to GetDefaultAppIcon in src/apps
This requires a DEPS exception in src/apps for grit/theme_resources.h, but
that's better than having one in src/extensions (as src/apps is much higher
in the dependency tree).
No functional changes.
BUG=368334
TEST=Clean build of extensions_unittests succeeds, Chrome about:extensions still displays default icon for extension with no icon.
TBR=msw@chromium.org for mechanical namespace/include changes in chrome/browser/ui/views/
Review URL: https://codereview.chromium.org/259343002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267142 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 56 insertions, 51 deletions
@@ -24,6 +24,9 @@ include_rules = [ "+chrome/browser/sessions/session_id.h", "+chrome/common/chrome_switches.h", + # For default app icon. + "!grit/theme_resources.h", + # Pieces of the extensions system that need to move to src/extensions. # See http://crbug.com/162530 for details. "+chrome/browser/extensions/api/file_handlers/app_file_handler_util.h", @@ -33,7 +36,6 @@ include_rules = [ "+chrome/browser/extensions/suggest_permission_util.h", "+chrome/browser/extensions/unpacked_installer.h", "+chrome/common/extensions/api/app_window.h", - "+chrome/common/extensions/manifest_handlers/icons_handler.h", ] specific_include_rules = { diff --git a/apps/app_window.cc b/apps/app_window.cc index 0664548..cfb1213 100644 --- a/apps/app_window.cc +++ b/apps/app_window.cc @@ -40,7 +40,9 @@ #include "extensions/common/extension.h" #include "extensions/common/extension_messages.h" #include "extensions/common/manifest_handlers/icons_handler.h" +#include "grit/theme_resources.h" #include "third_party/skia/include/core/SkRegion.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/screen.h" #if !defined(OS_MACOSX) @@ -783,12 +785,15 @@ void AppWindow::UpdateExtensionAppIcon() { // Avoid using any previous app icons were being downloaded. image_loader_ptr_factory_.InvalidateWeakPtrs(); + const gfx::ImageSkia& default_icon = + *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + IDR_APP_DEFAULT_ICON); app_icon_image_.reset( new extensions::IconImage(browser_context(), extension(), extensions::IconsInfo::GetIcons(extension()), delegate_->PreferredIconSize(), - extensions::IconsInfo::GetDefaultAppIcon(), + default_icon, this)); // Triggers actual image loading with 1x resources. The 2x resource will diff --git a/apps/shell/app_shell.gyp b/apps/shell/app_shell.gyp index 720de6a..3e09a8f 100644 --- a/apps/shell/app_shell.gyp +++ b/apps/shell/app_shell.gyp @@ -14,8 +14,6 @@ # Need extension related resources in common_resources.pak and # renderer_resources_100_percent.pak '<(DEPTH)/chrome/chrome_resources.gyp:chrome_resources', - # Need app related resources in theme_resources_100_percent.pak - '<(DEPTH)/chrome/chrome_resources.gyp:theme_resources', # Need dev-tools related resources in shell_resources.pak and # devtools_resources.pak. '<(DEPTH)/content/content_shell_and_tests.gyp:generate_content_shell_resources', @@ -32,11 +30,9 @@ '<(SHARED_INTERMEDIATE_DIR)/chrome/common_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/chrome/extensions_api_resources.pak', # TODO(jamescook): Extract the extension/app related resources - # from generated_resources_en-US.pak and - # theme_resources_100_percent.pak. + # from generated_resources_en-US.pak. '<(SHARED_INTERMEDIATE_DIR)/chrome/generated_resources_en-US.pak', '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_100_percent.pak', - '<(SHARED_INTERMEDIATE_DIR)/chrome/theme_resources_100_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/content/shell_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/extensions/extensions_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings/app_locale_settings_en-US.pak', diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc index 2efd3ae..de83ec63 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc @@ -18,6 +18,7 @@ #include "chrome/browser/chromeos/app_mode/kiosk_app_data_delegate.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/extensions/webstore_data_fetcher.h" #include "chrome/browser/extensions/webstore_install_helper.h" @@ -403,7 +404,7 @@ void KioskAppData::OnExtensionIconLoaded(const gfx::Image& icon) { if (icon.IsEmpty()) { LOG(WARNING) << "Failed to load icon from installed app" << ", id=" << app_id_; - SetCache(name_, *extensions::IconsInfo::GetDefaultAppIcon().bitmap()); + SetCache(name_, *extensions::util::GetDefaultAppIcon().bitmap()); } else { SetCache(name_, icon.AsBitmap()); } diff --git a/chrome/browser/extensions/app_icon_loader_impl.cc b/chrome/browser/extensions/app_icon_loader_impl.cc index 99e8f49..e661fa5 100644 --- a/chrome/browser/extensions/app_icon_loader_impl.cc +++ b/chrome/browser/extensions/app_icon_loader_impl.cc @@ -60,7 +60,7 @@ void AppIconLoaderImpl::FetchImage(const std::string& id) { extension, extensions::IconsInfo::GetIcons(extension), icon_size_, - extensions::IconsInfo::GetDefaultAppIcon(), + extensions::util::GetDefaultAppIcon(), this); // |map_| takes ownership of |image|. map_[image] = id; diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc index 8626b11..ece2144 100644 --- a/chrome/browser/extensions/extension_disabled_ui.cc +++ b/chrome/browser/extensions/extension_disabled_ui.cc @@ -19,6 +19,7 @@ #include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_uninstall_dialog.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -204,8 +205,8 @@ ExtensionDisabledGlobalError::ExtensionDisabledGlobalError( icon_ = gfx::Image( gfx::ImageSkiaOperations::CreateResizedImage( extension_->is_app() ? - extensions::IconsInfo::GetDefaultAppIcon() : - extensions::IconsInfo::GetDefaultExtensionIcon(), + extensions::util::GetDefaultAppIcon() : + extensions::util::GetDefaultExtensionIcon(), skia::ImageOperations::RESIZE_BEST, gfx::Size(kIconSize, kIconSize))); } diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc index 4f0ef54..569124f 100644 --- a/chrome/browser/extensions/extension_install_prompt.cc +++ b/chrome/browser/extensions/extension_install_prompt.cc @@ -15,6 +15,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/extensions/bundle_installer.h" #include "chrome/browser/extensions/extension_install_ui.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" @@ -137,8 +138,8 @@ int GetSizeForMaxScaleFactor(int size_in_dip) { // pixel size under maximal supported scale factor. SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { const gfx::ImageSkia& image = is_app ? - extensions::IconsInfo::GetDefaultAppIcon() : - extensions::IconsInfo::GetDefaultExtensionIcon(); + extensions::util::GetDefaultAppIcon() : + extensions::util::GetDefaultExtensionIcon(); return image.GetRepresentation( gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); } diff --git a/chrome/browser/extensions/extension_storage_monitor.cc b/chrome/browser/extensions/extension_storage_monitor.cc index ae42ee6..1e3f09fa 100644 --- a/chrome/browser/extensions/extension_storage_monitor.cc +++ b/chrome/browser/extensions/extension_storage_monitor.cc @@ -287,8 +287,8 @@ void ExtensionStorageMonitor::OnImageLoaded( gfx::Image notification_image(image); if (notification_image.IsEmpty()) { notification_image = - extension->is_app() ? gfx::Image(IconsInfo::GetDefaultAppIcon()) - : gfx::Image(IconsInfo::GetDefaultExtensionIcon()); + extension->is_app() ? gfx::Image(util::GetDefaultAppIcon()) + : gfx::Image(util::GetDefaultExtensionIcon()); } scoped_ptr<message_center::Notification> notification; diff --git a/chrome/browser/extensions/extension_uninstall_dialog.cc b/chrome/browser/extensions/extension_uninstall_dialog.cc index dc792e2..8a3c9e8 100644 --- a/chrome/browser/extensions/extension_uninstall_dialog.cc +++ b/chrome/browser/extensions/extension_uninstall_dialog.cc @@ -9,6 +9,7 @@ #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/chrome_notification_types.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -40,8 +41,8 @@ int GetSizeForMaxScaleFactor(int size_in_dip) { // pixel size under maximal supported scale factor. SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { const gfx::ImageSkia& image = is_app ? - extensions::IconsInfo::GetDefaultAppIcon() : - extensions::IconsInfo::GetDefaultExtensionIcon(); + extensions::util::GetDefaultAppIcon() : + extensions::util::GetDefaultExtensionIcon(); return image.GetRepresentation( gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); } diff --git a/chrome/browser/extensions/extension_util.cc b/chrome/browser/extensions/extension_util.cc index 41d535d..35e60c1 100644 --- a/chrome/browser/extensions/extension_util.cc +++ b/chrome/browser/extensions/extension_util.cc @@ -22,6 +22,8 @@ #include "extensions/common/extension_icon_set.h" #include "extensions/common/manifest.h" #include "extensions/common/manifest_handlers/incognito_info.h" +#include "grit/theme_resources.h" +#include "ui/base/resource/resource_bundle.h" namespace extensions { namespace util { @@ -240,5 +242,15 @@ bool SiteHasIsolatedStorage(const GURL& extension_site_url, return false; } +const gfx::ImageSkia& GetDefaultAppIcon() { + return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + IDR_APP_DEFAULT_ICON); +} + +const gfx::ImageSkia& GetDefaultExtensionIcon() { + return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + IDR_EXTENSION_DEFAULT_ICON); +} + } // namespace util } // namespace extensions diff --git a/chrome/browser/extensions/extension_util.h b/chrome/browser/extensions/extension_util.h index fb3b7ae..5ffcb9e 100644 --- a/chrome/browser/extensions/extension_util.h +++ b/chrome/browser/extensions/extension_util.h @@ -18,6 +18,10 @@ namespace content { class BrowserContext; } +namespace gfx { +class ImageSkia; +} + namespace extensions { class Extension; @@ -91,6 +95,11 @@ bool HasIsolatedStorage(const ExtensionInfo& info); bool SiteHasIsolatedStorage(const GURL& extension_site_url, content::BrowserContext* context); +// Returns the default extension/app icon (for extensions or apps that don't +// have one). +const gfx::ImageSkia& GetDefaultExtensionIcon(); +const gfx::ImageSkia& GetDefaultAppIcon(); + } // namespace util } // namespace extensions diff --git a/chrome/browser/ui/app_list/extension_app_item.cc b/chrome/browser/ui/app_list/extension_app_item.cc index 530af6e..daf3b83 100644 --- a/chrome/browser/ui/app_list/extension_app_item.cc +++ b/chrome/browser/ui/app_list/extension_app_item.cc @@ -245,7 +245,7 @@ void ExtensionAppItem::LoadImage(const Extension* extension) { extension, extensions::IconsInfo::GetIcons(extension), extension_misc::EXTENSION_ICON_MEDIUM, - extensions::IconsInfo::GetDefaultAppIcon(), + extensions::util::GetDefaultAppIcon(), this)); UpdateIcon(); } diff --git a/chrome/browser/ui/app_list/search/app_result.cc b/chrome/browser/ui/app_list/search/app_result.cc index 7b4a190..247c828 100644 --- a/chrome/browser/ui/app_list/search/app_result.cc +++ b/chrome/browser/ui/app_list/search/app_result.cc @@ -48,7 +48,7 @@ AppResult::AppResult(Profile* profile, extension, extensions::IconsInfo::GetIcons(extension), extension_misc::EXTENSION_ICON_SMALL, - extensions::IconsInfo::GetDefaultAppIcon(), + extensions::util::GetDefaultAppIcon(), this)); UpdateIcon(); StartObservingInstall(); diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc index 22f758c..e744037 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc @@ -1714,7 +1714,7 @@ ash::ShelfID ChromeLauncherController::InsertAppLauncherItem( ash::ShelfItem item; item.type = shelf_item_type; - item.image = extensions::IconsInfo::GetDefaultAppIcon(); + item.image = extensions::util::GetDefaultAppIcon(); ash::ShelfItemStatus new_state = GetAppState(app_id); if (new_state != ash::STATUS_CLOSED) diff --git a/chrome/browser/ui/toolbar/origin_chip_info.cc b/chrome/browser/ui/toolbar/origin_chip_info.cc index 7506cd3..3026af8 100644 --- a/chrome/browser/ui/toolbar/origin_chip_info.cc +++ b/chrome/browser/ui/toolbar/origin_chip_info.cc @@ -9,6 +9,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/extensions/extension_icon_image.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/client_side_detection_host.h" #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" @@ -121,7 +122,7 @@ bool OriginChipInfo::Update(const content::WebContents* web_contents, extension, extensions::IconsInfo::GetIcons(extension), extension_misc::EXTENSION_ICON_BITTY, - extensions::IconsInfo::GetDefaultAppIcon(), + extensions::util::GetDefaultAppIcon(), owner_)); // Forces load of the image. diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.cc index 788c501..8775148 100644 --- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.cc +++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.cc @@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/profiles/profile.h" @@ -371,7 +372,7 @@ void AppInfoSummaryTab::LoadAppImageAsync() { void AppInfoSummaryTab::OnAppImageLoaded(const gfx::Image& image) { const SkBitmap* bitmap; if (image.IsEmpty()) { - bitmap = &extensions::IconsInfo::GetDefaultAppIcon() + bitmap = &extensions::util::GetDefaultAppIcon() .GetRepresentation(gfx::ImageSkia::GetMaxSupportedScale()) .sk_bitmap(); } else { diff --git a/chrome/browser/ui/views/location_bar/origin_chip_view.cc b/chrome/browser/ui/views/location_bar/origin_chip_view.cc index b841e95..dd6c82f 100644 --- a/chrome/browser/ui/views/location_bar/origin_chip_view.cc +++ b/chrome/browser/ui/views/location_bar/origin_chip_view.cc @@ -11,6 +11,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_icon_image.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" @@ -74,7 +75,7 @@ OriginChipExtensionIcon::OriginChipExtensionIcon( extension, extensions::IconsInfo::GetIcons(extension), extension_misc::EXTENSION_ICON_BITTY, - extensions::IconsInfo::GetDefaultAppIcon(), + extensions::util::GetDefaultAppIcon(), this)) { // Forces load of the image. icon_image_->image_skia().GetRepresentation(1.0f); diff --git a/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc b/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc index 5a97d72..4c62538 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc @@ -11,6 +11,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_icon_image.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" @@ -76,7 +77,7 @@ ToolbarOriginChipExtensionIcon::ToolbarOriginChipExtensionIcon( extension, extensions::IconsInfo::GetIcons(extension), extension_misc::EXTENSION_ICON_BITTY, - extensions::IconsInfo::GetDefaultAppIcon(), + extensions::util::GetDefaultAppIcon(), this)) { // Forces load of the image. icon_image_->image_skia().GetRepresentation(1.0f); diff --git a/extensions/DEPS b/extensions/DEPS index 00641a3..5d3a4d5 100644 --- a/extensions/DEPS +++ b/extensions/DEPS @@ -16,7 +16,6 @@ include_rules = [ "!chrome/renderer/extensions/extension_helper.h", "!grit/common_resources.h", "!grit/extensions_api_resources.h", - "!grit/theme_resources.h", ] specific_include_rules = { diff --git a/extensions/common/manifest_handlers/icons_handler.cc b/extensions/common/manifest_handlers/icons_handler.cc index ebc18be..518ff406 100644 --- a/extensions/common/manifest_handlers/icons_handler.cc +++ b/extensions/common/manifest_handlers/icons_handler.cc @@ -16,8 +16,6 @@ #include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_handler_helpers.h" #include "grit/extensions_strings.h" -#include "grit/theme_resources.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/size.h" namespace extensions { @@ -35,18 +33,6 @@ const ExtensionIconSet& IconsInfo::GetIcons(const Extension* extension) { } // static -const gfx::ImageSkia& IconsInfo::GetDefaultAppIcon() { - return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( - IDR_APP_DEFAULT_ICON); -} - -// static -const gfx::ImageSkia& IconsInfo::GetDefaultExtensionIcon() { - return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( - IDR_EXTENSION_DEFAULT_ICON); -} - -// static ExtensionResource IconsInfo::GetIconResource( const Extension* extension, int size, diff --git a/extensions/common/manifest_handlers/icons_handler.h b/extensions/common/manifest_handlers/icons_handler.h index 10a774f..3b8794d 100644 --- a/extensions/common/manifest_handlers/icons_handler.h +++ b/extensions/common/manifest_handlers/icons_handler.h @@ -14,10 +14,6 @@ class GURL; -namespace gfx { -class ImageSkia; -} - namespace extensions { struct IconsInfo : public Extension::ManifestData { @@ -27,11 +23,6 @@ struct IconsInfo : public Extension::ManifestData { // Return the icon set for the given |extension|. static const ExtensionIconSet& GetIcons(const Extension* extension); - // Returns the default extension/app icon (for extensions or apps that don't - // have one). - static const gfx::ImageSkia& GetDefaultExtensionIcon(); - static const gfx::ImageSkia& GetDefaultAppIcon(); - // Get an extension icon as a resource or URL. static ExtensionResource GetIconResource( const Extension* extension, diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index 43cf863..255a68f 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -15,9 +15,6 @@ # api resources compiled into the chrome resource bundle. # http://crbug.com/162530 '../chrome/chrome_resources.gyp:chrome_resources', - # Need default icons in theme_resources.grd - '../chrome/chrome_resources.gyp:theme_resources', - # TODO(tfarina): This dep here is for extensions/common/constants.* # We should find a way to compile this module within extensions_common. '../chrome/common_constants.gyp:common_constants', |