| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/dom_ui/downloads_ui.h" | 7 #include "chrome/browser/dom_ui/downloads_ui.h" |
| 8 #include "chrome/browser/dom_ui/devtools_ui.h" | 8 #include "chrome/browser/dom_ui/devtools_ui.h" |
| 9 #include "chrome/browser/dom_ui/history_ui.h" | 9 #include "chrome/browser/dom_ui/history_ui.h" |
| 10 #include "chrome/browser/dom_ui/html_dialog_ui.h" | 10 #include "chrome/browser/dom_ui/html_dialog_ui.h" |
| 11 #include "chrome/browser/dom_ui/new_tab_ui.h" | 11 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 12 #include "chrome/browser/extensions/extensions_ui.h" | 12 #include "chrome/browser/extensions/extensions_ui.h" |
| 13 #include "chrome/browser/extensions/extension_dom_ui.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #ifdef CHROME_PERSONALIZATION | 15 #ifdef CHROME_PERSONALIZATION |
| 15 #include "chrome/personalization/personalization.h" | 16 #include "chrome/personalization/personalization.h" |
| 16 #endif | 17 #endif |
| 17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 18 | 19 |
| 19 // Backend for both querying for and creating new DOMUI objects. If you're just | 20 // Backend for both querying for and creating new DOMUI objects. If you're just |
| 20 // querying whether there's a DOM UI for the given URL, pass NULL for both the | 21 // querying whether there's a DOM UI for the given URL, pass NULL for both the |
| 21 // web contents and the new_ui. The return value will indiacate whether a DOM UI | 22 // web contents and the new_ui. The return value will indiacate whether a DOM UI |
| 22 // exists for the given URL. | 23 // exists for the given URL. |
| 23 // | 24 // |
| 24 // If you want to create a DOM UI, pass non-NULL pointers for both tab_contents | 25 // If you want to create a DOM UI, pass non-NULL pointers for both tab_contents |
| 25 // and new_ui. The *new_ui pointer will be filled with the created UI if it | 26 // and new_ui. The *new_ui pointer will be filled with the created UI if it |
| 26 // succeeds (indicated by a return value of true). The caller owns the *new_ui | 27 // succeeds (indicated by a return value of true). The caller owns the *new_ui |
| 27 // pointer. | 28 // pointer. |
| 28 static bool CreateDOMUI(const GURL& url, TabContents* tab_contents, | 29 static bool CreateDOMUI(const GURL& url, TabContents* tab_contents, |
| 29 DOMUI** new_ui) { | 30 DOMUI** new_ui) { |
| 30 // Currently, any gears: URL means an HTML dialog. | 31 // Currently, any gears: URL means an HTML dialog. |
| 31 if (url.SchemeIs(chrome::kGearsScheme)) { | 32 if (url.SchemeIs(chrome::kGearsScheme)) { |
| 32 if (new_ui) | 33 if (new_ui) |
| 33 *new_ui = new HtmlDialogUI(tab_contents); | 34 *new_ui = new HtmlDialogUI(tab_contents); |
| 34 return true; | 35 return true; |
| 35 } | 36 } |
| 36 | 37 |
| 38 if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 39 if (new_ui) |
| 40 *new_ui = new ExtensionDOMUI(tab_contents); |
| 41 return true; |
| 42 } |
| 43 |
| 37 #ifdef CHROME_PERSONALIZATION | 44 #ifdef CHROME_PERSONALIZATION |
| 38 if (Personalization::NeedsDOMUI(url)) { | 45 if (Personalization::NeedsDOMUI(url)) { |
| 39 if (new_ui) | 46 if (new_ui) |
| 40 *new_ui = new HtmlDialogUI(tab_contents); | 47 *new_ui = new HtmlDialogUI(tab_contents); |
| 41 return true; | 48 return true; |
| 42 } | 49 } |
| 43 #endif | 50 #endif |
| 44 | 51 |
| 45 // This will get called a lot to check all URLs, so do a quick check of other | 52 // This will get called a lot to check all URLs, so do a quick check of other |
| 46 // schemes (gears was handled above) to filter out most URLs. | 53 // schemes (gears was handled above) to filter out most URLs. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 *new_ui = new DevToolsUI(tab_contents); | 91 *new_ui = new DevToolsUI(tab_contents); |
| 85 return true; | 92 return true; |
| 86 } | 93 } |
| 87 | 94 |
| 88 return false; | 95 return false; |
| 89 } | 96 } |
| 90 | 97 |
| 91 // static | 98 // static |
| 92 bool DOMUIFactory::HasDOMUIScheme(const GURL& url) { | 99 bool DOMUIFactory::HasDOMUIScheme(const GURL& url) { |
| 93 return url.SchemeIs(chrome::kChromeInternalScheme) || | 100 return url.SchemeIs(chrome::kChromeInternalScheme) || |
| 94 url.SchemeIs(chrome::kChromeUIScheme); | 101 url.SchemeIs(chrome::kChromeUIScheme) || |
| 102 url.SchemeIs(chrome::kExtensionScheme); |
| 95 } | 103 } |
| 96 | 104 |
| 97 // static | 105 // static |
| 98 bool DOMUIFactory::UseDOMUIForURL(const GURL& url) { | 106 bool DOMUIFactory::UseDOMUIForURL(const GURL& url) { |
| 99 return CreateDOMUI(url, NULL, NULL); | 107 return CreateDOMUI(url, NULL, NULL); |
| 100 } | 108 } |
| 101 | 109 |
| 102 // static | 110 // static |
| 103 DOMUI* DOMUIFactory::CreateDOMUIForURL(TabContents* tab_contents, | 111 DOMUI* DOMUIFactory::CreateDOMUIForURL(TabContents* tab_contents, |
| 104 const GURL& url) { | 112 const GURL& url) { |
| 105 DOMUI* dom_ui; | 113 DOMUI* dom_ui; |
| 106 if (!CreateDOMUI(url, tab_contents, &dom_ui)) | 114 if (!CreateDOMUI(url, tab_contents, &dom_ui)) |
| 107 return NULL; | 115 return NULL; |
| 108 return dom_ui; | 116 return dom_ui; |
| 109 } | 117 } |
| OLD | NEW |