| 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/extension_web_ui.h" | 5 #include "chrome/browser/extensions/extension_web_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" | 13 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/extension_tab_util.h" | 15 #include "chrome/browser/extensions/extension_tab_util.h" |
| 16 #include "chrome/browser/extensions/image_loader.h" | 16 #include "chrome/browser/extensions/image_loader.h" |
| 17 #include "chrome/browser/favicon/favicon_util.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 23 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
| 26 #include "chrome/common/extensions/extension_icon_set.h" | 27 #include "chrome/common/extensions/extension_icon_set.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 ForwardFaviconResult(request, gfx::Image()); | 408 ForwardFaviconResult(request, gfx::Image()); |
| 408 return; | 409 return; |
| 409 } | 410 } |
| 410 const Extension* extension = service->extensions()->GetByID(page_url.host()); | 411 const Extension* extension = service->extensions()->GetByID(page_url.host()); |
| 411 if (!extension) { | 412 if (!extension) { |
| 412 ForwardFaviconResult(request, gfx::Image()); | 413 ForwardFaviconResult(request, gfx::Image()); |
| 413 return; | 414 return; |
| 414 } | 415 } |
| 415 | 416 |
| 416 // Fetch resources for all supported scale factors for which there are | 417 // Fetch resources for all supported scale factors for which there are |
| 417 // resources. Load image reps for all supported scale factors immediately | 418 // resources. Load image reps for all supported scale factors (in addition to |
| 418 // instead of in an as needed fashion to be consistent with how favicons | 419 // 1x) immediately instead of in an as needed fashion to be consistent with |
| 419 // are requested for chrome:// and page URLs. | 420 // how favicons are requested for chrome:// and page URLs. |
| 420 const std::vector<ui::ScaleFactor>& scale_factors = | 421 const std::vector<ui::ScaleFactor>& scale_factors = |
| 421 ui::GetSupportedScaleFactors(); | 422 FaviconUtil::GetFaviconScaleFactors(); |
| 422 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; | 423 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; |
| 423 for (size_t i = 0; i < scale_factors.size(); ++i) { | 424 for (size_t i = 0; i < scale_factors.size(); ++i) { |
| 424 float scale = ui::GetScaleFactorScale(scale_factors[i]); | 425 float scale = ui::GetScaleFactorScale(scale_factors[i]); |
| 425 int pixel_size = static_cast<int>(gfx::kFaviconSize * scale); | 426 int pixel_size = static_cast<int>(gfx::kFaviconSize * scale); |
| 426 ExtensionResource icon_resource = | 427 ExtensionResource icon_resource = |
| 427 extension->GetIconResource(pixel_size, | 428 extension->GetIconResource(pixel_size, |
| 428 ExtensionIconSet::MATCH_BIGGER); | 429 ExtensionIconSet::MATCH_BIGGER); |
| 429 | 430 |
| 430 info_list.push_back( | 431 info_list.push_back( |
| 431 extensions::ImageLoader::ImageRepresentation( | 432 extensions::ImageLoader::ImageRepresentation( |
| 432 icon_resource, | 433 icon_resource, |
| 433 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 434 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
| 434 gfx::Size(pixel_size, pixel_size), | 435 gfx::Size(pixel_size, pixel_size), |
| 435 scale_factors[i])); | 436 scale_factors[i])); |
| 436 } | 437 } |
| 437 | 438 |
| 438 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 439 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
| 439 extension, info_list, | 440 extension, info_list, |
| 440 base::Bind(&ForwardFaviconResult, | 441 base::Bind(&ForwardFaviconResult, |
| 441 scoped_refptr<FaviconService::GetFaviconRequest>(request))); | 442 scoped_refptr<FaviconService::GetFaviconRequest>(request))); |
| 442 } | 443 } |
| OLD | NEW |