| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 460 |
| 461 WebUIController* controller = (*function)(web_ui, url); | 461 WebUIController* controller = (*function)(web_ui, url); |
| 462 if (controller) | 462 if (controller) |
| 463 web_ui->AddMessageHandler(new GenericHandler()); | 463 web_ui->AddMessageHandler(new GenericHandler()); |
| 464 return controller; | 464 return controller; |
| 465 } | 465 } |
| 466 | 466 |
| 467 void ChromeWebUIControllerFactory::GetFaviconForURL( | 467 void ChromeWebUIControllerFactory::GetFaviconForURL( |
| 468 Profile* profile, | 468 Profile* profile, |
| 469 FaviconService::GetFaviconRequest* request, | 469 FaviconService::GetFaviconRequest* request, |
| 470 const GURL& page_url) const { | 470 const GURL& page_url, |
| 471 const std::vector<ui::ScaleFactor>& scale_factors) const { |
| 471 // Before determining whether page_url is an extension url, we must handle | 472 // Before determining whether page_url is an extension url, we must handle |
| 472 // overrides. This changes urls in |kChromeUIScheme| to extension urls, and | 473 // overrides. This changes urls in |kChromeUIScheme| to extension urls, and |
| 473 // allows to use ExtensionWebUI::GetFaviconForURL. | 474 // allows to use ExtensionWebUI::GetFaviconForURL. |
| 474 GURL url(page_url); | 475 GURL url(page_url); |
| 475 ExtensionWebUI::HandleChromeURLOverride(&url, profile); | 476 ExtensionWebUI::HandleChromeURLOverride(&url, profile); |
| 476 | 477 |
| 477 // All extensions but the bookmark manager get their favicon from the icons | 478 // All extensions but the bookmark manager get their favicon from the icons |
| 478 // part of the manifest. | 479 // part of the manifest. |
| 479 if (url.SchemeIs(chrome::kExtensionScheme) && | 480 if (url.SchemeIs(chrome::kExtensionScheme) && |
| 480 url.host() != extension_misc::kBookmarkManagerId) { | 481 url.host() != extension_misc::kBookmarkManagerId) { |
| 481 ExtensionWebUI::GetFaviconForURL(profile, request, url); | 482 ExtensionWebUI::GetFaviconForURL(profile, request, url); |
| 482 } else { | 483 } else { |
| 483 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( | |
| 484 url, ui::SCALE_FACTOR_100P)); | |
| 485 std::vector<history::FaviconBitmapResult> favicon_bitmap_results; | 484 std::vector<history::FaviconBitmapResult> favicon_bitmap_results; |
| 486 if (bitmap.get() && bitmap->size()) { | 485 for (size_t i = 0; i < scale_factors.size(); ++i) { |
| 487 history::FaviconBitmapResult bitmap_result; | 486 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( |
| 488 bitmap_result.bitmap_data = bitmap; | 487 url, scale_factors[i])); |
| 489 bitmap_result.icon_type = history::FAVICON; | 488 if (bitmap.get() && bitmap->size()) { |
| 490 favicon_bitmap_results.push_back(bitmap_result); | 489 history::FaviconBitmapResult bitmap_result; |
| 490 bitmap_result.bitmap_data = bitmap; |
| 491 bitmap_result.icon_type = history::FAVICON; |
| 492 favicon_bitmap_results.push_back(bitmap_result); |
| 493 } |
| 491 } | 494 } |
| 492 request->ForwardResultAsync(request->handle(), favicon_bitmap_results, | 495 request->ForwardResultAsync(request->handle(), favicon_bitmap_results, |
| 493 history::IconURLSizesMap()); | 496 history::IconURLSizesMap()); |
| 494 } | 497 } |
| 495 } | 498 } |
| 496 | 499 |
| 497 // static | 500 // static |
| 498 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { | 501 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { |
| 499 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< | 502 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< |
| 500 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); | 503 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 552 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
| 550 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); | 553 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); |
| 551 | 554 |
| 552 // Android doesn't use the plugins pages. | 555 // Android doesn't use the plugins pages. |
| 553 if (page_url.host() == chrome::kChromeUIPluginsHost) | 556 if (page_url.host() == chrome::kChromeUIPluginsHost) |
| 554 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 557 return PluginsUI::GetFaviconResourceBytes(scale_factor); |
| 555 #endif | 558 #endif |
| 556 | 559 |
| 557 return NULL; | 560 return NULL; |
| 558 } | 561 } |
| OLD | NEW |