| 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 policy_blocked_hosts( |
| 69 extension->permissions_data()->policy_blocked_hosts()), |
| 70 policy_allowed_hosts( |
| 71 extension->permissions_data()->policy_allowed_hosts()), |
| 72 is_default_policy_blocked_allowed_hosts( |
| 73 extension->permissions_data()->UsesDefaultPolicyHostRestrictions()), |
| 68 id(extension->id()), | 74 id(extension->id()), |
| 69 creation_flags(extension->creation_flags()) { | 75 creation_flags(extension->creation_flags()) { |
| 70 if (include_tab_permissions) { | 76 if (include_tab_permissions) { |
| 71 for (const auto& pair : | 77 for (const auto& pair : |
| 72 extension->permissions_data()->tab_specific_permissions()) { | 78 extension->permissions_data()->tab_specific_permissions()) { |
| 73 tab_specific_permissions[pair.first] = | 79 tab_specific_permissions[pair.first] = |
| 74 ExtensionMsg_PermissionSetStruct(*pair.second); | 80 ExtensionMsg_PermissionSetStruct(*pair.second); |
| 75 } | 81 } |
| 76 } | 82 } |
| 77 } | 83 } |
| 78 | 84 |
| 79 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( | 85 ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( |
| 80 const ExtensionMsg_Loaded_Params& other) = default; | 86 const ExtensionMsg_Loaded_Params& other) = default; |
| 81 | 87 |
| 82 scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( | 88 scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( |
| 83 std::string* error) const { | 89 std::string* error) const { |
| 84 // We pass in the |id| to the create call because it will save work in the | 90 // 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, | 91 // normal case, and because in tests, extensions may not have paths or keys, |
| 86 // but it's important to retain the same id. | 92 // but it's important to retain the same id. |
| 87 scoped_refptr<Extension> extension = | 93 scoped_refptr<Extension> extension = |
| 88 Extension::Create(path, location, *manifest, creation_flags, id, error); | 94 Extension::Create(path, location, *manifest, creation_flags, id, error); |
| 89 if (extension.get()) { | 95 if (extension.get()) { |
| 90 const extensions::PermissionsData* permissions_data = | 96 const extensions::PermissionsData* permissions_data = |
| 91 extension->permissions_data(); | 97 extension->permissions_data(); |
| 92 permissions_data->SetPermissions(active_permissions.ToPermissionSet(), | 98 permissions_data->SetPermissions(active_permissions.ToPermissionSet(), |
| 93 withheld_permissions.ToPermissionSet()); | 99 withheld_permissions.ToPermissionSet()); |
| 100 permissions_data->SetPolicyHostRestrictions( |
| 101 policy_blocked_hosts, policy_allowed_hosts, |
| 102 is_default_policy_blocked_allowed_hosts); |
| 94 for (const auto& pair : tab_specific_permissions) { | 103 for (const auto& pair : tab_specific_permissions) { |
| 95 permissions_data->UpdateTabSpecificPermissions( | 104 permissions_data->UpdateTabSpecificPermissions( |
| 96 pair.first, *pair.second.ToPermissionSet()); | 105 pair.first, *pair.second.ToPermissionSet()); |
| 97 } | 106 } |
| 98 } | 107 } |
| 99 return extension; | 108 return extension; |
| 100 } | 109 } |
| 101 | 110 |
| 102 namespace IPC { | 111 namespace IPC { |
| 103 | 112 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 LogParam(p.type(), l); | 345 LogParam(p.type(), l); |
| 337 LogParam(p.id(), l); | 346 LogParam(p.id(), l); |
| 338 } | 347 } |
| 339 | 348 |
| 340 void ParamTraits<ExtensionMsg_PermissionSetStruct>::GetSize( | 349 void ParamTraits<ExtensionMsg_PermissionSetStruct>::GetSize( |
| 341 base::PickleSizer* s, const param_type& p) { | 350 base::PickleSizer* s, const param_type& p) { |
| 342 GetParamSize(s, p.apis); | 351 GetParamSize(s, p.apis); |
| 343 GetParamSize(s, p.manifest_permissions); | 352 GetParamSize(s, p.manifest_permissions); |
| 344 GetParamSize(s, p.explicit_hosts); | 353 GetParamSize(s, p.explicit_hosts); |
| 345 GetParamSize(s, p.scriptable_hosts); | 354 GetParamSize(s, p.scriptable_hosts); |
| 355 GetParamSize(s, p.policy_blocked_hosts); |
| 356 GetParamSize(s, p.policy_allowed_hosts); |
| 357 GetParamSize(s, p.uses_default_policy_host_restrictions); |
| 346 } | 358 } |
| 347 | 359 |
| 348 void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(base::Pickle* m, | 360 void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(base::Pickle* m, |
| 349 const param_type& p) { | 361 const param_type& p) { |
| 350 WriteParam(m, p.apis); | 362 WriteParam(m, p.apis); |
| 351 WriteParam(m, p.manifest_permissions); | 363 WriteParam(m, p.manifest_permissions); |
| 352 WriteParam(m, p.explicit_hosts); | 364 WriteParam(m, p.explicit_hosts); |
| 353 WriteParam(m, p.scriptable_hosts); | 365 WriteParam(m, p.scriptable_hosts); |
| 366 WriteParam(m, p.policy_blocked_hosts); |
| 367 WriteParam(m, p.policy_allowed_hosts); |
| 368 WriteParam(m, p.uses_default_policy_host_restrictions); |
| 354 } | 369 } |
| 355 | 370 |
| 356 bool ParamTraits<ExtensionMsg_PermissionSetStruct>::Read( | 371 bool ParamTraits<ExtensionMsg_PermissionSetStruct>::Read( |
| 357 const base::Pickle* m, | 372 const base::Pickle* m, |
| 358 base::PickleIterator* iter, | 373 base::PickleIterator* iter, |
| 359 param_type* p) { | 374 param_type* p) { |
| 360 return ReadParam(m, iter, &p->apis) && | 375 return ReadParam(m, iter, &p->apis) && |
| 361 ReadParam(m, iter, &p->manifest_permissions) && | 376 ReadParam(m, iter, &p->manifest_permissions) && |
| 362 ReadParam(m, iter, &p->explicit_hosts) && | 377 ReadParam(m, iter, &p->explicit_hosts) && |
| 363 ReadParam(m, iter, &p->scriptable_hosts); | 378 ReadParam(m, iter, &p->scriptable_hosts) && |
| 379 ReadParam(m, iter, &p->policy_blocked_hosts) && |
| 380 ReadParam(m, iter, &p->policy_allowed_hosts) && |
| 381 ReadParam(m, iter, &p->uses_default_policy_host_restrictions); |
| 364 } | 382 } |
| 365 | 383 |
| 366 void ParamTraits<ExtensionMsg_PermissionSetStruct>::Log(const param_type& p, | 384 void ParamTraits<ExtensionMsg_PermissionSetStruct>::Log(const param_type& p, |
| 367 std::string* l) { | 385 std::string* l) { |
| 368 LogParam(p.apis, l); | 386 LogParam(p.apis, l); |
| 369 LogParam(p.manifest_permissions, l); | 387 LogParam(p.manifest_permissions, l); |
| 370 LogParam(p.explicit_hosts, l); | 388 LogParam(p.explicit_hosts, l); |
| 371 LogParam(p.scriptable_hosts, l); | 389 LogParam(p.scriptable_hosts, l); |
| 390 LogParam(p.policy_blocked_hosts, l); |
| 391 LogParam(p.policy_allowed_hosts, l); |
| 392 LogParam(p.uses_default_policy_host_restrictions, l); |
| 372 } | 393 } |
| 373 | 394 |
| 374 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, | 395 void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, |
| 375 const param_type& p) { | 396 const param_type& p) { |
| 376 WriteParam(m, p.location); | 397 WriteParam(m, p.location); |
| 377 WriteParam(m, p.path); | 398 WriteParam(m, p.path); |
| 378 WriteParam(m, *(p.manifest)); | 399 WriteParam(m, *(p.manifest)); |
| 379 WriteParam(m, p.creation_flags); | 400 WriteParam(m, p.creation_flags); |
| 380 WriteParam(m, p.id); | 401 WriteParam(m, p.id); |
| 381 WriteParam(m, p.active_permissions); | 402 WriteParam(m, p.active_permissions); |
| 382 WriteParam(m, p.withheld_permissions); | 403 WriteParam(m, p.withheld_permissions); |
| 383 WriteParam(m, p.tab_specific_permissions); | 404 WriteParam(m, p.tab_specific_permissions); |
| 405 WriteParam(m, p.policy_blocked_hosts); |
| 406 WriteParam(m, p.policy_allowed_hosts); |
| 407 WriteParam(m, p.is_default_policy_blocked_allowed_hosts); |
| 384 } | 408 } |
| 385 | 409 |
| 386 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m, | 410 bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m, |
| 387 base::PickleIterator* iter, | 411 base::PickleIterator* iter, |
| 388 param_type* p) { | 412 param_type* p) { |
| 389 p->manifest.reset(new base::DictionaryValue()); | 413 p->manifest.reset(new base::DictionaryValue()); |
| 390 return ReadParam(m, iter, &p->location) && ReadParam(m, iter, &p->path) && | 414 return ReadParam(m, iter, &p->location) && ReadParam(m, iter, &p->path) && |
| 391 ReadParam(m, iter, p->manifest.get()) && | 415 ReadParam(m, iter, p->manifest.get()) && |
| 392 ReadParam(m, iter, &p->creation_flags) && ReadParam(m, iter, &p->id) && | 416 ReadParam(m, iter, &p->creation_flags) && ReadParam(m, iter, &p->id) && |
| 393 ReadParam(m, iter, &p->active_permissions) && | 417 ReadParam(m, iter, &p->active_permissions) && |
| 394 ReadParam(m, iter, &p->withheld_permissions) && | 418 ReadParam(m, iter, &p->withheld_permissions) && |
| 395 ReadParam(m, iter, &p->tab_specific_permissions); | 419 ReadParam(m, iter, &p->tab_specific_permissions) && |
| 420 ReadParam(m, iter, &p->policy_blocked_hosts) && |
| 421 ReadParam(m, iter, &p->policy_allowed_hosts) && |
| 422 ReadParam(m, iter, &p->is_default_policy_blocked_allowed_hosts); |
| 396 } | 423 } |
| 397 | 424 |
| 398 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, | 425 void ParamTraits<ExtensionMsg_Loaded_Params>::Log(const param_type& p, |
| 399 std::string* l) { | 426 std::string* l) { |
| 400 l->append(p.id); | 427 l->append(p.id); |
| 401 } | 428 } |
| 402 | 429 |
| 403 } // namespace IPC | 430 } // namespace IPC |
| OLD | NEW |