| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/dom_ui_factory.h" | 5 #include "chrome/browser/dom_ui/dom_ui_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/dom_ui/bookmarks_ui.h" | 9 #include "chrome/browser/dom_ui/bookmarks_ui.h" |
| 10 #include "chrome/browser/dom_ui/bug_report_ui.h" | 10 #include "chrome/browser/dom_ui/bug_report_ui.h" |
| 11 #include "chrome/browser/dom_ui/constrained_html_ui.h" | 11 #include "chrome/browser/dom_ui/constrained_html_ui.h" |
| 12 #include "chrome/browser/dom_ui/downloads_ui.h" | 12 #include "chrome/browser/dom_ui/downloads_ui.h" |
| 13 #include "chrome/browser/dom_ui/devtools_ui.h" | 13 #include "chrome/browser/dom_ui/devtools_ui.h" |
| 14 #include "chrome/browser/dom_ui/history_ui.h" | 14 #include "chrome/browser/dom_ui/history_ui.h" |
| 15 #include "chrome/browser/dom_ui/history2_ui.h" | 15 #include "chrome/browser/dom_ui/history2_ui.h" |
| 16 #include "chrome/browser/dom_ui/html_dialog_ui.h" | 16 #include "chrome/browser/dom_ui/html_dialog_ui.h" |
| 17 #include "chrome/browser/dom_ui/flags_ui.h" | 17 #include "chrome/browser/dom_ui/flags_ui.h" |
| 18 #include "chrome/browser/dom_ui/net_internals_ui.h" | 18 #include "chrome/browser/dom_ui/net_internals_ui.h" |
| 19 #include "chrome/browser/dom_ui/new_tab_ui.h" | 19 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 20 #include "chrome/browser/dom_ui/plugins_ui.h" | 20 #include "chrome/browser/dom_ui/plugins_ui.h" |
| 21 #include "chrome/browser/dom_ui/print_preview_ui.h" | 21 #include "chrome/browser/dom_ui/print_preview_ui.h" |
| 22 #include "chrome/browser/dom_ui/remoting_ui.h" | 22 #include "chrome/browser/dom_ui/remoting_ui.h" |
| 23 #include "chrome/browser/dom_ui/options/options_ui.h" | 23 #include "chrome/browser/dom_ui/options/options_ui.h" |
| 24 #include "chrome/browser/dom_ui/slideshow_ui.h" | 24 #include "chrome/browser/dom_ui/slideshow_ui.h" |
| 25 #include "chrome/browser/dom_ui/textfields_ui.h" | 25 #include "chrome/browser/dom_ui/textfields_ui.h" |
| 26 #include "chrome/browser/extensions/extension_dom_ui.h" | 26 #include "chrome/browser/extensions/extension_dom_ui.h" |
| 27 #include "chrome/browser/extensions/extensions_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 28 #include "chrome/browser/extensions/extensions_ui.h" | 28 #include "chrome/browser/extensions/extensions_ui.h" |
| 29 #include "chrome/browser/printing/print_dialog_cloud.h" | 29 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/tab_contents/tab_contents.h" | 31 #include "chrome/browser/tab_contents/tab_contents.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/extensions/extension_constants.h" | 33 #include "chrome/common/extensions/extension_constants.h" |
| 34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 35 #include "googleurl/src/gurl.h" | 35 #include "googleurl/src/gurl.h" |
| 36 | 36 |
| 37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 67 template<class T> | 67 template<class T> |
| 68 DOMUI* NewDOMUI(TabContents* contents, const GURL& url) { | 68 DOMUI* NewDOMUI(TabContents* contents, const GURL& url) { |
| 69 return new T(contents); | 69 return new T(contents); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Special case for extensions. | 72 // Special case for extensions. |
| 73 template<> | 73 template<> |
| 74 DOMUI* NewDOMUI<ExtensionDOMUI>(TabContents* contents, const GURL& url) { | 74 DOMUI* NewDOMUI<ExtensionDOMUI>(TabContents* contents, const GURL& url) { |
| 75 // Don't use a DOMUI for incognito tabs because we require extensions to run | 75 // Don't use a DOMUI for incognito tabs because we require extensions to run |
| 76 // within a single process. | 76 // within a single process. |
| 77 ExtensionsService* service = contents->profile()->GetExtensionsService(); | 77 ExtensionService* service = contents->profile()->GetExtensionService(); |
| 78 if (service && | 78 if (service && |
| 79 service->ExtensionBindingsAllowed(url)) { | 79 service->ExtensionBindingsAllowed(url)) { |
| 80 return new ExtensionDOMUI(contents, url); | 80 return new ExtensionDOMUI(contents, url); |
| 81 } | 81 } |
| 82 return NULL; | 82 return NULL; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Returns a function that can be used to create the right type of DOMUI for a | 85 // Returns a function that can be used to create the right type of DOMUI for a |
| 86 // tab, based on its URL. Returns NULL if the URL doesn't have DOMUI associated | 86 // tab, based on its URL. Returns NULL if the URL doesn't have DOMUI associated |
| 87 // with it. Even if the factory function is valid, it may yield a NULL DOMUI | 87 // with it. Even if the factory function is valid, it may yield a NULL DOMUI |
| 88 // when invoked for a particular tab - see NewDOMUI<ExtensionDOMUI>. | 88 // when invoked for a particular tab - see NewDOMUI<ExtensionDOMUI>. |
| 89 static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile, | 89 static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile, |
| 90 const GURL& url) { | 90 const GURL& url) { |
| 91 // Currently, any gears: URL means an HTML dialog. | 91 // Currently, any gears: URL means an HTML dialog. |
| 92 if (url.SchemeIs(chrome::kGearsScheme)) | 92 if (url.SchemeIs(chrome::kGearsScheme)) |
| 93 return &NewDOMUI<HtmlDialogUI>; | 93 return &NewDOMUI<HtmlDialogUI>; |
| 94 | 94 |
| 95 if (url.host() == chrome::kChromeUIDialogHost) | 95 if (url.host() == chrome::kChromeUIDialogHost) |
| 96 return &NewDOMUI<ConstrainedHtmlUI>; | 96 return &NewDOMUI<ConstrainedHtmlUI>; |
| 97 | 97 |
| 98 ExtensionsService* service = profile->GetExtensionsService(); | 98 ExtensionService* service = profile->GetExtensionService(); |
| 99 if (service && service->ExtensionBindingsAllowed(url)) | 99 if (service && service->ExtensionBindingsAllowed(url)) |
| 100 return &NewDOMUI<ExtensionDOMUI>; | 100 return &NewDOMUI<ExtensionDOMUI>; |
| 101 | 101 |
| 102 // All platform builds of Chrome will need to have a cloud printing | 102 // All platform builds of Chrome will need to have a cloud printing |
| 103 // dialog as backup. It's just that on Chrome OS, it's the only | 103 // dialog as backup. It's just that on Chrome OS, it's the only |
| 104 // print dialog. | 104 // print dialog. |
| 105 if (url.host() == chrome::kCloudPrintResourcesHost) | 105 if (url.host() == chrome::kCloudPrintResourcesHost) |
| 106 return &NewDOMUI<ExternalHtmlDialogUI>; | 106 return &NewDOMUI<ExternalHtmlDialogUI>; |
| 107 | 107 |
| 108 // This will get called a lot to check all URLs, so do a quick check of other | 108 // This will get called a lot to check all URLs, so do a quick check of other |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 if (page_url.host() == chrome::kChromeUIPluginsHost) | 323 if (page_url.host() == chrome::kChromeUIPluginsHost) |
| 324 return PluginsUI::GetFaviconResourceBytes(); | 324 return PluginsUI::GetFaviconResourceBytes(); |
| 325 | 325 |
| 326 #if defined(ENABLE_REMOTING) | 326 #if defined(ENABLE_REMOTING) |
| 327 if (page_url.host() == chrome::kChromeUIRemotingHost) | 327 if (page_url.host() == chrome::kChromeUIRemotingHost) |
| 328 return RemotingUI::GetFaviconResourceBytes(); | 328 return RemotingUI::GetFaviconResourceBytes(); |
| 329 #endif | 329 #endif |
| 330 | 330 |
| 331 return NULL; | 331 return NULL; |
| 332 } | 332 } |
| OLD | NEW |