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

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

Issue 7464009: Removal of Profile from content part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: slight tweaking for comments Created 9 years, 5 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 static Type* New() { 255 static Type* New() {
256 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) 256 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType))
257 return DefaultSingletonTraits<TestType>::New(); 257 return DefaultSingletonTraits<TestType>::New();
258 else 258 else
259 return DefaultSingletonTraits<Type>::New(); 259 return DefaultSingletonTraits<Type>::New();
260 } 260 }
261 }; 261 };
262 262
263 } // namespace 263 } // namespace
264 264
265 WebUI::TypeID ChromeWebUIFactory::GetWebUIType(Profile* profile, 265 WebUI::TypeID ChromeWebUIFactory::GetWebUIType(
266 const GURL& url) const { 266 content::BrowserContext* browser_context, const GURL& url) const {
267 Profile* profile = Profile::FromBrowserContext(browser_context);
267 WebUIFactoryFunction function = GetWebUIFactoryFunction(profile, url); 268 WebUIFactoryFunction function = GetWebUIFactoryFunction(profile, url);
268 return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI; 269 return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI;
269 } 270 }
270 271
271 bool ChromeWebUIFactory::UseWebUIForURL(Profile* profile, 272 bool ChromeWebUIFactory::UseWebUIForURL(
272 const GURL& url) const { 273 content::BrowserContext* browser_context, const GURL& url) const {
273 return GetWebUIType(profile, url) != WebUI::kNoWebUI; 274 return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
274 } 275 }
275 276
276 bool ChromeWebUIFactory::HasWebUIScheme(const GURL& url) const { 277 bool ChromeWebUIFactory::HasWebUIScheme(const GURL& url) const {
277 return url.SchemeIs(chrome::kChromeDevToolsScheme) || 278 return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
278 url.SchemeIs(chrome::kChromeInternalScheme) || 279 url.SchemeIs(chrome::kChromeInternalScheme) ||
279 url.SchemeIs(chrome::kChromeUIScheme) || 280 url.SchemeIs(chrome::kChromeUIScheme) ||
280 url.SchemeIs(chrome::kExtensionScheme); 281 url.SchemeIs(chrome::kExtensionScheme);
281 } 282 }
282 283
283 bool ChromeWebUIFactory::IsURLAcceptableForWebUI( 284 bool ChromeWebUIFactory::IsURLAcceptableForWebUI(
284 Profile* profile, 285 content::BrowserContext* browser_context,
285 const GURL& url) const { 286 const GURL& url) const {
286 return UseWebUIForURL(profile, url) || 287 return UseWebUIForURL(browser_context, url) ||
287 // javacsript: URLs are allowed to run in Web UI pages 288 // javacsript: URLs are allowed to run in Web UI pages
288 url.SchemeIs(chrome::kJavaScriptScheme) || 289 url.SchemeIs(chrome::kJavaScriptScheme) ||
289 // It's possible to load about:blank in a Web UI renderer. 290 // It's possible to load about:blank in a Web UI renderer.
290 // See http://crbug.com/42547 291 // See http://crbug.com/42547
291 url.spec() == chrome::kAboutBlankURL || 292 url.spec() == chrome::kAboutBlankURL ||
292 // Chrome URLs crash, kill, hang, and shorthang are allowed. 293 // Chrome URLs crash, kill, hang, and shorthang are allowed.
293 url == GURL(chrome::kChromeUICrashURL) || 294 url == GURL(chrome::kChromeUICrashURL) ||
294 url == GURL(chrome::kChromeUIKillURL) || 295 url == GURL(chrome::kChromeUIKillURL) ||
295 url == GURL(chrome::kChromeUIHangURL) || 296 url == GURL(chrome::kChromeUIHangURL) ||
296 url == GURL(chrome::kChromeUIShorthangURL); 297 url == GURL(chrome::kChromeUIShorthangURL);
297 } 298 }
298 299
299 WebUI* ChromeWebUIFactory::CreateWebUIForURL( 300 WebUI* ChromeWebUIFactory::CreateWebUIForURL(
300 TabContents* tab_contents, 301 TabContents* tab_contents,
301 const GURL& url) const { 302 const GURL& url) const {
302 WebUIFactoryFunction function = GetWebUIFactoryFunction( 303 Profile* profile =
303 tab_contents->profile(), url); 304 Profile::FromBrowserContext(tab_contents->browser_context());
305 WebUIFactoryFunction function = GetWebUIFactoryFunction(profile, url);
304 if (!function) 306 if (!function)
305 return NULL; 307 return NULL;
306 return (*function)(tab_contents, url); 308 return (*function)(tab_contents, url);
307 } 309 }
308 310
309 void ChromeWebUIFactory::GetFaviconForURL( 311 void ChromeWebUIFactory::GetFaviconForURL(
310 Profile* profile, 312 Profile* profile,
311 FaviconService::GetFaviconRequest* request, 313 FaviconService::GetFaviconRequest* request,
312 const GURL& page_url) const { 314 const GURL& page_url) const {
313 // All extensions but the bookmark manager get their favicon from the icons 315 // All extensions but the bookmark manager get their favicon from the icons
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return FlashUI::GetFaviconResourceBytes(); 388 return FlashUI::GetFaviconResourceBytes();
387 389
388 if (page_url.host() == chrome::kChromeUISettingsHost) 390 if (page_url.host() == chrome::kChromeUISettingsHost)
389 return OptionsUI::GetFaviconResourceBytes(); 391 return OptionsUI::GetFaviconResourceBytes();
390 392
391 if (page_url.host() == chrome::kChromeUIPluginsHost) 393 if (page_url.host() == chrome::kChromeUIPluginsHost)
392 return PluginsUI::GetFaviconResourceBytes(); 394 return PluginsUI::GetFaviconResourceBytes();
393 395
394 return NULL; 396 return NULL;
395 } 397 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_web_ui_factory.h ('k') | chrome/browser/ui/webui/test_chrome_web_ui_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698