Remove an obsolete NULL test for TabContents in NeedsExtensionWebUI.

The code that relied on there being a valid TabContents has changed, so we can
now create an ExtensionWebUI for all extension URLs.

BUG=106255


Review URL: https://chromiumcodereview.appspot.com/11348358

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171037 0039d316-1c4b-4281-b951-d872f2087c98
parent 7f01dde7
...@@ -147,16 +147,10 @@ WebUIController* NewWebUI<AboutUI>(WebUI* web_ui, const GURL& url) { ...@@ -147,16 +147,10 @@ WebUIController* NewWebUI<AboutUI>(WebUI* web_ui, const GURL& url) {
} }
// Only create ExtensionWebUI for URLs that are allowed extension bindings, // Only create ExtensionWebUI for URLs that are allowed extension bindings,
// hosted by actual tabs. If there is no TabContents, it likely refers // hosted by actual tabs.
// to another container type, like an extension background page. If there is bool NeedsExtensionWebUI(Profile* profile, const GURL& url) {
// no WebUI (it's not accessible when calling GetWebUIType and related
// functions) then we conservatively assume that we need a WebUI.
bool NeedsExtensionWebUI(WebUI* web_ui,
Profile* profile,
const GURL& url) {
ExtensionService* service = profile ? profile->GetExtensionService() : NULL; ExtensionService* service = profile ? profile->GetExtensionService() : NULL;
return service && service->ExtensionBindingsAllowed(url) && return service && service->ExtensionBindingsAllowed(url);
(!web_ui || TabContents::FromWebContents(web_ui->GetWebContents()));
} }
// Returns a function that can be used to create the right type of WebUI for a // Returns a function that can be used to create the right type of WebUI for a
...@@ -166,7 +160,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, ...@@ -166,7 +160,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
Profile* profile, Profile* profile,
const GURL& url) { const GURL& url) {
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
if (NeedsExtensionWebUI(web_ui, profile, url)) if (NeedsExtensionWebUI(profile, url))
return &NewWebUI<ExtensionWebUI>; return &NewWebUI<ExtensionWebUI>;
#endif #endif
...@@ -446,8 +440,7 @@ bool ChromeWebUIControllerFactory::UseWebUIBindingsForURL( ...@@ -446,8 +440,7 @@ bool ChromeWebUIControllerFactory::UseWebUIBindingsForURL(
content::BrowserContext* browser_context, const GURL& url) const { content::BrowserContext* browser_context, const GURL& url) const {
// Extensions are rendered via WebUI in tabs, but don't actually need WebUI // Extensions are rendered via WebUI in tabs, but don't actually need WebUI
// bindings (see the ExtensionWebUI constructor). // bindings (see the ExtensionWebUI constructor).
return !NeedsExtensionWebUI(NULL, return !NeedsExtensionWebUI(Profile::FromBrowserContext(browser_context),
Profile::FromBrowserContext(browser_context),
url) && url) &&
UseWebUIForURL(browser_context, url); UseWebUIForURL(browser_context, url);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment