| 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/webui/chrome_web_ui_controller_factory.h" | 5 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/about_flags.h" | 8 #include "chrome/browser/about_flags.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_web_ui.h" | 10 #include "chrome/browser/extensions/extension_web_ui.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "chrome/browser/ui/webui/tracing_ui.h" | 53 #include "chrome/browser/ui/webui/tracing_ui.h" |
| 54 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
| 55 #include "chrome/common/extensions/extension_constants.h" | 55 #include "chrome/common/extensions/extension_constants.h" |
| 56 #include "chrome/common/extensions/extension_switch_utils.h" | 56 #include "chrome/common/extensions/extension_switch_utils.h" |
| 57 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 58 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| 59 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 60 #include "content/public/browser/web_ui.h" | 60 #include "content/public/browser/web_ui.h" |
| 61 #include "content/public/common/content_client.h" | 61 #include "content/public/common/content_client.h" |
| 62 #include "googleurl/src/gurl.h" | 62 #include "googleurl/src/gurl.h" |
| 63 #include "ui/gfx/favicon_size.h" |
| 63 #include "ui/web_dialogs/constrained_web_dialog_ui.h" | 64 #include "ui/web_dialogs/constrained_web_dialog_ui.h" |
| 64 #include "ui/web_dialogs/web_dialog_ui.h" | 65 #include "ui/web_dialogs/web_dialog_ui.h" |
| 65 | 66 |
| 66 #if defined(OS_ANDROID) | 67 #if defined(OS_ANDROID) |
| 67 #include "chrome/browser/ui/webui/welcome_ui_android.h" | 68 #include "chrome/browser/ui/webui/welcome_ui_android.h" |
| 68 #else | 69 #else |
| 69 #include "chrome/browser/ui/webui/uber/uber_ui.h" | 70 #include "chrome/browser/ui/webui/uber/uber_ui.h" |
| 70 #endif | 71 #endif |
| 71 | 72 |
| 72 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 url.host() != extension_misc::kBookmarkManagerId) { | 482 url.host() != extension_misc::kBookmarkManagerId) { |
| 482 ExtensionWebUI::GetFaviconForURL(profile, request, url); | 483 ExtensionWebUI::GetFaviconForURL(profile, request, url); |
| 483 } else { | 484 } else { |
| 484 std::vector<history::FaviconBitmapResult> favicon_bitmap_results; | 485 std::vector<history::FaviconBitmapResult> favicon_bitmap_results; |
| 485 for (size_t i = 0; i < scale_factors.size(); ++i) { | 486 for (size_t i = 0; i < scale_factors.size(); ++i) { |
| 486 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( | 487 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( |
| 487 url, scale_factors[i])); | 488 url, scale_factors[i])); |
| 488 if (bitmap.get() && bitmap->size()) { | 489 if (bitmap.get() && bitmap->size()) { |
| 489 history::FaviconBitmapResult bitmap_result; | 490 history::FaviconBitmapResult bitmap_result; |
| 490 bitmap_result.bitmap_data = bitmap; | 491 bitmap_result.bitmap_data = bitmap; |
| 492 // Leave |bitmap_result|'s icon URL as the default of GURL(). |
| 491 bitmap_result.icon_type = history::FAVICON; | 493 bitmap_result.icon_type = history::FAVICON; |
| 492 favicon_bitmap_results.push_back(bitmap_result); | 494 favicon_bitmap_results.push_back(bitmap_result); |
| 495 |
| 496 // Assume that |bitmap| is |gfx::kFaviconSize| x |gfx::kFaviconSize| |
| 497 // DIP. |
| 498 float scale = ui::GetScaleFactorScale(scale_factors[i]); |
| 499 int edge_pixel_size = |
| 500 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); |
| 501 bitmap_result.pixel_size = gfx::Size(edge_pixel_size, edge_pixel_size); |
| 493 } | 502 } |
| 494 } | 503 } |
| 504 |
| 505 // Populate IconURLSizesMap such that the requirement that all the icon URLs |
| 506 // in |favicon_bitmap_results| be present in |icon_url_sizes| holds. |
| 507 // Populate the favicon sizes with the pixel sizes of the bitmaps available |
| 508 // for |url|. |
| 509 history::IconURLSizesMap icon_url_sizes; |
| 510 for (size_t i = 0; i < favicon_bitmap_results.size(); ++i) { |
| 511 const history::FaviconBitmapResult& bitmap_result = |
| 512 favicon_bitmap_results[i]; |
| 513 const GURL& icon_url = bitmap_result.icon_url; |
| 514 icon_url_sizes[icon_url].push_back(bitmap_result.pixel_size); |
| 515 } |
| 516 |
| 495 request->ForwardResultAsync(request->handle(), favicon_bitmap_results, | 517 request->ForwardResultAsync(request->handle(), favicon_bitmap_results, |
| 496 history::IconURLSizesMap()); | 518 icon_url_sizes); |
| 497 } | 519 } |
| 498 } | 520 } |
| 499 | 521 |
| 500 // static | 522 // static |
| 501 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { | 523 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { |
| 502 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< | 524 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< |
| 503 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); | 525 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); |
| 504 } | 526 } |
| 505 | 527 |
| 506 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { | 528 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 574 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
| 553 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); | 575 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); |
| 554 | 576 |
| 555 // Android doesn't use the plugins pages. | 577 // Android doesn't use the plugins pages. |
| 556 if (page_url.host() == chrome::kChromeUIPluginsHost) | 578 if (page_url.host() == chrome::kChromeUIPluginsHost) |
| 557 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 579 return PluginsUI::GetFaviconResourceBytes(scale_factor); |
| 558 #endif | 580 #endif |
| 559 | 581 |
| 560 return NULL; | 582 return NULL; |
| 561 } | 583 } |
| OLD | NEW |