OLD | NEW |
---|---|
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/public/common/common_param_traits.h" | 8 #include "content/public/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 creation_flags(Extension::NO_FLAGS){} | 12 creation_flags(Extension::NO_FLAGS){} |
13 | 13 |
14 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} | 14 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} |
15 | 15 |
16 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( | 16 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( |
17 const ExtensionMsg_Loaded_Params& other) | 17 const ExtensionMsg_Loaded_Params& other) |
18 : manifest(other.manifest->DeepCopy()), | 18 : location(other.location), |
19 location(other.location), | |
20 path(other.path), | 19 path(other.path), |
21 apis(other.apis), | 20 apis(other.apis), |
22 explicit_hosts(other.explicit_hosts), | 21 explicit_hosts(other.explicit_hosts), |
23 scriptable_hosts(other.scriptable_hosts), | 22 scriptable_hosts(other.scriptable_hosts), |
24 id(other.id), | 23 id(other.id), |
25 creation_flags(other.creation_flags) {} | 24 creation_flags(other.creation_flags) { |
25 // ipc_message_utils.h calls resize() on vector, which might briefly | |
26 // construct a struct missing a valid manifest. | |
27 if (other.manifest.get()) { | |
28 manifest.reset(other.manifest->DeepCopy()); | |
29 } | |
30 } | |
31 | |
32 ExtensionMsg_Loaded_Params& ExtensionMsg_Loaded_Params::operator=( | |
Aaron Boodman
2011/11/14 22:48:07
Hm, yeah, it does seem weird/unfortunate to need b
miket_OOO
2011/11/14 23:48:51
See #crx. mpcomplete suggested using linked_ptr, a
| |
33 const ExtensionMsg_Loaded_Params& other) { | |
34 manifest.reset(other.manifest->DeepCopy()); | |
35 location = other.location; | |
36 path = other.path; | |
37 apis = other.apis; | |
38 explicit_hosts = other.explicit_hosts; | |
39 scriptable_hosts = other.scriptable_hosts; | |
40 id = other.id; | |
41 creation_flags = other.creation_flags; | |
42 return *this; | |
43 } | |
26 | 44 |
27 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( | 45 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( |
28 const Extension* extension) | 46 const Extension* extension) |
29 : manifest(new DictionaryValue()), | 47 : manifest(new DictionaryValue()), |
30 location(extension->location()), | 48 location(extension->location()), |
31 path(extension->path()), | 49 path(extension->path()), |
32 apis(extension->GetActivePermissions()->apis()), | 50 apis(extension->GetActivePermissions()->apis()), |
33 explicit_hosts(extension->GetActivePermissions()->explicit_hosts()), | 51 explicit_hosts(extension->GetActivePermissions()->explicit_hosts()), |
34 scriptable_hosts(extension->GetActivePermissions()->scriptable_hosts()), | 52 scriptable_hosts(extension->GetActivePermissions()->scriptable_hosts()), |
35 id(extension->id()), | 53 id(extension->id()), |
36 creation_flags(extension->creation_flags()) { | 54 creation_flags(extension->creation_flags()) { |
37 // As we need more bits of extension data in the renderer, add more keys to | 55 // As we need more bits of extension data in the renderer, add more keys to |
38 // this list. | 56 // this list. |
39 const char* kRendererExtensionKeys[] = { | 57 const char* kRendererExtensionKeys[] = { |
40 extension_manifest_keys::kPublicKey, | 58 extension_manifest_keys::kApp, |
59 extension_manifest_keys::kContentScripts, | |
60 extension_manifest_keys::kIcons, | |
41 extension_manifest_keys::kName, | 61 extension_manifest_keys::kName, |
42 extension_manifest_keys::kVersion, | |
43 extension_manifest_keys::kIcons, | |
44 extension_manifest_keys::kPageAction, | 62 extension_manifest_keys::kPageAction, |
45 extension_manifest_keys::kPageActions, | 63 extension_manifest_keys::kPageActions, |
46 extension_manifest_keys::kPermissions, | 64 extension_manifest_keys::kPermissions, |
47 extension_manifest_keys::kApp, | 65 extension_manifest_keys::kPlatformApp, |
48 extension_manifest_keys::kContentScripts | 66 extension_manifest_keys::kPublicKey, |
67 extension_manifest_keys::kVersion, | |
49 }; | 68 }; |
50 | 69 |
51 // Copy only the data we need. | 70 // Copy only the data we need. |
52 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRendererExtensionKeys); ++i) { | 71 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRendererExtensionKeys); ++i) { |
53 Value* temp = NULL; | 72 Value* temp = NULL; |
54 if (extension->manifest_value()->Get(kRendererExtensionKeys[i], &temp)) | 73 if (extension->manifest_value()->Get(kRendererExtensionKeys[i], &temp)) |
55 manifest->Set(kRendererExtensionKeys[i], temp->DeepCopy()); | 74 manifest->Set(kRendererExtensionKeys[i], temp->DeepCopy()); |
56 } | 75 } |
57 } | 76 } |
58 | 77 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 ReadParam(m, iter, &p->explicit_hosts) && | 205 ReadParam(m, iter, &p->explicit_hosts) && |
187 ReadParam(m, iter, &p->scriptable_hosts); | 206 ReadParam(m, iter, &p->scriptable_hosts); |
188 } | 207 } |
189 | 208 |
190 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, | 209 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, |
191 std::string* l) { | 210 std::string* l) { |
192 l->append(p.id); | 211 l->append(p.id); |
193 } | 212 } |
194 | 213 |
195 } // namespace IPC | 214 } // namespace IPC |
OLD | NEW |