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

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

Issue 7064052: Revert 88142 to fix sync_integration_tests offline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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::kChromeUICloudPrintResourcesHost) 103 if (url.host() == chrome::kCloudPrintResourcesHost)
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::kChromeUICloudPrintSetupHost) 114 url.host() == chrome::kCloudPrintSetupHost)
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 // Return a generic Web UI so chrome:chrome-urls can navigate to Web UI pages. 125 // Give about:about a generic Web UI so it can navigate to pages with Web UIs.
126 if (url.host() == chrome::kChromeUIAboutHost || 126 if (url.spec() == chrome::kChromeUIAboutAboutURL)
127 url.host() == chrome::kChromeUIChromeURLsHost)
128 return &NewWebUI<ChromeWebUI>; 127 return &NewWebUI<ChromeWebUI>;
129 128
130 // We must compare hosts only since some of the Web UIs append extra stuff 129 // We must compare hosts only since some of the Web UIs append extra stuff
131 // after the host name. 130 // after the host name.
132 if (url.host() == chrome::kChromeUIBookmarksHost) 131 if (url.host() == chrome::kChromeUIBookmarksHost)
133 return &NewWebUI<BookmarksUI>; 132 return &NewWebUI<BookmarksUI>;
134 if (url.host() == chrome::kChromeUIBugReportHost) 133 if (url.host() == chrome::kChromeUIBugReportHost)
135 return &NewWebUI<BugReportUI>; 134 return &NewWebUI<BugReportUI>;
136 if (url.host() == chrome::kChromeUICrashesHost) 135 if (url.host() == chrome::kChromeUICrashesHost)
137 return &NewWebUI<CrashesUI>; 136 return &NewWebUI<CrashesUI>;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 247
249 bool ChromeWebUIFactory::IsURLAcceptableForWebUI( 248 bool ChromeWebUIFactory::IsURLAcceptableForWebUI(
250 Profile* profile, 249 Profile* profile,
251 const GURL& url) const { 250 const GURL& url) const {
252 return UseWebUIForURL(profile, url) || 251 return UseWebUIForURL(profile, url) ||
253 // javacsript: URLs are allowed to run in Web UI pages 252 // javacsript: URLs are allowed to run in Web UI pages
254 url.SchemeIs(chrome::kJavaScriptScheme) || 253 url.SchemeIs(chrome::kJavaScriptScheme) ||
255 // It's possible to load about:blank in a Web UI renderer. 254 // It's possible to load about:blank in a Web UI renderer.
256 // See http://crbug.com/42547 255 // See http://crbug.com/42547
257 url.spec() == chrome::kAboutBlankURL || 256 url.spec() == chrome::kAboutBlankURL ||
258 // Chrome URLs crash, kill, hang, and shorthang are allowed. 257 // about:crash, about:kill, about:hang, and about:shorthang are allowed.
259 url == GURL(chrome::kChromeUICrashURL) || 258 url.spec() == chrome::kAboutCrashURL ||
260 url == GURL(chrome::kChromeUIKillURL) || 259 url.spec() == chrome::kAboutKillURL ||
261 url == GURL(chrome::kChromeUIHangURL) || 260 url.spec() == chrome::kAboutHangURL ||
262 url == GURL(chrome::kChromeUIShorthangURL); 261 url.spec() == chrome::kAboutShorthangURL;
263 } 262 }
264 263
265 WebUI* ChromeWebUIFactory::CreateWebUIForURL( 264 WebUI* ChromeWebUIFactory::CreateWebUIForURL(
266 TabContents* tab_contents, 265 TabContents* tab_contents,
267 const GURL& url) const { 266 const GURL& url) const {
268 WebUIFactoryFunction function = GetWebUIFactoryFunction( 267 WebUIFactoryFunction function = GetWebUIFactoryFunction(
269 tab_contents->profile(), url); 268 tab_contents->profile(), url);
270 if (!function) 269 if (!function)
271 return NULL; 270 return NULL;
272 return (*function)(tab_contents, url); 271 return (*function)(tab_contents, url);
(...skipping 26 matching lines...) Expand all
299 ChromeWebUIFactory, TestChromeWebUIFactory> >::get(); 298 ChromeWebUIFactory, TestChromeWebUIFactory> >::get();
300 } 299 }
301 300
302 ChromeWebUIFactory::ChromeWebUIFactory() { 301 ChromeWebUIFactory::ChromeWebUIFactory() {
303 } 302 }
304 303
305 ChromeWebUIFactory::~ChromeWebUIFactory() { 304 ChromeWebUIFactory::~ChromeWebUIFactory() {
306 } 305 }
307 306
308 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes( 307 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes(
309 const GURL& page_url) const { 308 const GURL& page_url) const {
310 // The bookmark manager is a chrome extension, so we have to check for it 309 // The bookmark manager is a chrome extension, so we have to check for it
311 // before we check for extension scheme. 310 // before we check for extension scheme.
312 if (page_url.host() == extension_misc::kBookmarkManagerId) 311 if (page_url.host() == extension_misc::kBookmarkManagerId)
313 return BookmarksUI::GetFaviconResourceBytes(); 312 return BookmarksUI::GetFaviconResourceBytes();
314 313
315 // The extension scheme is handled in GetFaviconForURL. 314 // The extension scheme is handled in GetFaviconForURL.
316 if (page_url.SchemeIs(chrome::kExtensionScheme)) { 315 if (page_url.SchemeIs(chrome::kExtensionScheme)) {
317 NOTREACHED(); 316 NOTREACHED();
318 return NULL; 317 return NULL;
319 } 318 }
(...skipping 28 matching lines...) Expand all
348 return FlashUI::GetFaviconResourceBytes(); 347 return FlashUI::GetFaviconResourceBytes();
349 348
350 if (page_url.host() == chrome::kChromeUISettingsHost) 349 if (page_url.host() == chrome::kChromeUISettingsHost)
351 return OptionsUI::GetFaviconResourceBytes(); 350 return OptionsUI::GetFaviconResourceBytes();
352 351
353 if (page_url.host() == chrome::kChromeUIPluginsHost) 352 if (page_url.host() == chrome::kChromeUIPluginsHost)
354 return PluginsUI::GetFaviconResourceBytes(); 353 return PluginsUI::GetFaviconResourceBytes();
355 354
356 return NULL; 355 return NULL;
357 } 356 }
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