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

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

Issue 7068007: Revise about: and chrome: url handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and add extra crash URL checks. Created 9 years, 7 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/extensions/extension_install_ui.cc ('k') | chrome/browser/net/url_fixer_upper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 2bb87d91b3100ad3200570b64de4cc768b9fb9c3..ee6c4cd0d39a073ca21b47932daeb7e4712fea31 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -123,6 +123,18 @@ std::string GetWindowTypeText(const Browser* browser) {
return keys::kWindowTypeValueNormal;
}
+bool IsCrashURL(const GURL& url) {
+ if (url == GURL(chrome::kAboutBrowserCrash) ||
+ url == GURL(chrome::kAboutCrashURL))
+ return true;
+
+ bool has_chrome_scheme = url.SchemeIs(chrome::kAboutScheme) ||
+ url.SchemeIs(chrome::kChromeUIScheme);
+ bool has_crash_host = url.host() == chrome::kChromeUIBrowserCrashHost ||
+ url.host() == chrome::kChromeUICrashHost;
+ return (has_chrome_scheme && has_crash_host);
+}
+
} // namespace
int ExtensionTabUtil::GetWindowId(const Browser* browser) {
@@ -402,20 +414,16 @@ bool CreateWindowFunction::RunImpl() {
keys::kInvalidUrlError, *i);
return false;
}
+ // Don't let the extension crash the browser or renderers.
msw 2011/05/31 20:58:25 comment outdented...
+ if (IsCrashURL(url)) {
+ error_ = keys::kNoCrashBrowserError;
+ return false;
+ }
urls.push_back(url);
}
}
}
- // Don't let the extension crash the browser or renderers.
- GURL browser_crash(chrome::kAboutBrowserCrash);
- GURL renderer_crash(chrome::kAboutCrashURL);
- if (std::find(urls.begin(), urls.end(), browser_crash) != urls.end() ||
- std::find(urls.begin(), urls.end(), renderer_crash) != urls.end()) {
- error_ = keys::kNoCrashBrowserError;
- return false;
- }
-
// Look for optional tab id.
if (args) {
int tab_id;
@@ -749,8 +757,7 @@ bool CreateTabFunction::RunImpl() {
}
// Don't let extensions crash the browser or renderers.
- if (url == GURL(chrome::kAboutBrowserCrash) ||
- url == GURL(chrome::kAboutCrashURL)) {
+ if (IsCrashURL(url)) {
error_ = keys::kNoCrashBrowserError;
return false;
}
@@ -867,7 +874,7 @@ bool UpdateTabFunction::RunImpl() {
// -title
// -favIconUrl
- // Navigate the tab to a new location if the url different.
+ // Navigate the tab to a new location if the url is different.
std::string url_string;
if (update_props->HasKey(keys::kUrlKey)) {
EXTENSION_FUNCTION_VALIDATE(update_props->GetString(
@@ -881,8 +888,7 @@ bool UpdateTabFunction::RunImpl() {
}
// Don't let the extension crash the browser or renderers.
- if (url == GURL(chrome::kAboutBrowserCrash) ||
- url == GURL(chrome::kAboutCrashURL)) {
+ if (IsCrashURL(url)) {
error_ = keys::kNoCrashBrowserError;
return false;
}
« no previous file with comments | « chrome/browser/extensions/extension_install_ui.cc ('k') | chrome/browser/net/url_fixer_upper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698