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

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

Issue 10649003: 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 on HEAD 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::Extension; 12 using extensions::Extension;
13 using extensions::PermissionSet;
13 14
14 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() 15 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
15 : location(Extension::INVALID), 16 : location(Extension::INVALID),
16 creation_flags(Extension::NO_FLAGS){} 17 creation_flags(Extension::NO_FLAGS){}
17 18
18 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} 19 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {}
19 20
20 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( 21 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
21 const Extension* extension) 22 const Extension* extension)
22 : manifest(extension->manifest()->value()->DeepCopy()), 23 : manifest(extension->manifest()->value()->DeepCopy()),
(...skipping 12 matching lines...) Expand all
35 36
36 scoped_refptr<Extension> extension( 37 scoped_refptr<Extension> extension(
37 Extension::Create(path, location, *manifest, creation_flags, 38 Extension::Create(path, location, *manifest, creation_flags,
38 &error)); 39 &error));
39 if (!extension.get()) { 40 if (!extension.get()) {
40 DLOG(ERROR) << "Error deserializing extension: " << error; 41 DLOG(ERROR) << "Error deserializing extension: " << error;
41 return extension; 42 return extension;
42 } 43 }
43 44
44 extension->SetActivePermissions( 45 extension->SetActivePermissions(
45 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts)); 46 new PermissionSet(apis, explicit_hosts, scriptable_hosts));
46 47
47 return extension; 48 return extension;
48 } 49 }
49 50
50 namespace IPC { 51 namespace IPC {
51 52
52 template <> 53 template <>
53 struct ParamTraits<Extension::Location> { 54 struct ParamTraits<Extension::Location> {
54 typedef Extension::Location param_type; 55 typedef Extension::Location param_type;
55 static void Write(Message* m, const param_type& p) { 56 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(); 112 for (std::set<URLPattern>::iterator i = patterns.begin();
112 i != patterns.end(); ++i) 113 i != patterns.end(); ++i)
113 p->AddPattern(*i); 114 p->AddPattern(*i);
114 return true; 115 return true;
115 } 116 }
116 117
117 void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) { 118 void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) {
118 LogParam(p.patterns(), l); 119 LogParam(p.patterns(), l);
119 } 120 }
120 121
121 void ParamTraits<ExtensionAPIPermission::ID>::Write( 122 void ParamTraits<APIPermission::ID>::Write(
122 Message* m, const param_type& p) { 123 Message* m, const param_type& p) {
123 WriteParam(m, static_cast<int>(p)); 124 WriteParam(m, static_cast<int>(p));
124 } 125 }
125 126
126 bool ParamTraits<ExtensionAPIPermission::ID>::Read( 127 bool ParamTraits<APIPermission::ID>::Read(
127 const Message* m, PickleIterator* iter, param_type* p) { 128 const Message* m, PickleIterator* iter, param_type* p) {
128 int api_id = -2; 129 int api_id = -2;
129 if (!ReadParam(m, iter, &api_id)) 130 if (!ReadParam(m, iter, &api_id))
130 return false; 131 return false;
131 132
132 *p = static_cast<ExtensionAPIPermission::ID>(api_id); 133 *p = static_cast<APIPermission::ID>(api_id);
133 return true; 134 return true;
134 } 135 }
135 136
136 void ParamTraits<ExtensionAPIPermission::ID>::Log( 137 void ParamTraits<APIPermission::ID>::Log(
137 const param_type& p, std::string* l) { 138 const param_type& p, std::string* l) {
138 LogParam(static_cast<int>(p), l); 139 LogParam(static_cast<int>(p), l);
139 } 140 }
140 141
141 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m, 142 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(Message* m,
142 const param_type& p) { 143 const param_type& p) {
143 WriteParam(m, p.location); 144 WriteParam(m, p.location);
144 WriteParam(m, p.path); 145 WriteParam(m, p.path);
145 WriteParam(m, *(p.manifest)); 146 WriteParam(m, *(p.manifest));
146 WriteParam(m, p.creation_flags); 147 WriteParam(m, p.creation_flags);
(...skipping 14 matching lines...) Expand all
161 ReadParam(m, iter, &p->explicit_hosts) && 162 ReadParam(m, iter, &p->explicit_hosts) &&
162 ReadParam(m, iter, &p->scriptable_hosts); 163 ReadParam(m, iter, &p->scriptable_hosts);
163 } 164 }
164 165
165 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, 166 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p,
166 std::string* l) { 167 std::string* l) {
167 l->append(p.id); 168 l->append(p.id);
168 } 169 }
169 170
170 } // namespace IPC 171 } // 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