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/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 WebUIController* controller = (*function)(web_ui, url); | 419 WebUIController* controller = (*function)(web_ui, url); |
420 if (controller) | 420 if (controller) |
421 web_ui->AddMessageHandler(new GenericHandler()); | 421 web_ui->AddMessageHandler(new GenericHandler()); |
422 return controller; | 422 return controller; |
423 } | 423 } |
424 | 424 |
425 void ChromeWebUIControllerFactory::GetFaviconForURL( | 425 void ChromeWebUIControllerFactory::GetFaviconForURL( |
426 Profile* profile, | 426 Profile* profile, |
427 FaviconService::GetFaviconRequest* request, | 427 FaviconService::GetFaviconRequest* request, |
428 const GURL& page_url) const { | 428 const GURL& page_url) const { |
429 // Before determining whether page_url is an extension url, we must handle | |
430 // overrides. This changes urls in |kChromeUIScheme| to extension urls, and | |
431 // allows to use ExtensionWebUI::GetFaviconForURL. | |
432 GURL url(page_url); | |
433 ExtensionWebUI::HandleChromeURLOverride(&url, profile); | |
434 | |
435 // All extensions but the bookmark manager get their favicon from the icons | 429 // All extensions but the bookmark manager get their favicon from the icons |
436 // part of the manifest. | 430 // part of the manifest. |
437 if (url.SchemeIs(chrome::kExtensionScheme) && | 431 if (page_url.SchemeIs(chrome::kExtensionScheme) && |
438 url.host() != extension_misc::kBookmarkManagerId) { | 432 page_url.host() != extension_misc::kBookmarkManagerId) { |
439 ExtensionWebUI::GetFaviconForURL(profile, request, url); | 433 ExtensionWebUI::GetFaviconForURL(profile, request, page_url); |
440 } else { | 434 } else { |
441 history::FaviconData favicon; | 435 history::FaviconData favicon; |
442 favicon.image_data = scoped_refptr<RefCountedMemory>( | 436 favicon.image_data = scoped_refptr<RefCountedMemory>( |
443 GetFaviconResourceBytes(url)); | 437 GetFaviconResourceBytes(page_url)); |
444 favicon.known_icon = favicon.image_data.get() != NULL && | 438 favicon.known_icon = favicon.image_data.get() != NULL && |
445 favicon.image_data->size() > 0; | 439 favicon.image_data->size() > 0; |
446 favicon.icon_type = history::FAVICON; | 440 favicon.icon_type = history::FAVICON; |
447 request->ForwardResultAsync(request->handle(), favicon); | 441 request->ForwardResultAsync(request->handle(), favicon); |
448 } | 442 } |
449 } | 443 } |
450 | 444 |
451 // static | 445 // static |
452 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { | 446 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { |
453 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< | 447 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 500 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
507 return options2::OptionsUI::GetFaviconResourceBytes(); | 501 return options2::OptionsUI::GetFaviconResourceBytes(); |
508 | 502 |
509 // Android doesn't use the plugins pages. | 503 // Android doesn't use the plugins pages. |
510 if (page_url.host() == chrome::kChromeUIPluginsHost) | 504 if (page_url.host() == chrome::kChromeUIPluginsHost) |
511 return PluginsUI::GetFaviconResourceBytes(); | 505 return PluginsUI::GetFaviconResourceBytes(); |
512 #endif | 506 #endif |
513 | 507 |
514 return NULL; | 508 return NULL; |
515 } | 509 } |
OLD | NEW |