| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/common/extension_messages.h" | 5 #include "extensions/common/extension_messages.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} | 57 ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} |
| 58 | 58 |
| 59 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( | 59 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( |
| 60 const Extension* extension, | 60 const Extension* extension, |
| 61 bool include_tab_permissions) | 61 bool include_tab_permissions) |
| 62 : manifest(extension->manifest()->value()->DeepCopy()), | 62 : manifest(extension->manifest()->value()->DeepCopy()), |
| 63 location(extension->location()), | 63 location(extension->location()), |
| 64 path(extension->path()), | 64 path(extension->path()), |
| 65 active_permissions(extension->permissions_data()->active_permissions()), | 65 active_permissions(extension->permissions_data()->active_permissions()), |
| 66 withheld_permissions(extension->permissions_data() | 66 withheld_permissions( |
| 67 ->withheld_permissions()), | 67 extension->permissions_data()->withheld_permissions()), |
| 68 runtime_blocked_hosts( |
| 69 extension->permissions_data()->runtime_blocked_hosts()), |
| 70 runtime_allowed_hosts( |
| 71 extension->permissions_data()->runtime_allowed_hosts()), |
| 68 id(extension->id()), | 72 id(extension->id()), |
| 69 creation_flags(extension->creation_flags()) { | 73 creation_flags(extension->creation_flags()) { |
| 70 if (include_tab_permissions) { | 74 if (include_tab_permissions) { |
| 71 for (const auto& pair : | 75 for (const auto& pair : |
| 72 extension->permissions_data()->tab_specific_permissions()) { | 76 extension->permissions_data()->tab_specific_permissions()) { |
| 73 tab_specific_permissions[pair.first] = | 77 tab_specific_permissions[pair.first] = |
| 74 ExtensionMsg_PermissionSetStruct(*pair.second); | 78 ExtensionMsg_PermissionSetStruct(*pair.second); |
| 75 } | 79 } |
| 76 } | 80 } |
| 77 } | 81 } |
| 78 | 82 |
| 79 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( | 83 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( |
| 80 const ExtensionMsg_Loaded_Params& other) = default; | 84 const ExtensionMsg_Loaded_Params& other) = default; |
| 81 | 85 |
| 82 scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( | 86 scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( |
| 83 std::string* error) const { | 87 std::string* error) const { |
| 84 // We pass in the |id| to the create call because it will save work in the | 88 // We pass in the |id| to the create call because it will save work in the |
| 85 // normal case, and because in tests, extensions may not have paths or keys, | 89 // normal case, and because in tests, extensions may not have paths or keys, |
| 86 // but it's important to retain the same id. | 90 // but it's important to retain the same id. |
| 87 scoped_refptr<Extension> extension = | 91 scoped_refptr<Extension> extension = |
| 88 Extension::Create(path, location, *manifest, creation_flags, id, error); | 92 Extension::Create(path, location, *manifest, creation_flags, id, error); |
| 89 if (extension.get()) { | 93 if (extension.get()) { |
| 90 const extensions::PermissionsData* permissions_data = | 94 const extensions::PermissionsData* permissions_data = |
| 91 extension->permissions_data(); | 95 extension->permissions_data(); |
| 92 permissions_data->SetPermissions(active_permissions.ToPermissionSet(), | 96 permissions_data->SetPermissions(active_permissions.ToPermissionSet(), |
| 93 withheld_permissions.ToPermissionSet()); | 97 withheld_permissions.ToPermissionSet()); |
| 98 permissions_data->SetRuntimeBlockedAllowedHosts(runtime_blocked_hosts, |
| 99 runtime_allowed_hosts); |
| 94 for (const auto& pair : tab_specific_permissions) { | 100 for (const auto& pair : tab_specific_permissions) { |
| 95 permissions_data->UpdateTabSpecificPermissions( | 101 permissions_data->UpdateTabSpecificPermissions( |
| 96 pair.first, *pair.second.ToPermissionSet()); | 102 pair.first, *pair.second.ToPermissionSet()); |
| 97 } | 103 } |
| 98 } | 104 } |
| 99 return extension; | 105 return extension; |
| 100 } | 106 } |
| 101 | 107 |
| 102 namespace IPC { | 108 namespace IPC { |
| 103 | 109 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, | 380 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, |
| 375 const param_type& p) { | 381 const param_type& p) { |
| 376 WriteParam(m, p.location); | 382 WriteParam(m, p.location); |
| 377 WriteParam(m, p.path); | 383 WriteParam(m, p.path); |
| 378 WriteParam(m, *(p.manifest)); | 384 WriteParam(m, *(p.manifest)); |
| 379 WriteParam(m, p.creation_flags); | 385 WriteParam(m, p.creation_flags); |
| 380 WriteParam(m, p.id); | 386 WriteParam(m, p.id); |
| 381 WriteParam(m, p.active_permissions); | 387 WriteParam(m, p.active_permissions); |
| 382 WriteParam(m, p.withheld_permissions); | 388 WriteParam(m, p.withheld_permissions); |
| 383 WriteParam(m, p.tab_specific_permissions); | 389 WriteParam(m, p.tab_specific_permissions); |
| 390 WriteParam(m, p.runtime_blocked_hosts); |
| 391 WriteParam(m, p.runtime_allowed_hosts); |
| 384 } | 392 } |
| 385 | 393 |
| 386 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m, | 394 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m, |
| 387 base::PickleIterator* iter, | 395 base::PickleIterator* iter, |
| 388 param_type* p) { | 396 param_type* p) { |
| 389 p->manifest.reset(new base::DictionaryValue()); | 397 p->manifest.reset(new base::DictionaryValue()); |
| 390 return ReadParam(m, iter, &p->location) && ReadParam(m, iter, &p->path) && | 398 return ReadParam(m, iter, &p->location) && ReadParam(m, iter, &p->path) && |
| 391 ReadParam(m, iter, p->manifest.get()) && | 399 ReadParam(m, iter, p->manifest.get()) && |
| 392 ReadParam(m, iter, &p->creation_flags) && ReadParam(m, iter, &p->id) && | 400 ReadParam(m, iter, &p->creation_flags) && ReadParam(m, iter, &p->id) && |
| 393 ReadParam(m, iter, &p->active_permissions) && | 401 ReadParam(m, iter, &p->active_permissions) && |
| 394 ReadParam(m, iter, &p->withheld_permissions) && | 402 ReadParam(m, iter, &p->withheld_permissions) && |
| 395 ReadParam(m, iter, &p->tab_specific_permissions); | 403 ReadParam(m, iter, &p->tab_specific_permissions) && |
| 404 ReadParam(m, iter, &p->runtime_blocked_hosts) && |
| 405 ReadParam(m, iter, &p->runtime_allowed_hosts); |
| 396 } | 406 } |
| 397 | 407 |
| 398 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, | 408 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, |
| 399 std::string* l) { | 409 std::string* l) { |
| 400 l->append(p.id); | 410 l->append(p.id); |
| 401 } | 411 } |
| 402 | 412 |
| 403 } // namespace IPC | 413 } // namespace IPC |
| OLD | NEW |