Index: extensions/common/permissions/manifest_permission.cc |
diff --git a/extensions/common/permissions/manifest_permission.cc b/extensions/common/permissions/manifest_permission.cc |
index b15c541467da6056ff5d529037f6d47e08eb28e5..09c640c075feb974585bed5e39f10b9dc0228e86 100644 |
--- a/extensions/common/permissions/manifest_permission.cc |
+++ b/extensions/common/permissions/manifest_permission.cc |
@@ -4,10 +4,53 @@ |
#include "extensions/common/permissions/manifest_permission.h" |
+#include "base/json/json_writer.h" |
+#include "extensions/common/manifest_handler.h" |
+#include "ipc/ipc_message.h" |
+#include "ipc/ipc_message_utils.h" |
+ |
namespace extensions { |
ManifestPermission::ManifestPermission() {} |
ManifestPermission::~ManifestPermission() { } |
+ManifestPermission* ManifestPermission::Clone() const { |
+ 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.
|
+ if (!clone->FromValue(ToValue().get())) |
+ NOTREACHED() << "Could not convert back from Value"; |
+ return clone; |
+} |
+ |
+bool ManifestPermission::Contains(const ManifestPermission* rhs) const { |
+ 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.
|
+} |
+ |
+bool ManifestPermission::Equal(const ManifestPermission* rhs) const { |
+ return ToValue()->Equals(rhs->ToValue().get()); |
+} |
+ |
+void ManifestPermission::Write(IPC::Message* m) const { |
+ base::ListValue singleton; |
+ base::Value* value = ToValue().release(); |
+ singleton.Append(value); |
+ IPC::WriteParam(m, singleton); |
+} |
+ |
+bool ManifestPermission::Read(const IPC::Message* m, PickleIterator* iter) { |
+ base::ListValue singleton; |
+ if (!IPC::ReadParam(m, iter, &singleton)) |
+ return false; |
+ if (singleton.GetSize() != 1) |
+ return false; |
+ base::Value* value = NULL; |
+ if (!singleton.Get(0, &value)) |
+ return false; |
+ return FromValue(value); |
+} |
+ |
+void ManifestPermission::Log(std::string* log) const { |
+ base::JSONWriter::Write(ToValue().get(), log); |
+} |
+ |
} // namespace extensions |