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 "grit/extensions_strings.h"
9 #include "ui/base/l10n/l10n_util.h"
11 namespace extensions
{
13 SettingsOverrideAPIPermission::SettingsOverrideAPIPermission(
14 const APIPermissionInfo
* permission
,
15 const std::string
& setting_value
)
16 : APIPermission(permission
), setting_value_(setting_value
) {}
18 SettingsOverrideAPIPermission::~SettingsOverrideAPIPermission() {}
20 bool SettingsOverrideAPIPermission::HasMessages() const {
21 return info()->message_id() > PermissionMessage::kNone
;
24 PermissionMessages
SettingsOverrideAPIPermission::GetMessages() const {
25 DCHECK(HasMessages());
29 string_id
= IDS_EXTENSION_PROMPT_WARNING_HOME_PAGE_SETTING_OVERRIDE
;
33 string_id
= IDS_EXTENSION_PROMPT_WARNING_START_PAGE_SETTING_OVERRIDE
;
36 case kSearchProvider
: {
37 string_id
= IDS_EXTENSION_PROMPT_WARNING_SEARCH_SETTINGS_OVERRIDE
;
43 PermissionMessages result
;
45 PermissionMessage(info()->message_id(),
46 l10n_util::GetStringFUTF16(
47 string_id
, base::UTF8ToUTF16(setting_value_
))));
51 bool SettingsOverrideAPIPermission::Check(
52 const APIPermission::CheckParam
* param
) const {
53 return (param
== NULL
);
56 bool SettingsOverrideAPIPermission::Contains(const APIPermission
* rhs
) const {
57 CHECK_EQ(info(), rhs
->info());
61 bool SettingsOverrideAPIPermission::Equal(const APIPermission
* rhs
) const {
63 CHECK_EQ(info(), rhs
->info());
67 bool SettingsOverrideAPIPermission::FromValue(
68 const base::Value
* value
,
69 std::string
* /*error*/,
70 std::vector
<std::string
>* unhandled_permissions
) {
71 return (value
== NULL
);
74 scoped_ptr
<base::Value
> SettingsOverrideAPIPermission::ToValue() const {
75 return scoped_ptr
<base::Value
>();
78 APIPermission
* SettingsOverrideAPIPermission::Clone() const {
79 return new SettingsOverrideAPIPermission(info(), setting_value_
);
82 APIPermission
* SettingsOverrideAPIPermission::Diff(
83 const APIPermission
* rhs
) const {
84 CHECK_EQ(info(), rhs
->info());
88 APIPermission
* SettingsOverrideAPIPermission::Union(
89 const APIPermission
* rhs
) const {
90 CHECK_EQ(info(), rhs
->info());
91 return new SettingsOverrideAPIPermission(info(), setting_value_
);
94 APIPermission
* SettingsOverrideAPIPermission::Intersect(
95 const APIPermission
* rhs
) const {
96 CHECK_EQ(info(), rhs
->info());
97 return new SettingsOverrideAPIPermission(info(), setting_value_
);
100 void SettingsOverrideAPIPermission::Write(IPC::Message
* m
) const {}
102 bool SettingsOverrideAPIPermission::Read(const IPC::Message
* m
,
103 PickleIterator
* iter
) {
107 void SettingsOverrideAPIPermission::Log(std::string
* log
) const {}
109 } // namespace extensions