Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: chrome/browser/extensions/app_shortcut_manager.cc

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/app_shortcut_manager.h" 5 #include "chrome/browser/extensions/app_shortcut_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/extensions/image_loader.h" 12 #include "chrome/browser/extensions/image_loader.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/web_applications/web_app_ui.h" 14 #include "chrome/browser/ui/web_applications/web_app_ui.h"
15 #include "chrome/browser/web_applications/web_app.h" 15 #include "chrome/browser/web_applications/web_app.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/extensions/api/icons/icons_handler.h"
18 #include "chrome/common/extensions/extension_resource.h" 19 #include "chrome/common/extensions/extension_resource.h"
19 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
21 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
22 #include "skia/ext/image_operations.h" 23 #include "skia/ext/image_operations.h"
23 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
24 25
25 #if defined(OS_WIN) 26 #if defined(OS_WIN)
26 #include "chrome/browser/extensions/app_host_installer_win.h" 27 #include "chrome/browser/extensions/app_host_installer_win.h"
27 #include "chrome/installer/util/browser_distribution.h" 28 #include "chrome/installer/util/browser_distribution.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 112 }
112 #endif 113 #endif
113 114
114 void AppShortcutManager::UpdateApplicationShortcuts( 115 void AppShortcutManager::UpdateApplicationShortcuts(
115 const Extension* extension) { 116 const Extension* extension) {
116 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); 117 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_);
117 118
118 std::vector<ImageLoader::ImageRepresentation> info_list; 119 std::vector<ImageLoader::ImageRepresentation> info_list;
119 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { 120 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
120 int size = kDesiredSizes[i]; 121 int size = kDesiredSizes[i];
121 ExtensionResource resource = extension->GetIconResource( 122 ExtensionResource resource = IconsInfo::GetIconResource(
122 size, ExtensionIconSet::MATCH_EXACTLY); 123 extension, size, ExtensionIconSet::MATCH_EXACTLY);
123 if (!resource.empty()) { 124 if (!resource.empty()) {
124 info_list.push_back(ImageLoader::ImageRepresentation( 125 info_list.push_back(ImageLoader::ImageRepresentation(
125 resource, 126 resource,
126 ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, 127 ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER,
127 gfx::Size(size, size), 128 gfx::Size(size, size),
128 ui::SCALE_FACTOR_100P)); 129 ui::SCALE_FACTOR_100P));
129 } 130 }
130 } 131 }
131 132
132 if (info_list.empty()) { 133 if (info_list.empty()) {
133 size_t i = arraysize(kDesiredSizes) - 1; 134 size_t i = arraysize(kDesiredSizes) - 1;
134 int size = kDesiredSizes[i]; 135 int size = kDesiredSizes[i];
135 136
136 // If there is no icon at the desired sizes, we will resize what we can get. 137 // If there is no icon at the desired sizes, we will resize what we can get.
137 // Making a large icon smaller is preferred to making a small icon larger, 138 // Making a large icon smaller is preferred to making a small icon larger,
138 // so look for a larger icon first: 139 // so look for a larger icon first:
139 ExtensionResource resource = extension->GetIconResource( 140 ExtensionResource resource = IconsInfo::GetIconResource(
140 size, ExtensionIconSet::MATCH_BIGGER); 141 extension, size, ExtensionIconSet::MATCH_BIGGER);
141 if (resource.empty()) { 142 if (resource.empty()) {
142 resource = extension->GetIconResource( 143 resource = IconsInfo::GetIconResource(
143 size, ExtensionIconSet::MATCH_SMALLER); 144 extension, size, ExtensionIconSet::MATCH_SMALLER);
144 } 145 }
145 info_list.push_back(ImageLoader::ImageRepresentation( 146 info_list.push_back(ImageLoader::ImageRepresentation(
146 resource, 147 resource,
147 ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, 148 ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER,
148 gfx::Size(size, size), 149 gfx::Size(size, size),
149 ui::SCALE_FACTOR_100P)); 150 ui::SCALE_FACTOR_100P));
150 } 151 }
151 152
152 // |info_list| may still be empty at this point, in which case LoadImage 153 // |info_list| may still be empty at this point, in which case LoadImage
153 // will call the OnImageLoaded callback with an empty image and exit 154 // will call the OnImageLoaded callback with an empty image and exit
(...skipping 22 matching lines...) Expand all
176 } 177 }
177 178
178 void AppShortcutManager::DeleteApplicationShortcuts( 179 void AppShortcutManager::DeleteApplicationShortcuts(
179 const Extension* extension) { 180 const Extension* extension) {
180 ShellIntegration::ShortcutInfo delete_info = 181 ShellIntegration::ShortcutInfo delete_info =
181 ShortcutInfoForExtensionAndProfile(extension, profile_); 182 ShortcutInfoForExtensionAndProfile(extension, profile_);
182 web_app::DeleteAllShortcuts(delete_info); 183 web_app::DeleteAllShortcuts(delete_info);
183 } 184 }
184 185
185 } // namespace extensions 186 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698