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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/permissions/settings_override_permission.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h"
12 namespace extensions
{
14 SettingsOverrideAPIPermission::SettingsOverrideAPIPermission(
15 const APIPermissionInfo
* permission
, const std::string
& setting_value
)
16 : APIPermission(permission
),
17 setting_value_(setting_value
) {
20 SettingsOverrideAPIPermission::~SettingsOverrideAPIPermission() {
23 bool SettingsOverrideAPIPermission::HasMessages() const {
24 return info()->message_id() > PermissionMessage::kNone
;
27 PermissionMessages
SettingsOverrideAPIPermission::GetMessages() const {
28 DCHECK(HasMessages());
32 string_id
= IDS_EXTENSION_PROMPT_WARNING_HOME_PAGE_SETTING_OVERRIDE
;
36 string_id
= IDS_EXTENSION_PROMPT_WARNING_START_PAGE_SETTING_OVERRIDE
;
39 case kSearchProvider
: {
40 string_id
= IDS_EXTENSION_PROMPT_WARNING_SEARCH_SETTINGS_OVERRIDE
;
46 PermissionMessages result
;
47 result
.push_back(PermissionMessage(
49 l10n_util::GetStringFUTF16(string_id
,
50 base::UTF8ToUTF16(setting_value_
))));
54 bool SettingsOverrideAPIPermission::Check(
55 const APIPermission::CheckParam
* param
) const {
59 bool SettingsOverrideAPIPermission::Contains(const APIPermission
* rhs
) const {
60 CHECK(info() == rhs
->info());
64 bool SettingsOverrideAPIPermission::Equal(const APIPermission
* rhs
) const {
67 CHECK(info() == rhs
->info());
71 bool SettingsOverrideAPIPermission::FromValue(const base::Value
* value
) {
77 scoped_ptr
<base::Value
> SettingsOverrideAPIPermission::ToValue() const {
78 return scoped_ptr
<base::Value
>();
81 APIPermission
* SettingsOverrideAPIPermission::Clone() const {
82 return new SettingsOverrideAPIPermission(info(), setting_value_
);
85 APIPermission
* SettingsOverrideAPIPermission::Diff(
86 const APIPermission
* rhs
) const {
87 CHECK(info() == rhs
->info());
91 APIPermission
* SettingsOverrideAPIPermission::Union(
92 const APIPermission
* rhs
) const {
93 CHECK(info() == rhs
->info());
94 return new SettingsOverrideAPIPermission(info(), setting_value_
);
97 APIPermission
* SettingsOverrideAPIPermission::Intersect(
98 const APIPermission
* rhs
) const {
99 CHECK(info() == rhs
->info());
100 return new SettingsOverrideAPIPermission(info(), setting_value_
);
103 void SettingsOverrideAPIPermission::Write(IPC::Message
* m
) const {
106 bool SettingsOverrideAPIPermission::Read(
107 const IPC::Message
* m
, PickleIterator
* iter
) {
111 void SettingsOverrideAPIPermission::Log(std::string
* log
) const {
114 } // namespace extensions