| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_contents.h" | 5 #include "chrome/browser/dom_ui/dom_ui_contents.h" |
| 6 | 6 |
| 7 #include "chrome/browser/debugger/debugger_contents.h" | 7 #include "chrome/browser/debugger/debugger_contents.h" |
| 8 #include "chrome/browser/dom_ui/dom_ui.h" | 8 #include "chrome/browser/dom_ui/dom_ui.h" |
| 9 #include "chrome/browser/dom_ui/downloads_ui.h" | 9 #include "chrome/browser/dom_ui/downloads_ui.h" |
| 10 #include "chrome/browser/dom_ui/history_ui.h" | 10 #include "chrome/browser/dom_ui/history_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/renderer_host/render_view_host.h" | 12 #include "chrome/browser/renderer_host/render_view_host.h" |
| 13 #include "chrome/browser/tab_contents/navigation_entry.h" | 13 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 14 #include "chrome/common/resource_bundle.h" | 14 #include "chrome/common/resource_bundle.h" |
| 15 | 15 #include "chrome/common/url_constants.h" |
| 16 // The scheme used for DOMUIContentses | |
| 17 // TODO(glen): Merge this with the scheme in chrome_url_data_manager | |
| 18 static const char kURLScheme[] = "chrome-ui"; | |
| 19 | 16 |
| 20 // The path used in internal URLs to thumbnail data. | 17 // The path used in internal URLs to thumbnail data. |
| 21 static const char kThumbnailPath[] = "thumb"; | 18 static const char kThumbnailPath[] = "thumb"; |
| 22 | 19 |
| 23 // The path used in internal URLs to favicon data. | 20 // The path used in internal URLs to favicon data. |
| 24 static const char kFavIconPath[] = "favicon"; | 21 static const char kFavIconPath[] = "favicon"; |
| 25 | 22 |
| 26 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
| 27 // FavIconSource | 24 // FavIconSource |
| 28 | 25 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 116 |
| 120 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
| 121 // DOMUIContents | 118 // DOMUIContents |
| 122 | 119 |
| 123 // This is the top-level URL handler for chrome-ui: URLs, and exposed in | 120 // This is the top-level URL handler for chrome-ui: URLs, and exposed in |
| 124 // our header file. The individual DOMUIs provide a chrome-ui:// HTML source | 121 // our header file. The individual DOMUIs provide a chrome-ui:// HTML source |
| 125 // at the same host/path. | 122 // at the same host/path. |
| 126 bool DOMUIContentsCanHandleURL(GURL* url, | 123 bool DOMUIContentsCanHandleURL(GURL* url, |
| 127 TabContentsType* result_type) { | 124 TabContentsType* result_type) { |
| 128 // chrome-internal is a scheme we used to use for the new tab page. | 125 // chrome-internal is a scheme we used to use for the new tab page. |
| 129 if (!url->SchemeIs(kURLScheme) && !url->SchemeIs("chrome-internal")) | 126 if (!url->SchemeIs(chrome::kChromeUIScheme) && |
| 127 !url->SchemeIs(chrome::kChromeInternalScheme)) |
| 130 return false; | 128 return false; |
| 131 | 129 |
| 132 *result_type = TAB_CONTENTS_DOM_UI; | 130 *result_type = TAB_CONTENTS_DOM_UI; |
| 133 return true; | 131 return true; |
| 134 } | 132 } |
| 135 | 133 |
| 136 DOMUIContents::DOMUIContents(Profile* profile, | 134 DOMUIContents::DOMUIContents(Profile* profile, |
| 137 SiteInstance* instance, | 135 SiteInstance* instance, |
| 138 RenderViewHostFactory* render_view_factory) | 136 RenderViewHostFactory* render_view_factory) |
| 139 : WebContents(profile, | 137 : WebContents(profile, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 216 } |
| 219 | 217 |
| 220 void DOMUIContents::ProcessDOMUIMessage(const std::string& message, | 218 void DOMUIContents::ProcessDOMUIMessage(const std::string& message, |
| 221 const std::string& content) { | 219 const std::string& content) { |
| 222 DCHECK(current_ui_); | 220 DCHECK(current_ui_); |
| 223 current_ui_->ProcessDOMUIMessage(message, content); | 221 current_ui_->ProcessDOMUIMessage(message, content); |
| 224 } | 222 } |
| 225 | 223 |
| 226 // static | 224 // static |
| 227 const std::string DOMUIContents::GetScheme() { | 225 const std::string DOMUIContents::GetScheme() { |
| 228 return kURLScheme; | 226 return chrome::kChromeUIScheme; |
| 229 } | 227 } |
| 230 | 228 |
| 231 DOMUI* DOMUIContents::GetDOMUIForURL(const GURL &url) { | 229 DOMUI* DOMUIContents::GetDOMUIForURL(const GURL &url) { |
| 232 #if defined(OS_WIN) | 230 #if defined(OS_WIN) |
| 233 // TODO(port): include this once these are converted to HTML | 231 // TODO(port): include this once these are converted to HTML |
| 234 if (url.host() == NewTabUI::GetBaseURL().host() || | 232 if (url.host() == NewTabUI::GetBaseURL().host() || |
| 235 url.SchemeIs("chrome-internal")) { | 233 url.SchemeIs(chrome::kChromeInternalScheme)) { |
| 236 return new NewTabUI(this); | 234 return new NewTabUI(this); |
| 237 } else if (url.host() == HistoryUI::GetBaseURL().host()) { | 235 } else if (url.host() == HistoryUI::GetBaseURL().host()) { |
| 238 return new HistoryUI(this); | 236 return new HistoryUI(this); |
| 239 } else if (url.host() == DownloadsUI::GetBaseURL().host()) { | 237 } else if (url.host() == DownloadsUI::GetBaseURL().host()) { |
| 240 return new DownloadsUI(this); | 238 return new DownloadsUI(this); |
| 241 } else if (url.host() == DebuggerContents::GetBaseURL().host()) { | 239 } else if (url.host() == DebuggerContents::GetBaseURL().host()) { |
| 242 return new DebuggerContents(this); | 240 return new DebuggerContents(this); |
| 243 } | 241 } |
| 244 #else | 242 #else |
| 245 NOTIMPLEMENTED(); | 243 NOTIMPLEMENTED(); |
| 246 #endif | 244 #endif |
| 247 return NULL; | 245 return NULL; |
| 248 } | 246 } |
| OLD | NEW |