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

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

Issue 7619011: Simplify ExtensionMsg_Loaded_Params message interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/common_param_traits.h" 8 #include "content/common/common_param_traits.h"
9 9
10 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() 10 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
11 : location(Extension::INVALID) { 11 : location(Extension::INVALID) {}
12 }
13 12
14 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() { 13 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {}
15 }
16 14
17 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( 15 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
18 const ExtensionMsg_Loaded_Params& other) 16 const ExtensionMsg_Loaded_Params& other)
19 : manifest(other.manifest->DeepCopy()), 17 : manifest(other.manifest->DeepCopy()),
20 location(other.location), 18 location(other.location),
21 path(other.path), 19 path(other.path),
20 apis(other.apis),
21 explicit_hosts(other.explicit_hosts),
22 scriptable_hosts(other.scriptable_hosts),
22 id(other.id), 23 id(other.id),
23 creation_flags(other.creation_flags) { 24 creation_flags(other.creation_flags) {}
24 }
25 25
26 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( 26 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
27 const Extension* extension, 27 const Extension* extension)
28 const ExtensionPermissionSet* active)
29 : manifest(new DictionaryValue()), 28 : manifest(new DictionaryValue()),
30 location(extension->location()), 29 location(extension->location()),
31 path(extension->path()), 30 path(extension->path()),
32 apis(active->apis()), 31 apis(extension->GetActivePermissions()->apis()),
33 explicit_hosts(active->explicit_hosts()), 32 explicit_hosts(extension->GetActivePermissions()->explicit_hosts()),
34 scriptable_hosts(active->scriptable_hosts()), 33 scriptable_hosts(extension->GetActivePermissions()->scriptable_hosts()),
35 id(extension->id()), 34 id(extension->id()),
36 creation_flags(extension->creation_flags()) { 35 creation_flags(extension->creation_flags()) {
37 // As we need more bits of extension data in the renderer, add more keys to 36 // As we need more bits of extension data in the renderer, add more keys to
38 // this list. 37 // this list.
39 const char* kRendererExtensionKeys[] = { 38 const char* kRendererExtensionKeys[] = {
40 extension_manifest_keys::kPublicKey, 39 extension_manifest_keys::kPublicKey,
41 extension_manifest_keys::kName, 40 extension_manifest_keys::kName,
42 extension_manifest_keys::kVersion, 41 extension_manifest_keys::kVersion,
43 extension_manifest_keys::kIcons, 42 extension_manifest_keys::kIcons,
44 extension_manifest_keys::kPageAction, 43 extension_manifest_keys::kPageAction,
(...skipping 13 matching lines...) Expand all
58 57
59 scoped_refptr<Extension> 58 scoped_refptr<Extension>
60 ExtensionMsg_Loaded_Params::ConvertToExtension() const { 59 ExtensionMsg_Loaded_Params::ConvertToExtension() const {
61 std::string error; 60 std::string error;
62 61
63 scoped_refptr<Extension> extension( 62 scoped_refptr<Extension> extension(
64 Extension::Create(path, location, *manifest, creation_flags, 63 Extension::Create(path, location, *manifest, creation_flags,
65 &error)); 64 &error));
66 if (!extension.get()) 65 if (!extension.get())
67 LOG(ERROR) << "Error deserializing extension: " << error; 66 LOG(ERROR) << "Error deserializing extension: " << error;
67 else
68 extension->SetActivePermissions(
69 new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts));
68 70
69 return extension; 71 return extension;
70 } 72 }
71 73
72 const ExtensionPermissionSet*
73 ExtensionMsg_Loaded_Params::GetActivePermissions() const {
74 return new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts);
75 }
76
77 namespace IPC { 74 namespace IPC {
78 75
79 template <> 76 template <>
80 struct ParamTraits<Extension::Location> { 77 struct ParamTraits<Extension::Location> {
81 typedef Extension::Location param_type; 78 typedef Extension::Location param_type;
82 static void Write(Message* m, const param_type& p) { 79 static void Write(Message* m, const param_type& p) {
83 int val = static_cast<int>(p); 80 int val = static_cast<int>(p);
84 WriteParam(m, val); 81 WriteParam(m, val);
85 } 82 }
86 static bool Read(const Message* m, void** iter, param_type* p) { 83 static bool Read(const Message* m, void** iter, param_type* p) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 ReadParam(m, iter, &p->explicit_hosts) && 185 ReadParam(m, iter, &p->explicit_hosts) &&
189 ReadParam(m, iter, &p->scriptable_hosts); 186 ReadParam(m, iter, &p->scriptable_hosts);
190 } 187 }
191 188
192 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, 189 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p,
193 std::string* l) { 190 std::string* l) {
194 l->append(p.id); 191 l->append(p.id);
195 } 192 }
196 193
197 } // namespace IPC 194 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_messages.h ('k') | chrome/renderer/extensions/extension_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698