Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/extensions/extension_web_ui.h" | 11 #include "chrome/browser/extensions/extension_web_ui.h" |
| 12 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/printing/print_preview_tab_controller.h" | 14 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/ui/webui/about_ui.h" | 18 #include "chrome/browser/ui/webui/about_ui.h" |
| 19 #include "chrome/browser/ui/webui/bookmarks_ui.h" | 19 #include "chrome/browser/ui/webui/bookmarks_ui.h" |
| 20 #include "chrome/browser/ui/webui/crashes_ui.h" | 20 #include "chrome/browser/ui/webui/crashes_ui.h" |
| 21 #include "chrome/browser/ui/webui/devtools_ui.h" | 21 #include "chrome/browser/ui/webui/devtools_ui.h" |
| 22 #include "chrome/browser/ui/webui/downloads_ui.h" | 22 #include "chrome/browser/ui/webui/downloads_ui.h" |
| 23 #include "chrome/browser/ui/webui/extensions/extension_activity_ui.h" | 23 #include "chrome/browser/ui/webui/extensions/extension_activity_ui.h" |
| 24 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" | 24 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" |
| 25 #include "chrome/browser/ui/webui/feedback_ui.h" | 25 #include "chrome/browser/ui/webui/feedback_ui.h" |
| 26 #include "chrome/browser/ui/webui/flags_ui.h" | 26 #include "chrome/browser/ui/webui/flags_ui.h" |
| 27 #include "chrome/browser/ui/webui/flash_ui.h" | 27 #include "chrome/browser/ui/webui/flash_ui.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 return new ExtensionWebUI(web_ui, url); | 109 return new ExtensionWebUI(web_ui, url); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Special case for older about: handlers. | 112 // Special case for older about: handlers. |
| 113 template<> | 113 template<> |
| 114 WebUIController* NewWebUI<AboutUI>(WebUI* web_ui, const GURL& url) { | 114 WebUIController* NewWebUI<AboutUI>(WebUI* web_ui, const GURL& url) { |
| 115 return new AboutUI(web_ui, url.host()); | 115 return new AboutUI(web_ui, url.host()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Only create ExtensionWebUI for URLs that are allowed extension bindings, | 118 // Only create ExtensionWebUI for URLs that are allowed extension bindings, |
| 119 // hosted by actual tabs. If tab_contents has no wrapper, it likely refers | 119 // hosted by actual tabs. If there is no TabContents, it likely refers |
| 120 // to another container type, like an extension background page. If there is | 120 // to another container type, like an extension background page. If there is |
| 121 // no WebUI (it's not accessible when calling GetWebUIType and related | 121 // no WebUI (it's not accessible when calling GetWebUIType and related |
| 122 // functions) then we conservatively assume that we need a WebUI. | 122 // functions) then we conservatively assume that we need a WebUI. |
| 123 bool NeedsExtensionWebUI(WebUI* web_ui, | 123 bool NeedsExtensionWebUI(WebUI* web_ui, |
| 124 Profile* profile, | 124 Profile* profile, |
| 125 const GURL& url) { | 125 const GURL& url) { |
| 126 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; | 126 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; |
| 127 return service && service->ExtensionBindingsAllowed(url) && | 127 return service && service->ExtensionBindingsAllowed(url) && |
| 128 (!web_ui || | 128 (!web_ui || |
|
Evan Stade
2012/06/11 23:33:23
no wrap
| |
| 129 TabContentsWrapper::GetCurrentWrapperForContents( | 129 TabContents::FromWebContents(web_ui->GetWebContents())); |
| 130 web_ui->GetWebContents())); | |
| 131 } | 130 } |
| 132 | 131 |
| 133 // Returns a function that can be used to create the right type of WebUI for a | 132 // Returns a function that can be used to create the right type of WebUI for a |
| 134 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated | 133 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated |
| 135 // with it. | 134 // with it. |
| 136 WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, | 135 WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, |
| 137 Profile* profile, | 136 Profile* profile, |
| 138 const GURL& url) { | 137 const GURL& url) { |
| 139 if (NeedsExtensionWebUI(web_ui, profile, url)) | 138 if (NeedsExtensionWebUI(web_ui, profile, url)) |
| 140 return &NewWebUI<ExtensionWebUI>; | 139 return &NewWebUI<ExtensionWebUI>; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 501 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
| 503 return options2::OptionsUI::GetFaviconResourceBytes(); | 502 return options2::OptionsUI::GetFaviconResourceBytes(); |
| 504 | 503 |
| 505 // Android doesn't use the plugins pages. | 504 // Android doesn't use the plugins pages. |
| 506 if (page_url.host() == chrome::kChromeUIPluginsHost) | 505 if (page_url.host() == chrome::kChromeUIPluginsHost) |
| 507 return PluginsUI::GetFaviconResourceBytes(); | 506 return PluginsUI::GetFaviconResourceBytes(); |
| 508 #endif | 507 #endif |
| 509 | 508 |
| 510 return NULL; | 509 return NULL; |
| 511 } | 510 } |
| OLD | NEW |