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

Unified Diff: chrome/common/extensions/extension_messages.cc

Issue 7432006: Add an experimental permissions API for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang Created 9 years, 5 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/extensions/extension_messages.h ('k') | chrome/common/extensions/extension_permission_set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_messages.cc
diff --git a/chrome/common/extensions/extension_messages.cc b/chrome/common/extensions/extension_messages.cc
index b38823495e8a3d0631f460049570856c4bd35b61..fe88896287fa805f6745be8bba3f72b4d6467200 100644
--- a/chrome/common/extensions/extension_messages.cc
+++ b/chrome/common/extensions/extension_messages.cc
@@ -24,10 +24,14 @@ ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
}
ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
- const Extension* extension)
+ const Extension* extension,
+ const ExtensionPermissionSet* active)
: manifest(new DictionaryValue()),
location(extension->location()),
path(extension->path()),
+ apis(active->apis()),
+ explicit_hosts(active->explicit_hosts()),
+ scriptable_hosts(active->scriptable_hosts()),
id(extension->id()),
creation_flags(extension->creation_flags()) {
// As we need more bits of extension data in the renderer, add more keys to
@@ -65,6 +69,11 @@ scoped_refptr<Extension>
return extension;
}
+const ExtensionPermissionSet*
+ ExtensionMsg_Loaded_Params::GetActivePermissions() const {
+ return new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts);
+}
+
namespace IPC {
template <>
@@ -101,8 +110,15 @@ bool ParamTraits<URLPattern>::Read(const Message* m, void** iter,
!ReadParam(m, iter, &spec))
return false;
+ // TODO(jstritar): We don't want the URLPattern to fail parsing when the
+ // scheme is invalid. Instead, the pattern should parse but it should not
+ // match the invalid patterns. We get around this by setting the valid
+ // schemes after parsing the pattern. Update these method calls once we can
+ // ignore scheme validation with URLPattern parse options. crbug.com/90544
+ p->SetValidSchemes(URLPattern::SCHEME_ALL);
+ URLPattern::ParseResult result = p->Parse(spec, URLPattern::IGNORE_PORTS);
p->SetValidSchemes(valid_schemes);
- return URLPattern::PARSE_SUCCESS == p->Parse(spec, URLPattern::IGNORE_PORTS);
+ return URLPattern::PARSE_SUCCESS == result;
}
void ParamTraits<URLPattern>::Log(const param_type& p, std::string* l) {
@@ -116,9 +132,7 @@ void ParamTraits<URLPatternSet>::Write(Message* m, const param_type& p) {
bool ParamTraits<URLPatternSet>::Read(const Message* m, void** iter,
param_type* p) {
std::set<URLPattern> patterns;
- bool success =
- ReadParam(m, iter, &patterns);
- if (!success)
+ if (!ReadParam(m, iter, &patterns))
return false;
for (std::set<URLPattern>::iterator i = patterns.begin();
@@ -131,12 +145,35 @@ void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) {
LogParam(p.patterns(), l);
}
+void ParamTraits<ExtensionAPIPermission::ID>::Write(
+ Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p));
+}
+
+bool ParamTraits<ExtensionAPIPermission::ID>::Read(
+ const Message* m, void** iter, param_type* p) {
+ int api_id = -2;
+ if (!ReadParam(m, iter, &api_id))
+ return false;
+
+ *p = static_cast<ExtensionAPIPermission::ID>(api_id);
+ return true;
+}
+
+void ParamTraits<ExtensionAPIPermission::ID>::Log(
+ const param_type& p, std::string* l) {
+ LogParam(static_cast<int>(p), l);
+}
+
void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
const param_type& p) {
WriteParam(m, p.location);
WriteParam(m, p.path);
WriteParam(m, *(p.manifest));
WriteParam(m, p.creation_flags);
+ WriteParam(m, p.apis);
+ WriteParam(m, p.explicit_hosts);
+ WriteParam(m, p.scriptable_hosts);
}
bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m,
@@ -146,7 +183,10 @@ bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m,
return ReadParam(m, iter, &p->location) &&
ReadParam(m, iter, &p->path) &&
ReadParam(m, iter, p->manifest.get()) &&
- ReadParam(m, iter, &p->creation_flags);
+ ReadParam(m, iter, &p->creation_flags) &&
+ ReadParam(m, iter, &p->apis) &&
+ ReadParam(m, iter, &p->explicit_hosts) &&
+ ReadParam(m, iter, &p->scriptable_hosts);
}
void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p,
« no previous file with comments | « chrome/common/extensions/extension_messages.h ('k') | chrome/common/extensions/extension_permission_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698