Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / common / permissions / settings_override_permission.cc
blobb4cec3c0e0b5ea632791c02734dc494555733e3e
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
3 // found in the LICENSE file.
5 #include "extensions/common/permissions/settings_override_permission.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "extensions/common/permissions/api_permission_set.h"
9 #include "grit/extensions_strings.h"
10 #include "ui/base/l10n/l10n_util.h"
12 namespace extensions {
14 SettingsOverrideAPIPermission::SettingsOverrideAPIPermission(
15 const APIPermissionInfo* permission,
16 const std::string& setting_value)
17 : APIPermission(permission), setting_value_(setting_value) {}
19 SettingsOverrideAPIPermission::~SettingsOverrideAPIPermission() {}
21 PermissionIDSet SettingsOverrideAPIPermission::GetPermissions() const {
22 PermissionIDSet permissions;
23 permissions.insert(info()->id(), base::UTF8ToUTF16(setting_value_));
24 return permissions;
27 bool SettingsOverrideAPIPermission::Check(
28 const APIPermission::CheckParam* param) const {
29 return (param == NULL);
32 bool SettingsOverrideAPIPermission::Contains(const APIPermission* rhs) const {
33 CHECK_EQ(info(), rhs->info());
34 return true;
37 bool SettingsOverrideAPIPermission::Equal(const APIPermission* rhs) const {
38 if (this != rhs)
39 CHECK_EQ(info(), rhs->info());
40 return true;
43 bool SettingsOverrideAPIPermission::FromValue(
44 const base::Value* value,
45 std::string* /*error*/,
46 std::vector<std::string>* unhandled_permissions) {
47 return (value == NULL);
50 scoped_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const {
51 return scoped_ptr<base::Value>();
54 APIPermission* SettingsOverrideAPIPermission::Clone() const {
55 return new SettingsOverrideAPIPermission(info(), setting_value_);
58 APIPermission* SettingsOverrideAPIPermission::Diff(
59 const APIPermission* rhs) const {
60 CHECK_EQ(info(), rhs->info());
61 return NULL;
64 APIPermission* SettingsOverrideAPIPermission::Union(
65 const APIPermission* rhs) const {
66 CHECK_EQ(info(), rhs->info());
67 return new SettingsOverrideAPIPermission(info(), setting_value_);
70 APIPermission* SettingsOverrideAPIPermission::Intersect(
71 const APIPermission* rhs) const {
72 CHECK_EQ(info(), rhs->info());
73 return new SettingsOverrideAPIPermission(info(), setting_value_);
76 void SettingsOverrideAPIPermission::Write(IPC::Message* m) const {}
78 bool SettingsOverrideAPIPermission::Read(const IPC::Message* m,
79 base::PickleIterator* iter) {
80 return true;
83 void SettingsOverrideAPIPermission::Log(std::string* log) const {}
85 } // namespace extensions