| 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" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/extensions/image_loader.h" | 13 #include "chrome/browser/extensions/image_loader.h" |
| 14 #include "chrome/browser/extensions/tab_helper.h" | 14 #include "chrome/browser/extensions/tab_helper.h" |
| 15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 16 #include "chrome/browser/favicon/favicon_util.h" | 16 #include "chrome/browser/favicon/favicon_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/web_applications/web_app.h" | 18 #include "chrome/browser/web_applications/web_app.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 20 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 26 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 27 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 28 #include "skia/ext/image_operations.h" | 29 #include "skia/ext/image_operations.h" |
| 29 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 void UpdateShortcutInfoAndIconForApp( | 407 void UpdateShortcutInfoAndIconForApp( |
| 407 const extensions::Extension& extension, | 408 const extensions::Extension& extension, |
| 408 Profile* profile, | 409 Profile* profile, |
| 409 const web_app::ShortcutInfoCallback& callback) { | 410 const web_app::ShortcutInfoCallback& callback) { |
| 410 ShellIntegration::ShortcutInfo shortcut_info = | 411 ShellIntegration::ShortcutInfo shortcut_info = |
| 411 ShortcutInfoForExtensionAndProfile(&extension, profile); | 412 ShortcutInfoForExtensionAndProfile(&extension, profile); |
| 412 | 413 |
| 413 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; | 414 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; |
| 414 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { | 415 for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) { |
| 415 int size = kDesiredSizes[i]; | 416 int size = kDesiredSizes[i]; |
| 416 ExtensionResource resource = extension.GetIconResource( | 417 ExtensionResource resource = extensions::IconsInfo::GetIconResource( |
| 417 size, ExtensionIconSet::MATCH_EXACTLY); | 418 &extension, size, ExtensionIconSet::MATCH_EXACTLY); |
| 418 if (!resource.empty()) { | 419 if (!resource.empty()) { |
| 419 info_list.push_back(extensions::ImageLoader::ImageRepresentation( | 420 info_list.push_back(extensions::ImageLoader::ImageRepresentation( |
| 420 resource, | 421 resource, |
| 421 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, | 422 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, |
| 422 gfx::Size(size, size), | 423 gfx::Size(size, size), |
| 423 ui::SCALE_FACTOR_100P)); | 424 ui::SCALE_FACTOR_100P)); |
| 424 } | 425 } |
| 425 } | 426 } |
| 426 | 427 |
| 427 if (info_list.empty()) { | 428 if (info_list.empty()) { |
| 428 size_t i = arraysize(kDesiredSizes) - 1; | 429 size_t i = arraysize(kDesiredSizes) - 1; |
| 429 int size = kDesiredSizes[i]; | 430 int size = kDesiredSizes[i]; |
| 430 | 431 |
| 431 // If there is no icon at the desired sizes, we will resize what we can get. | 432 // If there is no icon at the desired sizes, we will resize what we can get. |
| 432 // Making a large icon smaller is preferred to making a small icon larger, | 433 // Making a large icon smaller is preferred to making a small icon larger, |
| 433 // so look for a larger icon first: | 434 // so look for a larger icon first: |
| 434 ExtensionResource resource = extension.GetIconResource( | 435 ExtensionResource resource = extensions::IconsInfo::GetIconResource( |
| 435 size, ExtensionIconSet::MATCH_BIGGER); | 436 &extension, size, ExtensionIconSet::MATCH_BIGGER); |
| 436 if (resource.empty()) { | 437 if (resource.empty()) { |
| 437 resource = extension.GetIconResource( | 438 resource = extensions::IconsInfo::GetIconResource( |
| 438 size, ExtensionIconSet::MATCH_SMALLER); | 439 &extension, size, ExtensionIconSet::MATCH_SMALLER); |
| 439 } | 440 } |
| 440 info_list.push_back(extensions::ImageLoader::ImageRepresentation( | 441 info_list.push_back(extensions::ImageLoader::ImageRepresentation( |
| 441 resource, | 442 resource, |
| 442 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, | 443 extensions::ImageLoader::ImageRepresentation::RESIZE_WHEN_LARGER, |
| 443 gfx::Size(size, size), | 444 gfx::Size(size, size), |
| 444 ui::SCALE_FACTOR_100P)); | 445 ui::SCALE_FACTOR_100P)); |
| 445 } | 446 } |
| 446 | 447 |
| 447 // |info_list| may still be empty at this point, in which case LoadImage | 448 // |info_list| may still be empty at this point, in which case LoadImage |
| 448 // will call the OnImageLoaded callback with an empty image and exit | 449 // will call the OnImageLoaded callback with an empty image and exit |
| 449 // immediately. | 450 // immediately. |
| 450 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, | 451 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, |
| 451 base::Bind(&OnImageLoaded, shortcut_info, callback)); | 452 base::Bind(&OnImageLoaded, shortcut_info, callback)); |
| 452 } | 453 } |
| 453 | 454 |
| 454 } // namespace web_app | 455 } // namespace web_app |
| OLD | NEW |