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

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

Issue 10675007: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase again Created 8 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 unified diff | Download patch
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.h" 7 #include "chrome/common/extensions/extension.h"
8 #include "chrome/common/extensions/extension_constants.h" 8 #include "chrome/common/extensions/extension_constants.h"
9 #include "chrome/common/extensions/manifest.h" 9 #include "chrome/common/extensions/manifest.h"
10 #include "content/public/common/common_param_traits.h" 10 #include "content/public/common/common_param_traits.h"
11 11
12 using extensions::APIPermission;
12 using extensions::Extension; 13 using extensions::Extension;
14 using extensions::PermissionSet;
13 15
14 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() 16 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
15 : location(Extension::INVALID), 17 : location(Extension::INVALID),
16 creation_flags(Extension::NO_FLAGS){} 18 creation_flags(Extension::NO_FLAGS){}
17 19
18 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} 20 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {}
19 21
20 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( 22 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
21 const Extension* extension) 23 const Extension* extension)
22 : manifest(extension->manifest()->value()->DeepCopy()), 24 : manifest(extension->manifest()->value()->DeepCopy()),
(...skipping 12 matching lines...) Expand all
35 37
36 scoped_refptr<Extension> extension( 38 scoped_refptr<Extension> extension(
37 Extension::Create(path, location, *manifest, creation_flags, 39 Extension::Create(path, location, *manifest, creation_flags,
38 &error)); 40 &error));
39 if (!extension.get()) { 41 if (!extension.get()) {
40 DLOG(ERROR) << "Error deserializing extension: " << error; 42 DLOG(ERROR) << "Error deserializing extension: " << error;
41 return extension; 43 return extension;
42 } 44 }
43 45
44 extension->SetActivePermissions( 46 extension->SetActivePermissions(
45 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts)); 47 new PermissionSet(apis, explicit_hosts, scriptable_hosts));
46 48
47 return extension; 49 return extension;
48 } 50 }
49 51
50 namespace IPC { 52 namespace IPC {
51 53
52 template <> 54 template <>
53 struct ParamTraits<Extension::Location> { 55 struct ParamTraits<Extension::Location> {
54 typedef Extension::Location param_type; 56 typedef Extension::Location param_type;
55 static void Write(Message* m, const param_type& p) { 57 static void Write(Message* m, const param_type& p) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 for (std::set<URLPattern>::iterator i = patterns.begin(); 113 for (std::set<URLPattern>::iterator i = patterns.begin();
112 i != patterns.end(); ++i) 114 i != patterns.end(); ++i)
113 p->AddPattern(*i); 115 p->AddPattern(*i);
114 return true; 116 return true;
115 } 117 }
116 118
117 void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) { 119 void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) {
118 LogParam(p.patterns(), l); 120 LogParam(p.patterns(), l);
119 } 121 }
120 122
121 void ParamTraits<ExtensionAPIPermission::ID>::Write( 123 void ParamTraits<APIPermission::ID>::Write(
122 Message* m, const param_type& p) { 124 Message* m, const param_type& p) {
123 WriteParam(m, static_cast<int>(p)); 125 WriteParam(m, static_cast<int>(p));
124 } 126 }
125 127
126 bool ParamTraits<ExtensionAPIPermission::ID>::Read( 128 bool ParamTraits<APIPermission::ID>::Read(
127 const Message* m, PickleIterator* iter, param_type* p) { 129 const Message* m, PickleIterator* iter, param_type* p) {
128 int api_id = -2; 130 int api_id = -2;
129 if (!ReadParam(m, iter, &api_id)) 131 if (!ReadParam(m, iter, &api_id))
130 return false; 132 return false;
131 133
132 *p = static_cast<ExtensionAPIPermission::ID>(api_id); 134 *p = static_cast<APIPermission::ID>(api_id);
133 return true; 135 return true;
134 } 136 }
135 137
136 void ParamTraits<ExtensionAPIPermission::ID>::Log( 138 void ParamTraits<APIPermission::ID>::Log(
137 const param_type& p, std::string* l) { 139 const param_type& p, std::string* l) {
138 LogParam(static_cast<int>(p), l); 140 LogParam(static_cast<int>(p), l);
139 } 141 }
140 142
141 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, 143 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
142 const param_type& p) { 144 const param_type& p) {
143 WriteParam(m, p.location); 145 WriteParam(m, p.location);
144 WriteParam(m, p.path); 146 WriteParam(m, p.path);
145 WriteParam(m, *(p.manifest)); 147 WriteParam(m, *(p.manifest));
146 WriteParam(m, p.creation_flags); 148 WriteParam(m, p.creation_flags);
(...skipping 14 matching lines...) Expand all
161 ReadParam(m, iter, &p->explicit_hosts) && 163 ReadParam(m, iter, &p->explicit_hosts) &&
162 ReadParam(m, iter, &p->scriptable_hosts); 164 ReadParam(m, iter, &p->scriptable_hosts);
163 } 165 }
164 166
165 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, 167 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p,
166 std::string* l) { 168 std::string* l) {
167 l->append(p.id); 169 l->append(p.id);
168 } 170 }
169 171
170 } // namespace IPC 172 } // namespace IPC
OLDNEW
« 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