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/ui/web_applications/web_app_ui.h" | 5 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 void UpdateShortcutInfoAndIconForApp( | 398 void UpdateShortcutInfoAndIconForApp( |
399 const extensions::Extension& extension, | 399 const extensions::Extension& extension, |
400 Profile* profile, | 400 Profile* profile, |
401 const web_app::ShortcutInfoCallback& callback) { | 401 const web_app::ShortcutInfoCallback& callback) { |
402 ShellIntegration::ShortcutInfo shortcut_info = | 402 ShellIntegration::ShortcutInfo shortcut_info = |
403 ShortcutInfoForExtensionAndProfile(&extension, profile); | 403 ShortcutInfoForExtensionAndProfile(&extension, profile); |
404 | 404 |
405 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; | 405 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; |
406 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { | 406 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { |
407 int size = kDesiredSizes[i]; | 407 int size = kDesiredSizes[i]; |
408 ExtensionResource resource = extensions::IconsInfo::GetIconResource( | 408 extensions::ExtensionResource resource = |
409 &extension, size, ExtensionIconSet::MATCH_EXACTLY); | 409 extensions::IconsInfo::GetIconResource( |
| 410 &extension, size, ExtensionIconSet::MATCH_EXACTLY); |
410 if (!resource.empty()) { | 411 if (!resource.empty()) { |
411 info_list.push_back(extensions::ImageLoader::ImageRepresentation( | 412 info_list.push_back(extensions::ImageLoader::ImageRepresentation( |
412 resource, | 413 resource, |
413 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, | 414 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, |
414 gfx::Size(size, size), | 415 gfx::Size(size, size), |
415 ui::SCALE_FACTOR_100P)); | 416 ui::SCALE_FACTOR_100P)); |
416 } | 417 } |
417 } | 418 } |
418 | 419 |
419 if (info_list.empty()) { | 420 if (info_list.empty()) { |
420 size_t i = arraysize(kDesiredSizes) - 1; | 421 size_t i = arraysize(kDesiredSizes) - 1; |
421 int size = kDesiredSizes[i]; | 422 int size = kDesiredSizes[i]; |
422 | 423 |
423 // If there is no icon at the desired sizes, we will resize what we can get. | 424 // If there is no icon at the desired sizes, we will resize what we can get. |
424 // Making a large icon smaller is preferred to making a small icon larger, | 425 // Making a large icon smaller is preferred to making a small icon larger, |
425 // so look for a larger icon first: | 426 // so look for a larger icon first: |
426 ExtensionResource resource = extensions::IconsInfo::GetIconResource( | 427 extensions::ExtensionResource resource = |
427 &extension, size, ExtensionIconSet::MATCH_BIGGER); | 428 extensions::IconsInfo::GetIconResource( |
| 429 &extension, size, ExtensionIconSet::MATCH_BIGGER); |
428 if (resource.empty()) { | 430 if (resource.empty()) { |
429 resource = extensions::IconsInfo::GetIconResource( | 431 resource = extensions::IconsInfo::GetIconResource( |
430 &extension, size, ExtensionIconSet::MATCH_SMALLER); | 432 &extension, size, ExtensionIconSet::MATCH_SMALLER); |
431 } | 433 } |
432 info_list.push_back(extensions::ImageLoader::ImageRepresentation( | 434 info_list.push_back(extensions::ImageLoader::ImageRepresentation( |
433 resource, | 435 resource, |
434 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, | 436 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, |
435 gfx::Size(size, size), | 437 gfx::Size(size, size), |
436 ui::SCALE_FACTOR_100P)); | 438 ui::SCALE_FACTOR_100P)); |
437 } | 439 } |
438 | 440 |
439 // |info_list| may still be empty at this point, in which case LoadImage | 441 // |info_list| may still be empty at this point, in which case LoadImage |
440 // will call the OnImageLoaded callback with an empty image and exit | 442 // will call the OnImageLoaded callback with an empty image and exit |
441 // immediately. | 443 // immediately. |
442 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, | 444 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, |
443 base::Bind(&OnImageLoaded, shortcut_info, callback)); | 445 base::Bind(&OnImageLoaded, shortcut_info, callback)); |
444 } | 446 } |
445 | 447 |
446 } // namespace web_app | 448 } // namespace web_app |
OLD | NEW |