Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/ui/webui/chrome_web_ui_factory.cc

Issue 7068007: Revise about: and chrome: url handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update special_tabs.py from Nirnimesh's codereview.chromium.org/6995057/. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_factory.h" 5 #include "chrome/browser/ui/webui/chrome_web_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/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_web_ui.h" 10 #include "chrome/browser/extensions/extension_web_ui.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (url.host() == chrome::kChromeUIDialogHost) 93 if (url.host() == chrome::kChromeUIDialogHost)
94 return &NewWebUI<ConstrainedHtmlUI>; 94 return &NewWebUI<ConstrainedHtmlUI>;
95 95
96 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; 96 ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
97 if (service && service->ExtensionBindingsAllowed(url)) 97 if (service && service->ExtensionBindingsAllowed(url))
98 return &NewWebUI<ExtensionWebUI>; 98 return &NewWebUI<ExtensionWebUI>;
99 99
100 // All platform builds of Chrome will need to have a cloud printing 100 // All platform builds of Chrome will need to have a cloud printing
101 // dialog as backup. It's just that on Chrome OS, it's the only 101 // dialog as backup. It's just that on Chrome OS, it's the only
102 // print dialog. 102 // print dialog.
103 if (url.host() == chrome::kCloudPrintResourcesHost) 103 if (url.host() == chrome::kChromeUICloudPrintResourcesHost)
104 return &NewWebUI<ExternalHtmlDialogUI>; 104 return &NewWebUI<ExternalHtmlDialogUI>;
105 105
106 // This will get called a lot to check all URLs, so do a quick check of other 106 // This will get called a lot to check all URLs, so do a quick check of other
107 // schemes to filter out most URLs. 107 // schemes to filter out most URLs.
108 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) && 108 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
109 !url.SchemeIs(chrome::kChromeInternalScheme) && 109 !url.SchemeIs(chrome::kChromeInternalScheme) &&
110 !url.SchemeIs(chrome::kChromeUIScheme)) 110 !url.SchemeIs(chrome::kChromeUIScheme))
111 return NULL; 111 return NULL;
112 112
113 if (url.host() == chrome::kChromeUISyncResourcesHost || 113 if (url.host() == chrome::kChromeUISyncResourcesHost ||
114 url.host() == chrome::kCloudPrintSetupHost) 114 url.host() == chrome::kChromeUICloudPrintSetupHost)
115 return &NewWebUI<HtmlDialogUI>; 115 return &NewWebUI<HtmlDialogUI>;
116 116
117 // Special case the new tab page. In older versions of Chrome, the new tab 117 // Special case the new tab page. In older versions of Chrome, the new tab
118 // page was hosted at chrome-internal:<blah>. This might be in people's saved 118 // page was hosted at chrome-internal:<blah>. This might be in people's saved
119 // sessions or bookmarks, so we say any URL with that scheme triggers the new 119 // sessions or bookmarks, so we say any URL with that scheme triggers the new
120 // tab page. 120 // tab page.
121 if (url.host() == chrome::kChromeUINewTabHost || 121 if (url.host() == chrome::kChromeUINewTabHost ||
122 url.SchemeIs(chrome::kChromeInternalScheme)) 122 url.SchemeIs(chrome::kChromeInternalScheme))
123 return &NewWebUI<NewTabUI>; 123 return &NewWebUI<NewTabUI>;
124 124
125 // Give about:about a generic Web UI so it can navigate to pages with Web UIs. 125 // Return a generic Web UI so chrome:chrome-urls can navigate to Web UI pages.
126 if (url.spec() == chrome::kChromeUIAboutAboutURL) 126 if (url.host() == chrome::kChromeUIAboutHost ||
127 url.host() == chrome::kChromeUIChromeURLsHost)
127 return &NewWebUI<ChromeWebUI>; 128 return &NewWebUI<ChromeWebUI>;
128 129
129 // We must compare hosts only since some of the Web UIs append extra stuff 130 // We must compare hosts only since some of the Web UIs append extra stuff
130 // after the host name. 131 // after the host name.
131 if (url.host() == chrome::kChromeUIBookmarksHost) 132 if (url.host() == chrome::kChromeUIBookmarksHost)
132 return &NewWebUI<BookmarksUI>; 133 return &NewWebUI<BookmarksUI>;
133 if (url.host() == chrome::kChromeUIBugReportHost) 134 if (url.host() == chrome::kChromeUIBugReportHost)
134 return &NewWebUI<BugReportUI>; 135 return &NewWebUI<BugReportUI>;
135 if (url.host() == chrome::kChromeUICrashesHost) 136 if (url.host() == chrome::kChromeUICrashesHost)
136 return &NewWebUI<CrashesUI>; 137 return &NewWebUI<CrashesUI>;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 248
248 bool ChromeWebUIFactory::IsURLAcceptableForWebUI( 249 bool ChromeWebUIFactory::IsURLAcceptableForWebUI(
249 Profile* profile, 250 Profile* profile,
250 const GURL& url) const { 251 const GURL& url) const {
251 return UseWebUIForURL(profile, url) || 252 return UseWebUIForURL(profile, url) ||
252 // javacsript: URLs are allowed to run in Web UI pages 253 // javacsript: URLs are allowed to run in Web UI pages
253 url.SchemeIs(chrome::kJavaScriptScheme) || 254 url.SchemeIs(chrome::kJavaScriptScheme) ||
254 // It's possible to load about:blank in a Web UI renderer. 255 // It's possible to load about:blank in a Web UI renderer.
255 // See http://crbug.com/42547 256 // See http://crbug.com/42547
256 url.spec() == chrome::kAboutBlankURL || 257 url.spec() == chrome::kAboutBlankURL ||
257 // about:crash, about:kill, about:hang, and about:shorthang are allowed. 258 // Chrome URLs crash, kill, hang, and shorthang are allowed.
258 url.spec() == chrome::kAboutCrashURL || 259 url == GURL(chrome::kChromeUICrashURL) ||
259 url.spec() == chrome::kAboutKillURL || 260 url == GURL(chrome::kChromeUIKillURL) ||
260 url.spec() == chrome::kAboutHangURL || 261 url == GURL(chrome::kChromeUIHangURL) ||
261 url.spec() == chrome::kAboutShorthangURL; 262 url == GURL(chrome::kChromeUIShorthangURL);
262 } 263 }
263 264
264 WebUI* ChromeWebUIFactory::CreateWebUIForURL( 265 WebUI* ChromeWebUIFactory::CreateWebUIForURL(
265 TabContents* tab_contents, 266 TabContents* tab_contents,
266 const GURL& url) const { 267 const GURL& url) const {
267 WebUIFactoryFunction function = GetWebUIFactoryFunction( 268 WebUIFactoryFunction function = GetWebUIFactoryFunction(
268 tab_contents->profile(), url); 269 tab_contents->profile(), url);
269 if (!function) 270 if (!function)
270 return NULL; 271 return NULL;
271 return (*function)(tab_contents, url); 272 return (*function)(tab_contents, url);
(...skipping 26 matching lines...) Expand all
298 ChromeWebUIFactory, TestChromeWebUIFactory> >::get(); 299 ChromeWebUIFactory, TestChromeWebUIFactory> >::get();
299 } 300 }
300 301
301 ChromeWebUIFactory::ChromeWebUIFactory() { 302 ChromeWebUIFactory::ChromeWebUIFactory() {
302 } 303 }
303 304
304 ChromeWebUIFactory::~ChromeWebUIFactory() { 305 ChromeWebUIFactory::~ChromeWebUIFactory() {
305 } 306 }
306 307
307 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes( 308 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes(
308 const GURL& page_url) const { 309 const GURL& page_url) const {
309 // The bookmark manager is a chrome extension, so we have to check for it 310 // The bookmark manager is a chrome extension, so we have to check for it
310 // before we check for extension scheme. 311 // before we check for extension scheme.
311 if (page_url.host() == extension_misc::kBookmarkManagerId) 312 if (page_url.host() == extension_misc::kBookmarkManagerId)
312 return BookmarksUI::GetFaviconResourceBytes(); 313 return BookmarksUI::GetFaviconResourceBytes();
313 314
314 // The extension scheme is handled in GetFaviconForURL. 315 // The extension scheme is handled in GetFaviconForURL.
315 if (page_url.SchemeIs(chrome::kExtensionScheme)) { 316 if (page_url.SchemeIs(chrome::kExtensionScheme)) {
316 NOTREACHED(); 317 NOTREACHED();
317 return NULL; 318 return NULL;
318 } 319 }
(...skipping 28 matching lines...) Expand all
347 return FlashUI::GetFaviconResourceBytes(); 348 return FlashUI::GetFaviconResourceBytes();
348 349
349 if (page_url.host() == chrome::kChromeUISettingsHost) 350 if (page_url.host() == chrome::kChromeUISettingsHost)
350 return OptionsUI::GetFaviconResourceBytes(); 351 return OptionsUI::GetFaviconResourceBytes();
351 352
352 if (page_url.host() == chrome::kChromeUIPluginsHost) 353 if (page_url.host() == chrome::kChromeUIPluginsHost)
353 return PluginsUI::GetFaviconResourceBytes(); 354 return PluginsUI::GetFaviconResourceBytes();
354 355
355 return NULL; 356 return NULL;
356 } 357 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_url_data_manager_backend.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698