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" | 7 #include "base/json/json_writer.h" |
8 #include "extensions/common/manifest_handler.h" | 8 #include "extensions/common/manifest_handler.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ipc/ipc_message_utils.h" | 10 #include "ipc/ipc_message_utils.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 bool ManifestPermission::Contains(const ManifestPermission* rhs) const { | 22 bool ManifestPermission::Contains(const ManifestPermission* rhs) const { |
23 return std::unique_ptr<ManifestPermission>(Intersect(rhs))->Equal(rhs); | 23 return std::unique_ptr<ManifestPermission>(Intersect(rhs))->Equal(rhs); |
24 } | 24 } |
25 | 25 |
26 bool ManifestPermission::Equal(const ManifestPermission* rhs) const { | 26 bool ManifestPermission::Equal(const ManifestPermission* rhs) const { |
27 return ToValue()->Equals(rhs->ToValue().get()); | 27 return ToValue()->Equals(rhs->ToValue().get()); |
28 } | 28 } |
29 | 29 |
30 void ManifestPermission::GetSize(base::PickleSizer* s) const { | 30 void ManifestPermission::GetSize(base::PickleSizer* s) const { |
31 base::ListValue singleton; | 31 base::ListValue singleton; |
32 base::Value* value = ToValue().release(); | 32 singleton.Append(ToValue()); |
33 singleton.Append(value); | |
34 IPC::GetParamSize(s, singleton); | 33 IPC::GetParamSize(s, singleton); |
35 } | 34 } |
36 | 35 |
37 void ManifestPermission::Write(base::Pickle* m) const { | 36 void ManifestPermission::Write(base::Pickle* m) const { |
38 base::ListValue singleton; | 37 base::ListValue singleton; |
39 base::Value* value = ToValue().release(); | 38 singleton.Append(ToValue()); |
40 singleton.Append(value); | |
41 IPC::WriteParam(m, singleton); | 39 IPC::WriteParam(m, singleton); |
42 } | 40 } |
43 | 41 |
44 bool ManifestPermission::Read(const base::Pickle* m, | 42 bool ManifestPermission::Read(const base::Pickle* m, |
45 base::PickleIterator* iter) { | 43 base::PickleIterator* iter) { |
46 base::ListValue singleton; | 44 base::ListValue singleton; |
47 if (!IPC::ReadParam(m, iter, &singleton)) | 45 if (!IPC::ReadParam(m, iter, &singleton)) |
48 return false; | 46 return false; |
49 if (singleton.GetSize() != 1) | 47 if (singleton.GetSize() != 1) |
50 return false; | 48 return false; |
51 base::Value* value = NULL; | 49 base::Value* value = NULL; |
52 if (!singleton.Get(0, &value)) | 50 if (!singleton.Get(0, &value)) |
53 return false; | 51 return false; |
54 return FromValue(value); | 52 return FromValue(value); |
55 } | 53 } |
56 | 54 |
57 void ManifestPermission::Log(std::string* log) const { | 55 void ManifestPermission::Log(std::string* log) const { |
58 base::JSONWriter::WriteWithOptions( | 56 base::JSONWriter::WriteWithOptions( |
59 *ToValue(), base::JSONWriter::OPTIONS_PRETTY_PRINT, log); | 57 *ToValue(), base::JSONWriter::OPTIONS_PRETTY_PRINT, log); |
60 } | 58 } |
61 | 59 |
62 } // namespace extensions | 60 } // namespace extensions |
OLD | NEW |