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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 195093: handle mole/toolstrip URLs properly (Closed)
Patch Set: Created 11 years, 3 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
Index: chrome/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index c483070d65353280dca7def31f01d274e7833f0a..df4f558fa0d1091f881cddd2617d74e86137a347 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -98,6 +98,15 @@ void ExtensionHost::CreateRenderView(RenderWidgetHostView* host_view) {
}
void ExtensionHost::NavigateToURL(const GURL& url) {
+ // Prevent explicit navigation to another extension id's pages.
+ // This method is only called by some APIs, so we still need to protect
+ // DidNavigate below (location = "").
+ if (url.SchemeIs(chrome::kExtensionScheme) &&
+ url.host() != extension_->id()) {
+ // TODO(erikkay) communicate this back to the caller?
+ return;
+ }
+
url_ = url;
if (!is_background_page() && !extension_->GetBackgroundPageReady()) {
@@ -141,11 +150,28 @@ void ExtensionHost::DidNavigate(RenderViewHost* render_view_host,
return;
}
- url_ = params.url;
- if (!url_.SchemeIs(chrome::kExtensionScheme)) {
+ if (!params.url.SchemeIs(chrome::kExtensionScheme)) {
+ extension_function_dispatcher_.reset(NULL);
+ url_ = params.url;
+ return;
+ }
+
+ // This catches two bogus use cases:
+ // (1) URLs that look like chrome-extension://somethingbogus or
+ // chrome-extension://nosuchid/, in other words, no Extension would
+ // be found.
+ // (2) URLs that refer to a different extension than this one.
+ // In both cases, we preserve the old URL and reset the EFD to NULL. This
+ // will leave the host in kind of a bad state with poor UI and errors, but
+ // it's better than the alternative.
+ // TODO(erikkay) Perhaps we should display log errors or display a big 404
+ // in the toolstrip or something like that.
+ if (params.url.host() != extension_->id()) {
extension_function_dispatcher_.reset(NULL);
return;
}
+
+ url_ = params.url;
extension_function_dispatcher_.reset(
new ExtensionFunctionDispatcher(render_view_host_, this, url_));
}

Powered by Google App Engine
This is Rietveld 408576698