| OLD | NEW |
| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/web_applications/web_app.h" | 10 #include "chrome/browser/web_applications/web_app.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 // static | 108 // static |
| 109 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { | 109 void AppShortcutManager::SetShortcutCreationDisabledForTesting(bool disabled) { |
| 110 disable_shortcut_creation_for_tests = disabled; | 110 disable_shortcut_creation_for_tests = disabled; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void AppShortcutManager::InstallApplicationShortcuts( | 113 void AppShortcutManager::InstallApplicationShortcuts( |
| 114 const Extension* extension) { | 114 const Extension* extension) { |
| 115 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); | 115 shortcut_info_ = ShortcutInfoForExtensionAndProfile(extension, profile_); |
| 116 std::vector<ImageLoadingTracker::ImageInfo> info_list; | 116 |
| 117 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; |
| 117 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { | 118 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { |
| 118 int size = kDesiredSizes[i]; | 119 int size = kDesiredSizes[i]; |
| 119 ExtensionResource resource = extension->GetIconResource( | 120 ExtensionResource resource = extension->GetIconResource( |
| 120 size, ExtensionIconSet::MATCH_EXACTLY); | 121 size, ExtensionIconSet::MATCH_EXACTLY); |
| 121 if (!resource.empty()) { | 122 if (!resource.empty()) { |
| 122 info_list.push_back( | 123 info_list.push_back(ImageLoadingTracker::ImageRepresentation( |
| 123 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); | 124 resource, |
| 125 ImageLoadingTracker::ImageRepresentation::RESIZE_WHEN_LARGER, |
| 126 gfx::Size(size, size), |
| 127 ui::SCALE_FACTOR_100P)); |
| 124 } | 128 } |
| 125 } | 129 } |
| 126 | 130 |
| 127 if (info_list.empty()) { | 131 if (info_list.empty()) { |
| 128 size_t i = arraysize(kDesiredSizes) - 1; | 132 size_t i = arraysize(kDesiredSizes) - 1; |
| 129 int size = kDesiredSizes[i]; | 133 int size = kDesiredSizes[i]; |
| 130 | 134 |
| 131 // If there is no icon at the desired sizes, we will resize what we can get. | 135 // If there is no icon at the desired sizes, we will resize what we can get. |
| 132 // Making a large icon smaller is prefered to making a small icon larger, so | 136 // Making a large icon smaller is prefered to making a small icon larger, so |
| 133 // look for a larger icon first: | 137 // look for a larger icon first: |
| 134 ExtensionResource resource = extension->GetIconResource( | 138 ExtensionResource resource = extension->GetIconResource( |
| 135 size, ExtensionIconSet::MATCH_BIGGER); | 139 size, ExtensionIconSet::MATCH_BIGGER); |
| 136 if (resource.empty()) { | 140 if (resource.empty()) { |
| 137 resource = extension->GetIconResource( | 141 resource = extension->GetIconResource( |
| 138 size, ExtensionIconSet::MATCH_SMALLER); | 142 size, ExtensionIconSet::MATCH_SMALLER); |
| 139 } | 143 } |
| 140 info_list.push_back( | 144 info_list.push_back(ImageLoadingTracker::ImageRepresentation( |
| 141 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); | 145 resource, |
| 146 ImageLoadingTracker::ImageRepresentation::RESIZE_WHEN_LARGER, |
| 147 gfx::Size(size, size), |
| 148 ui::SCALE_FACTOR_100P)); |
| 142 } | 149 } |
| 143 | 150 |
| 144 // |icon_resources| may still be empty at this point, in which case LoadImage | 151 // |icon_resources| may still be empty at this point, in which case LoadImage |
| 145 // will call the OnImageLoaded callback with an empty image and exit | 152 // will call the OnImageLoaded callback with an empty image and exit |
| 146 // immediately. | 153 // immediately. |
| 147 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); | 154 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); |
| 148 } | 155 } |
| 149 | 156 |
| 150 void AppShortcutManager::DeleteApplicationShortcuts( | 157 void AppShortcutManager::DeleteApplicationShortcuts( |
| 151 const Extension* extension) { | 158 const Extension* extension) { |
| 152 ShellIntegration::ShortcutInfo delete_info = | 159 ShellIntegration::ShortcutInfo delete_info = |
| 153 ShortcutInfoForExtensionAndProfile(extension, profile_); | 160 ShortcutInfoForExtensionAndProfile(extension, profile_); |
| 154 web_app::DeleteAllShortcuts(delete_info); | 161 web_app::DeleteAllShortcuts(delete_info); |
| 155 } | 162 } |
| OLD | NEW |