| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 13 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 14 #include "chrome/browser/web_applications/web_app.h" | 14 #include "chrome/browser/web_applications/web_app.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 17 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
| 18 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 20 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 21 #include "skia/ext/image_operations.h" | 22 #include "skia/ext/image_operations.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 23 | 24 |
| 24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 25 #include "chrome/browser/extensions/app_host_installer_win.h" | 26 #include "chrome/browser/extensions/app_host_installer_win.h" |
| 26 #include "chrome/installer/util/browser_distribution.h" | 27 #include "chrome/installer/util/browser_distribution.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 132 } |
| 132 #endif | 133 #endif |
| 133 | 134 |
| 134 void AppShortcutManager::UpdateApplicationShortcuts( | 135 void AppShortcutManager::UpdateApplicationShortcuts( |
| 135 const Extension* extension) { | 136 const Extension* extension) { |
| 136 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); | 137 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); |
| 137 | 138 |
| 138 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; | 139 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; |
| 139 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { | 140 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { |
| 140 int size = kDesiredSizes[i]; | 141 int size = kDesiredSizes[i]; |
| 141 ExtensionResource resource = extension->GetIconResource( | 142 ExtensionResource resource = IconsInfo::GetIconResource( |
| 142 size, ExtensionIconSet::MATCH_EXACTLY); | 143 extension, size, ExtensionIconSet::MATCH_EXACTLY); |
| 143 if (!resource.empty()) { | 144 if (!resource.empty()) { |
| 144 info_list.push_back(ImageLoadingTracker::ImageRepresentation( | 145 info_list.push_back(ImageLoadingTracker::ImageRepresentation( |
| 145 resource, | 146 resource, |
| 146 ImageLoadingTracker::ImageRepresentation::RESIZE_WHEN_LARGER, | 147 ImageLoadingTracker::ImageRepresentation::RESIZE_WHEN_LARGER, |
| 147 gfx::Size(size, size), | 148 gfx::Size(size, size), |
| 148 ui::SCALE_FACTOR_100P)); | 149 ui::SCALE_FACTOR_100P)); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 | 152 |
| 152 if (info_list.empty()) { | 153 if (info_list.empty()) { |
| 153 size_t i = arraysize(kDesiredSizes) - 1; | 154 size_t i = arraysize(kDesiredSizes) - 1; |
| 154 int size = kDesiredSizes[i]; | 155 int size = kDesiredSizes[i]; |
| 155 | 156 |
| 156 // If there is no icon at the desired sizes, we will resize what we can get. | 157 // If there is no icon at the desired sizes, we will resize what we can get. |
| 157 // Making a large icon smaller is prefered to making a small icon larger, so | 158 // Making a large icon smaller is prefered to making a small icon larger, so |
| 158 // look for a larger icon first: | 159 // look for a larger icon first: |
| 159 ExtensionResource resource = extension->GetIconResource( | 160 ExtensionResource resource = IconsInfo::GetIconResource( |
| 160 size, ExtensionIconSet::MATCH_BIGGER); | 161 extension, size, ExtensionIconSet::MATCH_BIGGER); |
| 161 if (resource.empty()) { | 162 if (resource.empty()) { |
| 162 resource = extension->GetIconResource( | 163 resource = IconsInfo::GetIconResource( |
| 163 size, ExtensionIconSet::MATCH_SMALLER); | 164 extension, size, ExtensionIconSet::MATCH_SMALLER); |
| 164 } | 165 } |
| 165 info_list.push_back(ImageLoadingTracker::ImageRepresentation( | 166 info_list.push_back(ImageLoadingTracker::ImageRepresentation( |
| 166 resource, | 167 resource, |
| 167 ImageLoadingTracker::ImageRepresentation::RESIZE_WHEN_LARGER, | 168 ImageLoadingTracker::ImageRepresentation::RESIZE_WHEN_LARGER, |
| 168 gfx::Size(size, size), | 169 gfx::Size(size, size), |
| 169 ui::SCALE_FACTOR_100P)); | 170 ui::SCALE_FACTOR_100P)); |
| 170 } | 171 } |
| 171 | 172 |
| 172 // |icon_resources| may still be empty at this point, in which case LoadImage | 173 // |icon_resources| may still be empty at this point, in which case LoadImage |
| 173 // will call the OnImageLoaded callback with an empty image and exit | 174 // will call the OnImageLoaded callback with an empty image and exit |
| 174 // immediately. | 175 // immediately. |
| 175 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); | 176 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); |
| 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 |
| OLD | NEW |