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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // allows to use ExtensionWebUI::GetFaviconForURL. | 455 // allows to use ExtensionWebUI::GetFaviconForURL. |
456 GURL url(page_url); | 456 GURL url(page_url); |
457 ExtensionWebUI::HandleChromeURLOverride(&url, profile); | 457 ExtensionWebUI::HandleChromeURLOverride(&url, profile); |
458 | 458 |
459 // All extensions but the bookmark manager get their favicon from the icons | 459 // All extensions but the bookmark manager get their favicon from the icons |
460 // part of the manifest. | 460 // part of the manifest. |
461 if (url.SchemeIs(chrome::kExtensionScheme) && | 461 if (url.SchemeIs(chrome::kExtensionScheme) && |
462 url.host() != extension_misc::kBookmarkManagerId) { | 462 url.host() != extension_misc::kBookmarkManagerId) { |
463 ExtensionWebUI::GetFaviconForURL(profile, request, url); | 463 ExtensionWebUI::GetFaviconForURL(profile, request, url); |
464 } else { | 464 } else { |
465 history::FaviconData favicon; | 465 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes(url)); |
466 favicon.image_data = scoped_refptr<base::RefCountedMemory>( | 466 bool bitmap_valid = bitmap.get() != NULL && bitmap->size() > 0; |
467 GetFaviconResourceBytes(url)); | 467 history::FaviconData favicon_data; |
468 favicon.known_icon = favicon.image_data.get() != NULL && | 468 favicon_data.known_icon = bitmap_valid; |
469 favicon.image_data->size() > 0; | 469 favicon_data.icon_type = history::FAVICON; |
470 favicon.icon_type = history::FAVICON; | 470 if (bitmap_valid) { |
471 request->ForwardResultAsync(request->handle(), favicon); | 471 history::FaviconDataElement element; |
| 472 element.bitmap_data = bitmap; |
| 473 element.pixel_size = gfx::Size(); |
| 474 favicon_data.elements.push_back(element); |
| 475 } |
| 476 request->ForwardResultAsync(request->handle(), favicon_data); |
472 } | 477 } |
473 } | 478 } |
474 | 479 |
475 // static | 480 // static |
476 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { | 481 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { |
477 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< | 482 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< |
478 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); | 483 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); |
479 } | 484 } |
480 | 485 |
481 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { | 486 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 532 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
528 return options2::OptionsUI::GetFaviconResourceBytes(); | 533 return options2::OptionsUI::GetFaviconResourceBytes(); |
529 | 534 |
530 // Android doesn't use the plugins pages. | 535 // Android doesn't use the plugins pages. |
531 if (page_url.host() == chrome::kChromeUIPluginsHost) | 536 if (page_url.host() == chrome::kChromeUIPluginsHost) |
532 return PluginsUI::GetFaviconResourceBytes(); | 537 return PluginsUI::GetFaviconResourceBytes(); |
533 #endif | 538 #endif |
534 | 539 |
535 return NULL; | 540 return NULL; |
536 } | 541 } |
OLD | NEW |