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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 2475033002: Don't show the pending URL for chrome.tabs API navigations. (Closed)
Patch Set: Identify failing test. Created 4 years, 1 month 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 | « no previous file | chrome/test/data/extensions/api_test/tabs/basics/crud2.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/tabs/tabs_api.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 021df4b62ccce2a514dccb11a0e479d8fd8a07f1..be512f9f4fc13b16aadaf733c75650ece3823308 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -1320,13 +1320,21 @@ bool TabsUpdateFunction::UpdateURL(const std::string &url_string,
return true;
}
- web_contents_->GetController().LoadURL(
- url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ // Load the URL, but treat it as renderer-initiated so that it does not show
+ // in the omnibox until it commits. This avoids URL spoofs when the tabs API
+ // is used on behalf of untrusted content.
+ NavigationController::LoadURLParams load_params(url);
+ load_params.is_renderer_initiated = true;
+ web_contents_->GetController().LoadURLWithParams(load_params);
// The URL of a tab contents never actually changes to a JavaScript URL, so
// this check only makes sense in other cases.
- if (!url.SchemeIs(url::kJavaScriptScheme))
- DCHECK_EQ(url.spec(), web_contents_->GetURL().spec());
+ if (!url.SchemeIs(url::kJavaScriptScheme)) {
+ // The URL should be present in the pending entry, though it won't be
+ // visible in the omnibox until it commits.
+ DCHECK_EQ(
+ url, web_contents_->GetController().GetPendingEntry()->GetVirtualURL());
+ }
return true;
}
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/tabs/basics/crud2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698