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

Unified Diff: extensions/browser/api/runtime/runtime_api.cc

Issue 1282263002: Restrict chrome.runtime.setUninstallURL to http(s) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small cleanup Created 5 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
Index: extensions/browser/api/runtime/runtime_api.cc
diff --git a/extensions/browser/api/runtime/runtime_api.cc b/extensions/browser/api/runtime/runtime_api.cc
index 09ffef2c864b5d6d902beb76f8d51d6eba2fc33e..443f93682b6d46cb3e054fa930516c7ebe2e2eac 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -54,7 +54,7 @@ const char kInstallReasonUpdate[] = "update";
const char kInstallReasonInstall[] = "install";
const char kInstallReasonSharedModuleUpdate[] = "shared_module_update";
const char kInstallPreviousVersion[] = "previousVersion";
-const char kInvalidUrlError[] = "Invalid URL.";
+const char kInvalidUrlError[] = "Invalid URL: \"*\".";
const char kPlatformInfoUnavailable[] = "Platform information unavailable.";
const char kUpdatesDisabledError[] = "Autoupdate is not enabled.";
@@ -405,8 +405,11 @@ void RuntimeEventRouter::OnExtensionUninstalled(
GURL uninstall_url(
GetUninstallURL(ExtensionPrefs::Get(context), extension_id));
- if (uninstall_url.is_empty())
+ if (!uninstall_url.SchemeIsHTTPOrHTTPS()) {
+ // Previous versions of Chrome allowed non-http(s) URLs to be stored in the
+ // prefs. Now they're disallowed, but the old data may still exist.
return;
+ }
RuntimeAPI::GetFactoryInstance()->Get(context)->OpenURL(uninstall_url);
}
@@ -448,10 +451,8 @@ ExtensionFunction::ResponseAction RuntimeSetUninstallURLFunction::Run() {
std::string url_string;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string));
- GURL url(url_string);
- if (!url.is_valid()) {
- return RespondNow(
- Error(ErrorUtils::FormatErrorMessage(kInvalidUrlError, url_string)));
+ if (!url_string.empty() && !GURL(url_string).SchemeIsHTTPOrHTTPS()) {
+ return RespondNow(Error(kInvalidUrlError, url_string));
}
SetUninstallURL(
ExtensionPrefs::Get(browser_context()), extension_id(), url_string);
« no previous file with comments | « chrome/test/data/extensions/api_test/runtime/uninstall_url/test.js ('k') | extensions/common/api/runtime.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698