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

Unified Diff: chrome/browser/dom_ui/dom_ui_factory.cc

Issue 3263007: Reland r57788 - Expose Extension Bindings to Component Applications (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: don't hide gallery url in omnibar Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_factory.h ('k') | chrome/browser/extensions/app_process_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/dom_ui_factory.cc
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index 251f64634bcd1b2c571f574791071cbc74cae6a3..96f8b8a7b5f10fdc405d6adb2278423118a5511e 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -55,14 +55,14 @@ DOMUI* NewDOMUI(TabContents* contents, const GURL& url) {
// Special case for extensions.
template<>
DOMUI* NewDOMUI<ExtensionDOMUI>(TabContents* contents, const GURL& url) {
- // Don't use a DOMUI for non-existent extensions or for incognito tabs. The
- // latter restriction is because we require extensions to run within a single
- // process.
+ // Don't use a DOMUI for incognito tabs because we require extensions to run
+ // within a single process.
ExtensionsService* service = contents->profile()->GetExtensionsService();
- bool valid_extension =
- (service && service->GetExtensionById(url.host(), false));
- if (valid_extension && !contents->profile()->IsOffTheRecord())
- return new ExtensionDOMUI(contents);
+ if (service &&
+ service->ExtensionBindingsAllowed(url) &&
+ !contents->profile()->IsOffTheRecord()) {
+ return new ExtensionDOMUI(contents, url);
+ }
return NULL;
}
@@ -70,12 +70,14 @@ DOMUI* NewDOMUI<ExtensionDOMUI>(TabContents* contents, const GURL& url) {
// tab, based on its URL. Returns NULL if the URL doesn't have DOMUI associated
// with it. Even if the factory function is valid, it may yield a NULL DOMUI
// when invoked for a particular tab - see NewDOMUI<ExtensionDOMUI>.
-static DOMUIFactoryFunction GetDOMUIFactoryFunction(const GURL& url) {
+static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile,
+ const GURL& url) {
// Currently, any gears: URL means an HTML dialog.
if (url.SchemeIs(chrome::kGearsScheme))
return &NewDOMUI<HtmlDialogUI>;
- if (url.SchemeIs(chrome::kExtensionScheme))
+ ExtensionsService* service = profile->GetExtensionsService();
+ if (service && service->ExtensionBindingsAllowed(url))
return &NewDOMUI<ExtensionDOMUI>;
// All platform builds of Chrome will need to have a cloud printing
@@ -159,8 +161,8 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(const GURL& url) {
}
// static
-DOMUITypeID DOMUIFactory::GetDOMUIType(const GURL& url) {
- DOMUIFactoryFunction function = GetDOMUIFactoryFunction(url);
+DOMUITypeID DOMUIFactory::GetDOMUIType(Profile* profile, const GURL& url) {
+ DOMUIFactoryFunction function = GetDOMUIFactoryFunction(profile, url);
return function ? reinterpret_cast<DOMUITypeID>(function) : kNoDOMUI;
}
@@ -172,14 +174,15 @@ bool DOMUIFactory::HasDOMUIScheme(const GURL& url) {
}
// static
-bool DOMUIFactory::UseDOMUIForURL(const GURL& url) {
- return GetDOMUIFactoryFunction(url) != NULL;
+bool DOMUIFactory::UseDOMUIForURL(Profile* profile, const GURL& url) {
+ return GetDOMUIFactoryFunction(profile, url) != NULL;
}
// static
DOMUI* DOMUIFactory::CreateDOMUIForURL(TabContents* tab_contents,
const GURL& url) {
- DOMUIFactoryFunction function = GetDOMUIFactoryFunction(url);
+ DOMUIFactoryFunction function = GetDOMUIFactoryFunction(
+ tab_contents->profile(), url);
if (!function)
return NULL;
return (*function)(tab_contents, url);
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_factory.h ('k') | chrome/browser/extensions/app_process_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698