| OLD | NEW |
| 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 "chrome/common/extensions/permissions/permissions_info.h" | 10 #include "chrome/common/extensions/permissions/permissions_info.h" |
| 11 #include "content/public/common/common_param_traits.h" | 11 #include "content/public/common/common_param_traits.h" |
| 12 | 12 |
| 13 using extensions::APIPermission; | 13 using extensions::APIPermission; |
| 14 using extensions::APIPermissionInfo; | 14 using extensions::APIPermissionInfo; |
| 15 using extensions::APIPermissionMap; | 15 using extensions::APIPermissionMap; |
| 16 using extensions::APIPermissionSet; | 16 using extensions::APIPermissionSet; |
| 17 using extensions::Extension; | 17 using extensions::Extension; |
| 18 using extensions::Manifest; |
| 18 using extensions::PermissionSet; | 19 using extensions::PermissionSet; |
| 19 using extensions::URLPatternSet; | 20 using extensions::URLPatternSet; |
| 20 | 21 |
| 21 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() | 22 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() |
| 22 : location(Extension::INVALID), | 23 : location(Manifest::INVALID_LOCATION), |
| 23 creation_flags(Extension::NO_FLAGS){} | 24 creation_flags(Extension::NO_FLAGS){} |
| 24 | 25 |
| 25 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} | 26 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} |
| 26 | 27 |
| 27 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( | 28 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( |
| 28 const Extension* extension) | 29 const Extension* extension) |
| 29 : manifest(extension->manifest()->value()->DeepCopy()), | 30 : manifest(extension->manifest()->value()->DeepCopy()), |
| 30 location(extension->location()), | 31 location(extension->location()), |
| 31 path(extension->path()), | 32 path(extension->path()), |
| 32 apis(extension->GetActivePermissions()->apis()), | 33 apis(extension->GetActivePermissions()->apis()), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 50 | 51 |
| 51 extension->SetActivePermissions( | 52 extension->SetActivePermissions( |
| 52 new PermissionSet(apis, explicit_hosts, scriptable_hosts)); | 53 new PermissionSet(apis, explicit_hosts, scriptable_hosts)); |
| 53 | 54 |
| 54 return extension; | 55 return extension; |
| 55 } | 56 } |
| 56 | 57 |
| 57 namespace IPC { | 58 namespace IPC { |
| 58 | 59 |
| 59 template <> | 60 template <> |
| 60 struct ParamTraits<Extension::Location> { | 61 struct ParamTraits<Manifest::Location> { |
| 61 typedef Extension::Location param_type; | 62 typedef Manifest::Location param_type; |
| 62 static void Write(Message* m, const param_type& p) { | 63 static void Write(Message* m, const param_type& p) { |
| 63 int val = static_cast<int>(p); | 64 int val = static_cast<int>(p); |
| 64 WriteParam(m, val); | 65 WriteParam(m, val); |
| 65 } | 66 } |
| 66 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | 67 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { |
| 67 int val = 0; | 68 int val = 0; |
| 68 if (!ReadParam(m, iter, &val) || | 69 if (!ReadParam(m, iter, &val) || |
| 69 val < Extension::INVALID || | 70 val < Manifest::INVALID_LOCATION || |
| 70 val >= Extension::NUM_LOCATIONS) | 71 val >= Manifest::NUM_LOCATIONS) |
| 71 return false; | 72 return false; |
| 72 *p = static_cast<param_type>(val); | 73 *p = static_cast<param_type>(val); |
| 73 return true; | 74 return true; |
| 74 } | 75 } |
| 75 static void Log(const param_type& p, std::string* l) { | 76 static void Log(const param_type& p, std::string* l) { |
| 76 ParamTraits<int>::Log(static_cast<int>(p), l); | 77 ParamTraits<int>::Log(static_cast<int>(p), l); |
| 77 } | 78 } |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 void ParamTraits<URLPattern>::Write(Message* m, const param_type& p) { | 81 void ParamTraits<URLPattern>::Write(Message* m, const param_type& p) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ReadParam(m, iter, &p->explicit_hosts) && | 211 ReadParam(m, iter, &p->explicit_hosts) && |
| 211 ReadParam(m, iter, &p->scriptable_hosts); | 212 ReadParam(m, iter, &p->scriptable_hosts); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, | 215 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, |
| 215 std::string* l) { | 216 std::string* l) { |
| 216 l->append(p.id); | 217 l->append(p.id); |
| 217 } | 218 } |
| 218 | 219 |
| 219 } // namespace IPC | 220 } // namespace IPC |
| OLD | NEW |