Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/protector/composite_settings_change.cc

Issue 11493003: Remove the protector service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix implicit ExtensionSystem -> TemplateURLService dependency Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "chrome/browser/protector/composite_settings_change.h"
6
7 #include "grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h"
9
10 namespace protector {
11
12
13 CompositeSettingsChange::CompositeSettingsChange() {
14 }
15
16 CompositeSettingsChange::~CompositeSettingsChange() {
17 }
18
19 CompositeSettingsChange* CompositeSettingsChange::MergeWith(
20 BaseSettingChange* other) {
21 DCHECK(profile());
22 DCHECK(other);
23 changes_.push_back(other);
24 apply_names_.push(other->GetApplyDisplayName());
25 return this;
26 }
27
28 bool CompositeSettingsChange::Contains(const BaseSettingChange* other) const {
29 return this == other ||
30 std::find(changes_.begin(), changes_.end(), other) != changes_.end();
31 }
32
33 // Apart from PrefsBackupInvalidChange, which should never appear with other
34 // Preferences-related changes together, the Apply/Discard logic of change
35 // classes does not overlap, so it's safe to call them in any order.
36
37 void CompositeSettingsChange::Apply(Browser* browser) {
38 DVLOG(1) << "Apply all changes";
39 for (size_t i = 0; i < changes_.size(); ++i)
40 changes_[i]->Apply(browser);
41 }
42
43 void CompositeSettingsChange::Discard(Browser* browser) {
44 DVLOG(1) << "Discard all changes";
45 for (size_t i = 0; i < changes_.size(); ++i)
46 changes_[i]->Discard(browser);
47 }
48
49 void CompositeSettingsChange::Timeout() {
50 DVLOG(1) << "Timeout all changes";
51 for (size_t i = 0; i < changes_.size(); ++i)
52 changes_[i]->Timeout();
53 }
54
55 int CompositeSettingsChange::GetBadgeIconID() const {
56 DCHECK(changes_.size());
57 // Use icons from the first change.
58 // TODO(ivankr): need something better, maybe a special icon.
59 return changes_[0]->GetBadgeIconID();
60 }
61
62 int CompositeSettingsChange::GetMenuItemIconID() const {
63 DCHECK(changes_.size());
64 return changes_[0]->GetMenuItemIconID();
65 }
66
67 int CompositeSettingsChange::GetBubbleIconID() const {
68 DCHECK(changes_.size());
69 return changes_[0]->GetBubbleIconID();
70 }
71
72 string16 CompositeSettingsChange::GetBubbleTitle() const {
73 return l10n_util::GetStringUTF16(IDS_SETTING_CHANGE_TITLE);
74 }
75
76 string16 CompositeSettingsChange::GetBubbleMessage() const {
77 // TODO(ivankr): indicate what kind of changes happened (i.e., "something
78 // tried to change your search engine, startup pages, etc.").
79 return l10n_util::GetStringUTF16(IDS_SETTING_CHANGE_BUBBLE_MESSAGE);
80 }
81
82 string16 CompositeSettingsChange::GetApplyButtonText() const {
83 DCHECK(apply_names_.size());
84 string16 apply_text = apply_names_.top().second;
85 return apply_text.empty() ?
86 l10n_util::GetStringUTF16(IDS_CHANGE_SETTING_NO_NAME) :
87 l10n_util::GetStringFUTF16(IDS_CHANGE_SETTING, apply_text);
88 }
89
90 string16 CompositeSettingsChange::GetDiscardButtonText() const {
91 return l10n_util::GetStringUTF16(IDS_KEEP_SETTING);
92 }
93
94 BaseSettingChange::DisplayName
95 CompositeSettingsChange::GetApplyDisplayName() const {
96 // CompositeSettingsChange should never be put inside another one.
97 NOTREACHED();
98 return BaseSettingChange::GetApplyDisplayName();
99 }
100
101 GURL CompositeSettingsChange::GetNewSettingURL() const {
102 DCHECK(changes_.size());
103 return changes_[0]->GetNewSettingURL();
104 }
105
106 bool CompositeSettingsChange::CanBeMerged() const {
107 // We did that already, why not do it again.
108 return true;
109 }
110
111 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/composite_settings_change.h ('k') | chrome/browser/protector/composite_settings_change_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698