| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 shortcut_info_.create_on_desktop = true; | 90 shortcut_info_.create_on_desktop = true; |
| 91 shortcut_info_.profile_path = profile_->GetPath(); | 91 shortcut_info_.profile_path = profile_->GetPath(); |
| 92 | 92 |
| 93 std::vector<ImageLoadingTracker::ImageInfo> info_list; | 93 std::vector<ImageLoadingTracker::ImageInfo> info_list; |
| 94 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { | 94 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { |
| 95 int size = kDesiredSizes[i]; | 95 int size = kDesiredSizes[i]; |
| 96 ExtensionResource resource = extension->GetIconResource( | 96 ExtensionResource resource = extension->GetIconResource( |
| 97 size, ExtensionIconSet::MATCH_EXACTLY); | 97 size, ExtensionIconSet::MATCH_EXACTLY); |
| 98 if (!resource.empty()) { | 98 if (!resource.empty()) { |
| 99 info_list.push_back( | 99 info_list.push_back( |
| 100 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); | 100 ImageLoadingTracker::ImageInfo(resource, |
| 101 gfx::Size(size, size), |
| 102 ui::SCALE_FACTOR_NONE)); |
| 101 } | 103 } |
| 102 } | 104 } |
| 103 | 105 |
| 104 if (info_list.empty()) { | 106 if (info_list.empty()) { |
| 105 size_t i = arraysize(kDesiredSizes) - 1; | 107 size_t i = arraysize(kDesiredSizes) - 1; |
| 106 int size = kDesiredSizes[i]; | 108 int size = kDesiredSizes[i]; |
| 107 | 109 |
| 108 // If there is no icon at the desired sizes, we will resize what we can get. | 110 // If there is no icon at the desired sizes, we will resize what we can get. |
| 109 // Making a large icon smaller is prefered to making a small icon larger, so | 111 // Making a large icon smaller is prefered to making a small icon larger, so |
| 110 // look for a larger icon first: | 112 // look for a larger icon first: |
| 111 ExtensionResource resource = extension->GetIconResource( | 113 ExtensionResource resource = extension->GetIconResource( |
| 112 size, ExtensionIconSet::MATCH_BIGGER); | 114 size, ExtensionIconSet::MATCH_BIGGER); |
| 113 if (resource.empty()) { | 115 if (resource.empty()) { |
| 114 resource = extension->GetIconResource( | 116 resource = extension->GetIconResource( |
| 115 size, ExtensionIconSet::MATCH_SMALLER); | 117 size, ExtensionIconSet::MATCH_SMALLER); |
| 116 } | 118 } |
| 117 info_list.push_back( | 119 info_list.push_back( |
| 118 ImageLoadingTracker::ImageInfo(resource, gfx::Size(size, size))); | 120 ImageLoadingTracker::ImageInfo(resource, |
| 121 gfx::Size(size, size), |
| 122 ui::SCALE_FACTOR_NONE)); |
| 119 } | 123 } |
| 120 | 124 |
| 121 // |icon_resources| may still be empty at this point, in which case LoadImage | 125 // |icon_resources| may still be empty at this point, in which case LoadImage |
| 122 // will call the OnImageLoaded callback with an empty image and exit | 126 // will call the OnImageLoaded callback with an empty image and exit |
| 123 // immediately. | 127 // immediately. |
| 124 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); | 128 tracker_.LoadImages(extension, info_list, ImageLoadingTracker::DONT_CACHE); |
| 125 } | 129 } |
| OLD | NEW |