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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 // Only create ExtensionWebUI for URLs that are allowed extension bindings, | 131 // Only create ExtensionWebUI for URLs that are allowed extension bindings, |
132 // hosted by actual tabs. If there is no TabContents, it likely refers | 132 // hosted by actual tabs. If there is no TabContents, it likely refers |
133 // to another container type, like an extension background page. If there is | 133 // to another container type, like an extension background page. If there is |
134 // no WebUI (it's not accessible when calling GetWebUIType and related | 134 // no WebUI (it's not accessible when calling GetWebUIType and related |
135 // functions) then we conservatively assume that we need a WebUI. | 135 // functions) then we conservatively assume that we need a WebUI. |
136 bool NeedsExtensionWebUI(WebUI* web_ui, | 136 bool NeedsExtensionWebUI(WebUI* web_ui, |
137 Profile* profile, | 137 Profile* profile, |
138 const GURL& url) { | 138 const GURL& url) { |
| 139 #if defined(OS_ANDROID) |
| 140 // Chrome for Android doesn't have extensions. |
| 141 return false; |
| 142 #else |
139 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; | 143 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; |
140 return service && service->ExtensionBindingsAllowed(url) && | 144 return service && service->ExtensionBindingsAllowed(url) && |
141 (!web_ui || TabContents::FromWebContents(web_ui->GetWebContents())); | 145 (!web_ui || TabContents::FromWebContents(web_ui->GetWebContents())); |
| 146 #endif |
142 } | 147 } |
143 | 148 |
144 // Returns a function that can be used to create the right type of WebUI for a | 149 // Returns a function that can be used to create the right type of WebUI for a |
145 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated | 150 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated |
146 // with it. | 151 // with it. |
147 WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, | 152 WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, |
148 Profile* profile, | 153 Profile* profile, |
149 const GURL& url) { | 154 const GURL& url) { |
150 if (NeedsExtensionWebUI(web_ui, profile, url)) | 155 if (NeedsExtensionWebUI(web_ui, profile, url)) |
151 return &NewWebUI<ExtensionWebUI>; | 156 return &NewWebUI<ExtensionWebUI>; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } | 446 } |
442 | 447 |
443 void ChromeWebUIControllerFactory::GetFaviconForURL( | 448 void ChromeWebUIControllerFactory::GetFaviconForURL( |
444 Profile* profile, | 449 Profile* profile, |
445 FaviconService::GetFaviconRequest* request, | 450 FaviconService::GetFaviconRequest* request, |
446 const GURL& page_url) const { | 451 const GURL& page_url) const { |
447 // Before determining whether page_url is an extension url, we must handle | 452 // Before determining whether page_url is an extension url, we must handle |
448 // overrides. This changes urls in |kChromeUIScheme| to extension urls, and | 453 // overrides. This changes urls in |kChromeUIScheme| to extension urls, and |
449 // allows to use ExtensionWebUI::GetFaviconForURL. | 454 // allows to use ExtensionWebUI::GetFaviconForURL. |
450 GURL url(page_url); | 455 GURL url(page_url); |
| 456 #if !defined(OS_ANDROID) |
451 ExtensionWebUI::HandleChromeURLOverride(&url, profile); | 457 ExtensionWebUI::HandleChromeURLOverride(&url, profile); |
452 | 458 #endif |
453 // 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 |
454 // part of the manifest. | 460 // part of the manifest. |
455 if (url.SchemeIs(chrome::kExtensionScheme) && | 461 if (url.SchemeIs(chrome::kExtensionScheme) && |
456 url.host() != extension_misc::kBookmarkManagerId) { | 462 url.host() != extension_misc::kBookmarkManagerId) { |
457 ExtensionWebUI::GetFaviconForURL(profile, request, url); | 463 ExtensionWebUI::GetFaviconForURL(profile, request, url); |
458 } else { | 464 } else { |
459 history::FaviconData favicon; | 465 history::FaviconData favicon; |
460 favicon.image_data = scoped_refptr<base::RefCountedMemory>( | 466 favicon.image_data = scoped_refptr<base::RefCountedMemory>( |
461 GetFaviconResourceBytes(url)); | 467 GetFaviconResourceBytes(url)); |
462 favicon.known_icon = favicon.image_data.get() != NULL && | 468 favicon.known_icon = favicon.image_data.get() != NULL && |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 527 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
522 return options2::OptionsUI::GetFaviconResourceBytes(); | 528 return options2::OptionsUI::GetFaviconResourceBytes(); |
523 | 529 |
524 // Android doesn't use the plugins pages. | 530 // Android doesn't use the plugins pages. |
525 if (page_url.host() == chrome::kChromeUIPluginsHost) | 531 if (page_url.host() == chrome::kChromeUIPluginsHost) |
526 return PluginsUI::GetFaviconResourceBytes(); | 532 return PluginsUI::GetFaviconResourceBytes(); |
527 #endif | 533 #endif |
528 | 534 |
529 return NULL; | 535 return NULL; |
530 } | 536 } |
OLD | NEW |