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

Side by Side Diff: chrome/common/extensions/extension_messages.cc

Issue 10073011: Fix the optional permissions API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/extension_messages.h" 5 #include "chrome/common/extensions/extension_messages.h"
6 6
7 #include "chrome/common/extensions/extension_constants.h" 7 #include "chrome/common/extensions/extension_constants.h"
8 #include "chrome/common/extensions/manifest.h" 8 #include "chrome/common/extensions/manifest.h"
9 #include "content/public/common/common_param_traits.h" 9 #include "content/public/common/common_param_traits.h"
10 10
11 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() 11 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
12 : location(Extension::INVALID), 12 : location(Extension::INVALID),
13 creation_flags(Extension::NO_FLAGS){} 13 creation_flags(Extension::NO_FLAGS){}
14 14
15 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} 15 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {}
16 16
17 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( 17 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
18 const Extension* extension) 18 const Extension* extension)
19 : manifest(extension->manifest()->value()->DeepCopy()), 19 : manifest(extension->manifest()->value()->DeepCopy()),
20 location(extension->location()), 20 location(extension->location()),
21 path(extension->path()), 21 path(extension->path()),
22 apis(extension->GetActivePermissions()->apis()),
23 explicit_hosts(extension->GetActivePermissions()->explicit_hosts()),
24 scriptable_hosts(extension->GetActivePermissions()->scriptable_hosts()),
22 id(extension->id()), 25 id(extension->id()),
23 creation_flags(extension->creation_flags()) { 26 creation_flags(extension->creation_flags()) {
24 } 27 }
25 28
26 scoped_refptr<Extension> 29 scoped_refptr<Extension>
27 ExtensionMsg_Loaded_Params::ConvertToExtension() const { 30 ExtensionMsg_Loaded_Params::ConvertToExtension() const {
28 std::string error; 31 std::string error;
29 32
30 scoped_refptr<Extension> extension( 33 scoped_refptr<Extension> extension(
31 Extension::Create(path, location, *manifest, creation_flags, 34 Extension::Create(path, location, *manifest, creation_flags,
32 &error)); 35 &error));
33 if (!extension.get()) 36 if (!extension.get()) {
34 DLOG(ERROR) << "Error deserializing extension: " << error; 37 DLOG(ERROR) << "Error deserializing extension: " << error;
38 return extension;
39 }
35 40
41 extension->SetActivePermissions(
42 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts));
36 return extension; 43 return extension;
37 } 44 }
38 45
39 namespace IPC { 46 namespace IPC {
40 47
41 template <> 48 template <>
42 struct ParamTraits<Extension::Location> { 49 struct ParamTraits<Extension::Location> {
43 typedef Extension::Location param_type; 50 typedef Extension::Location param_type;
44 static void Write(Message* m, const param_type& p) { 51 static void Write(Message* m, const param_type& p) {
45 int val = static_cast<int>(p); 52 int val = static_cast<int>(p);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const param_type& p, std::string* l) { 133 const param_type& p, std::string* l) {
127 LogParam(static_cast<int>(p), l); 134 LogParam(static_cast<int>(p), l);
128 } 135 }
129 136
130 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, 137 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
131 const param_type& p) { 138 const param_type& p) {
132 WriteParam(m, p.location); 139 WriteParam(m, p.location);
133 WriteParam(m, p.path); 140 WriteParam(m, p.path);
134 WriteParam(m, *(p.manifest)); 141 WriteParam(m, *(p.manifest));
135 WriteParam(m, p.creation_flags); 142 WriteParam(m, p.creation_flags);
143 WriteParam(m, p.apis);
144 WriteParam(m, p.explicit_hosts);
145 WriteParam(m, p.scriptable_hosts);
136 } 146 }
137 147
138 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m, 148 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const Message* m,
139 PickleIterator* iter, 149 PickleIterator* iter,
140 param_type* p) { 150 param_type* p) {
141 p->manifest.reset(new DictionaryValue()); 151 p->manifest.reset(new DictionaryValue());
142 return ReadParam(m, iter, &p->location) && 152 return ReadParam(m, iter, &p->location) &&
143 ReadParam(m, iter, &p->path) && 153 ReadParam(m, iter, &p->path) &&
144 ReadParam(m, iter, p->manifest.get()) && 154 ReadParam(m, iter, p->manifest.get()) &&
145 ReadParam(m, iter, &p->creation_flags); 155 ReadParam(m, iter, &p->creation_flags) &&
156 ReadParam(m, iter, &p->apis) &&
157 ReadParam(m, iter, &p->explicit_hosts) &&
158 ReadParam(m, iter, &p->scriptable_hosts);
146 } 159 }
147 160
148 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, 161 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p,
149 std::string* l) { 162 std::string* l) {
150 l->append(p.id); 163 l->append(p.id);
151 } 164 }
152 165
153 } // namespace IPC 166 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698