Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/permissions/manifest_permission.h" | 5 #include "extensions/common/permissions/manifest_permission.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | |
| 8 #include "extensions/common/manifest_handler.h" | |
| 9 #include "ipc/ipc_message.h" | |
| 10 #include "ipc/ipc_message_utils.h" | |
| 11 | |
| 7 namespace extensions { | 12 namespace extensions { |
| 8 | 13 |
| 9 ManifestPermission::ManifestPermission() {} | 14 ManifestPermission::ManifestPermission() {} |
| 10 | 15 |
| 11 ManifestPermission::~ManifestPermission() { } | 16 ManifestPermission::~ManifestPermission() { } |
| 12 | 17 |
| 18 ManifestPermission* ManifestPermission::Clone() const { | |
| 19 ManifestPermission* clone = ManifestHandler::CreatePermission(name()); | |
|
not at google - send to devlin
2014/07/18 22:02:18
you could implement Clone() via Union with this, r
aboxhall
2014/07/18 22:38:16
SGTM, done.
| |
| 20 if (!clone->FromValue(ToValue().get())) | |
| 21 NOTREACHED() << "Could not convert back from Value"; | |
| 22 return clone; | |
| 23 } | |
| 24 | |
| 25 bool ManifestPermission::Contains(const ManifestPermission* rhs) const { | |
| 26 return Intersect(rhs)->Equal(rhs); | |
|
not at google - send to devlin
2014/07/18 22:02:18
I think this is a leak, you need to wrap the resul
aboxhall
2014/07/18 22:38:16
Done.
| |
| 27 } | |
| 28 | |
| 29 bool ManifestPermission::Equal(const ManifestPermission* rhs) const { | |
| 30 return ToValue()->Equals(rhs->ToValue().get()); | |
| 31 } | |
| 32 | |
| 33 void ManifestPermission::Write(IPC::Message* m) const { | |
| 34 base::ListValue singleton; | |
| 35 base::Value* value = ToValue().release(); | |
| 36 singleton.Append(value); | |
| 37 IPC::WriteParam(m, singleton); | |
| 38 } | |
| 39 | |
| 40 bool ManifestPermission::Read(const IPC::Message* m, PickleIterator* iter) { | |
| 41 base::ListValue singleton; | |
| 42 if (!IPC::ReadParam(m, iter, &singleton)) | |
| 43 return false; | |
| 44 if (singleton.GetSize() != 1) | |
| 45 return false; | |
| 46 base::Value* value = NULL; | |
| 47 if (!singleton.Get(0, &value)) | |
| 48 return false; | |
| 49 return FromValue(value); | |
| 50 } | |
| 51 | |
| 52 void ManifestPermission::Log(std::string* log) const { | |
| 53 base::JSONWriter::Write(ToValue().get(), log); | |
| 54 } | |
| 55 | |
| 13 } // namespace extensions | 56 } // namespace extensions |
| OLD | NEW |