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

Unified Diff: chrome/common/pepper_permission_util.cc

Issue 17029002: Change the permission check for Pepper socket API to support both the public and private APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/common/pepper_permission_util.h ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/pepper_permission_util.cc
diff --git a/chrome/common/pepper_permission_util.cc b/chrome/common/pepper_permission_util.cc
index 84992d4b1553a122aa1884480b77e660da28e35e..b34e4574424b605a151567245f3bf6bcfe411c10 100644
--- a/chrome/common/pepper_permission_util.cc
+++ b/chrome/common/pepper_permission_util.cc
@@ -37,16 +37,13 @@ bool HostIsInSet(const std::string& host, const std::set<std::string>& set) {
bool IsExtensionOrSharedModuleWhitelisted(
const GURL& url,
const ExtensionSet* extension_set,
- const std::set<std::string>& whitelist,
- const char* command_line_switch) {
- const std::string host = url.host();
- if (!url.is_valid())
+ const std::set<std::string>& whitelist) {
+ if (!url.is_valid() || !url.SchemeIs(extensions::kExtensionScheme))
return false;
- if (url.SchemeIs(extensions::kExtensionScheme) &&
- HostIsInSet(host, whitelist)) {
+ const std::string host = url.host();
+ if (HostIsInSet(host, whitelist))
return true;
- }
// Check the modules that are imported by this extension to see if any of them
// is whitelisted.
@@ -69,22 +66,37 @@ bool IsExtensionOrSharedModuleWhitelisted(
}
}
+ return false;
+}
+
+bool IsHostAllowedByCommandLine(const GURL& url,
+ const ExtensionSet* extension_set,
+ const char* command_line_switch) {
+ if (!url.is_valid())
+ return false;
+
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
const std::string allowed_list =
command_line.GetSwitchValueASCII(command_line_switch);
+ if (allowed_list.empty())
+ return false;
+
+ const std::string host = url.host();
if (allowed_list == "*") {
// For now, we only allow packaged and platform apps in this wildcard.
+ if (!extension_set || !url.SchemeIs(extensions::kExtensionScheme))
+ return false;
+
+ const Extension* extension = extension_set->GetByID(host);
return extension &&
(extension->GetType() == Manifest::TYPE_LEGACY_PACKAGED_APP ||
extension->GetType() == Manifest::TYPE_PLATFORM_APP);
}
- if (!allowed_list.empty()) {
- base::StringTokenizer t(allowed_list, ",");
- while (t.GetNext()) {
- if (t.token() == host)
- return true;
- }
+ base::StringTokenizer t(allowed_list, ",");
+ while (t.GetNext()) {
+ if (t.token() == host)
+ return true;
}
return false;
« no previous file with comments | « chrome/common/pepper_permission_util.h ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698