1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/common/permissions/settings_override_permission.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "grit/extensions_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace extensions {
SettingsOverrideAPIPermission::SettingsOverrideAPIPermission(
const APIPermissionInfo* permission)
: APIPermission(permission) {}
SettingsOverrideAPIPermission::SettingsOverrideAPIPermission(
const APIPermissionInfo* permission,
const std::string& setting_value)
: APIPermission(permission), setting_value_(setting_value) {}
SettingsOverrideAPIPermission::~SettingsOverrideAPIPermission() {}
PermissionIDSet SettingsOverrideAPIPermission::GetPermissions() const {
PermissionIDSet permissions;
permissions.insert(info()->id(), base::UTF8ToUTF16(setting_value_));
return permissions;
}
bool SettingsOverrideAPIPermission::Check(
const APIPermission::CheckParam* param) const {
return (param == NULL);
}
bool SettingsOverrideAPIPermission::Contains(const APIPermission* rhs) const {
CHECK_EQ(info(), rhs->info());
return true;
}
bool SettingsOverrideAPIPermission::Equal(const APIPermission* rhs) const {
if (this != rhs)
CHECK_EQ(info(), rhs->info());
return true;
}
bool SettingsOverrideAPIPermission::FromValue(
const base::Value* value,
std::string* /*error*/,
std::vector<std::string>* unhandled_permissions) {
return value && value->GetAsString(&setting_value_);
}
scoped_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const {
return make_scoped_ptr(new base::StringValue(setting_value_));
}
APIPermission* SettingsOverrideAPIPermission::Clone() const {
return new SettingsOverrideAPIPermission(info(), setting_value_);
}
APIPermission* SettingsOverrideAPIPermission::Diff(
const APIPermission* rhs) const {
CHECK_EQ(info(), rhs->info());
return NULL;
}
APIPermission* SettingsOverrideAPIPermission::Union(
const APIPermission* rhs) const {
CHECK_EQ(info(), rhs->info());
return new SettingsOverrideAPIPermission(info(), setting_value_);
}
APIPermission* SettingsOverrideAPIPermission::Intersect(
const APIPermission* rhs) const {
CHECK_EQ(info(), rhs->info());
return new SettingsOverrideAPIPermission(info(), setting_value_);
}
void SettingsOverrideAPIPermission::Write(base::Pickle* m) const {}
bool SettingsOverrideAPIPermission::Read(const base::Pickle* m,
base::PickleIterator* iter) {
return true;
}
void SettingsOverrideAPIPermission::Log(std::string* log) const {
*log = setting_value_;
}
} // namespace extensions
|