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

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: Address comments and add extra crash URL checks. 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (url.host() == chrome::kChromeUIDialogHost) 97 if (url.host() == chrome::kChromeUIDialogHost)
98 return &NewWebUI<ConstrainedHtmlUI>; 98 return &NewWebUI<ConstrainedHtmlUI>;
99 99
100 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; 100 ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
101 if (service && service->ExtensionBindingsAllowed(url)) 101 if (service && service->ExtensionBindingsAllowed(url))
102 return &NewWebUI<ExtensionWebUI>; 102 return &NewWebUI<ExtensionWebUI>;
103 103
104 // All platform builds of Chrome will need to have a cloud printing 104 // All platform builds of Chrome will need to have a cloud printing
105 // dialog as backup. It's just that on Chrome OS, it's the only 105 // dialog as backup. It's just that on Chrome OS, it's the only
106 // print dialog. 106 // print dialog.
107 if (url.host() == chrome::kCloudPrintResourcesHost) 107 if (url.host() == chrome::kChromeUICloudPrintResourcesHost)
108 return &NewWebUI<ExternalHtmlDialogUI>; 108 return &NewWebUI<ExternalHtmlDialogUI>;
109 109
110 // This will get called a lot to check all URLs, so do a quick check of other 110 // This will get called a lot to check all URLs, so do a quick check of other
111 // schemes to filter out most URLs. 111 // schemes to filter out most URLs.
112 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) && 112 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) &&
113 !url.SchemeIs(chrome::kChromeInternalScheme) && 113 !url.SchemeIs(chrome::kChromeInternalScheme) &&
114 !url.SchemeIs(chrome::kChromeUIScheme)) 114 !url.SchemeIs(chrome::kChromeUIScheme))
115 return NULL; 115 return NULL;
116 116
117 if (url.host() == chrome::kChromeUISyncResourcesHost || 117 if (url.host() == chrome::kChromeUISyncResourcesHost ||
118 url.host() == chrome::kCloudPrintSetupHost) 118 url.host() == chrome::kChromeUICloudPrintSetupHost)
119 return &NewWebUI<HtmlDialogUI>; 119 return &NewWebUI<HtmlDialogUI>;
120 120
121 // Special case the new tab page. In older versions of Chrome, the new tab 121 // Special case the new tab page. In older versions of Chrome, the new tab
122 // page was hosted at chrome-internal:<blah>. This might be in people's saved 122 // page was hosted at chrome-internal:<blah>. This might be in people's saved
123 // sessions or bookmarks, so we say any URL with that scheme triggers the new 123 // sessions or bookmarks, so we say any URL with that scheme triggers the new
124 // tab page. 124 // tab page.
125 if (url.host() == chrome::kChromeUINewTabHost || 125 if (url.host() == chrome::kChromeUINewTabHost ||
126 url.SchemeIs(chrome::kChromeInternalScheme)) 126 url.SchemeIs(chrome::kChromeInternalScheme))
127 return &NewWebUI<NewTabUI>; 127 return &NewWebUI<NewTabUI>;
128 128
129 // Give about:about a generic Web UI so it can navigate to pages with Web UIs. 129 // Give about:about a generic Web UI so it can navigate to pages with Web UIs.
130 if (url.spec() == chrome::kChromeUIAboutAboutURL) 130 if (url.host() == chrome::kChromeUIAboutHost)
131 return &NewWebUI<WebUI>; 131 return &NewWebUI<WebUI>;
132 132
133 // We must compare hosts only since some of the Web UIs append extra stuff 133 // We must compare hosts only since some of the Web UIs append extra stuff
134 // after the host name. 134 // after the host name.
135 if (url.host() == chrome::kChromeUIBookmarksHost) 135 if (url.host() == chrome::kChromeUIBookmarksHost)
136 return &NewWebUI<BookmarksUI>; 136 return &NewWebUI<BookmarksUI>;
137 if (url.host() == chrome::kChromeUIBugReportHost) 137 if (url.host() == chrome::kChromeUIBugReportHost)
138 return &NewWebUI<BugReportUI>; 138 return &NewWebUI<BugReportUI>;
139 if (url.host() == chrome::kChromeUICrashesHost) 139 if (url.host() == chrome::kChromeUICrashesHost)
140 return &NewWebUI<CrashesUI>; 140 return &NewWebUI<CrashesUI>;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 ChromeWebUIFactory, TestChromeWebUIFactory> >::get(); 305 ChromeWebUIFactory, TestChromeWebUIFactory> >::get();
306 } 306 }
307 307
308 ChromeWebUIFactory::ChromeWebUIFactory() { 308 ChromeWebUIFactory::ChromeWebUIFactory() {
309 } 309 }
310 310
311 ChromeWebUIFactory::~ChromeWebUIFactory() { 311 ChromeWebUIFactory::~ChromeWebUIFactory() {
312 } 312 }
313 313
314 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes( 314 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes(
315 const GURL& page_url) const { 315 const GURL& page_url) const {
316 // The bookmark manager is a chrome extension, so we have to check for it 316 // The bookmark manager is a chrome extension, so we have to check for it
317 // before we check for extension scheme. 317 // before we check for extension scheme.
318 if (page_url.host() == extension_misc::kBookmarkManagerId) 318 if (page_url.host() == extension_misc::kBookmarkManagerId)
319 return BookmarksUI::GetFaviconResourceBytes(); 319 return BookmarksUI::GetFaviconResourceBytes();
320 320
321 // The extension scheme is handled in GetFaviconForURL. 321 // The extension scheme is handled in GetFaviconForURL.
322 if (page_url.SchemeIs(chrome::kExtensionScheme)) { 322 if (page_url.SchemeIs(chrome::kExtensionScheme)) {
323 NOTREACHED(); 323 NOTREACHED();
324 return NULL; 324 return NULL;
325 } 325 }
(...skipping 28 matching lines...) Expand all
354 return FlashUI::GetFaviconResourceBytes(); 354 return FlashUI::GetFaviconResourceBytes();
355 355
356 if (page_url.host() == chrome::kChromeUISettingsHost) 356 if (page_url.host() == chrome::kChromeUISettingsHost)
357 return OptionsUI::GetFaviconResourceBytes(); 357 return OptionsUI::GetFaviconResourceBytes();
358 358
359 if (page_url.host() == chrome::kChromeUIPluginsHost) 359 if (page_url.host() == chrome::kChromeUIPluginsHost)
360 return PluginsUI::GetFaviconResourceBytes(); 360 return PluginsUI::GetFaviconResourceBytes();
361 361
362 return NULL; 362 return NULL;
363 } 363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698