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

Side by Side Diff: chrome/browser/protector/base_setting_change.h

Issue 9968007: [protector] Support for collapsing multiple changes into a single one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tried to compile after merge. Created 8 years, 8 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ 5 #ifndef CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_
6 #define CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ 6 #define CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <utility>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "chrome/browser/tabs/pinned_tab_codec.h" 14 #include "chrome/browser/tabs/pinned_tab_codec.h"
15 15
16 class Browser; 16 class Browser;
17 class Profile; 17 class Profile;
18 class TemplateURL; 18 class TemplateURL;
19 struct SessionStartupPref; 19 struct SessionStartupPref;
20 20
21 namespace protector { 21 namespace protector {
22 22
23 class CompositeSettingsChange;
24
23 // Base class for setting change tracked by Protector. 25 // Base class for setting change tracked by Protector.
24 class BaseSettingChange { 26 class BaseSettingChange {
25 public: 27 public:
28 // Pair consisting of a display name representing either new or backup setting
29 // and priority for it. Priority is used for composite changes, consisting
30 // of multiple BaseSettingChange instances - the display name with the highest
31 // priority is used.
32 typedef std::pair<size_t, string16> DisplayName;
33
34 // Default priority value.
35 static const size_t kDefaultNamePriority;
36
26 BaseSettingChange(); 37 BaseSettingChange();
27 virtual ~BaseSettingChange(); 38 virtual ~BaseSettingChange();
28 39
40 // Merges |this| with |other| and returns a CompositeSettingsChange instance.
41 // Returned instance takes ownership of |other|.
42 // Init should not be called for the returned instance.
43 // |this| may be another CompositeSettingsChange, in which case |other| is
44 // simply added to it and |this| is returned. |other| cannot be
45 // CompositeSettingsChange.
46 virtual CompositeSettingsChange* MergeWith(BaseSettingChange* other);
47
48 // Returns true if |this| is a result of merging some changes with |other|.
49 virtual bool Contains(const BaseSettingChange* other) const;
50
29 // Applies initial actions to the setting if needed. Must be called before 51 // Applies initial actions to the setting if needed. Must be called before
30 // any other calls are made, including text getters. 52 // any other calls are made, including text getters.
31 // Returns true if initialization was successful. 53 // Returns true if initialization was successful.
32 // Associates this change with |profile| instance so overrides must call the 54 // Associates this change with |profile| instance so overrides must call the
33 // base method. 55 // base method.
34 virtual bool Init(Profile* profile); 56 virtual bool Init(Profile* profile);
35 57
36 // Persists new setting if needed. |browser| is the Browser instance from 58 // Persists new setting if needed. |browser| is the Browser instance from
37 // which the user action originates. 59 // which the user action originates.
38 virtual void Apply(Browser* browser); 60 virtual void Apply(Browser* browser);
(...skipping 20 matching lines...) Expand all
59 // Returns the bubble message text. 81 // Returns the bubble message text.
60 virtual string16 GetBubbleMessage() const = 0; 82 virtual string16 GetBubbleMessage() const = 0;
61 83
62 // Returns text for the button to apply the change with |Apply|. 84 // Returns text for the button to apply the change with |Apply|.
63 // Returns empty string if no apply button should be shown. 85 // Returns empty string if no apply button should be shown.
64 virtual string16 GetApplyButtonText() const = 0; 86 virtual string16 GetApplyButtonText() const = 0;
65 87
66 // Returns text for the button to discard the change with |Discard|. 88 // Returns text for the button to discard the change with |Discard|.
67 virtual string16 GetDiscardButtonText() const = 0; 89 virtual string16 GetDiscardButtonText() const = 0;
68 90
91 // Returns the display name and priority for the new setting. If multiple
92 // BaseSettingChange instances are collapsed into MulipleSettingChange
93 // instance, the display name with the highest priority will be used for the
94 // Apply button (Discard button will have a generic caption in that case).
95 // Returns an empty string if there is no specific representaion for new
whywhat 2012/04/06 16:28:32 s/representaion/representation The function return
Ivan Korotkov 2012/04/09 14:46:47 Done.
96 // setting value and a generic string should be used.
97 virtual DisplayName GetApplyDisplayName() const;
98
99 // Returns a keyword uniquely identifying new (to be applied) settings.
100 // BaseSettingChange instances with the same keyword may be collapsed into
101 // a single MulipleSettingChange instance. Empty keywords are not considered
whywhat 2012/04/06 16:28:32 When do we have an empty keyword? When we don't kn
Ivan Korotkov 2012/04/09 14:46:47 For settings which are not clear how to merge with
102 // to be equal.
103 virtual std::string GetApplyKeyword() const;
104
69 protected: 105 protected:
70 // Profile instance we've been associated with by an |Init| call. 106 // Profile instance we've been associated with by an |Init| call.
71 Profile* profile() { return profile_; } 107 Profile* profile() { return profile_; }
72 108
73 private: 109 private:
74 Profile* profile_; 110 Profile* profile_;
75 111
76 DISALLOW_COPY_AND_ASSIGN(BaseSettingChange); 112 DISALLOW_COPY_AND_ASSIGN(BaseSettingChange);
77 }; 113 };
78 114
(...skipping 17 matching lines...) Expand all
96 const SessionStartupPref& backup_startup_pref, 132 const SessionStartupPref& backup_startup_pref,
97 const PinnedTabCodec::Tabs& backup_pinned_tabs); 133 const PinnedTabCodec::Tabs& backup_pinned_tabs);
98 134
99 // Allocates and initializes BaseSettingChange implementation for an unknown 135 // Allocates and initializes BaseSettingChange implementation for an unknown
100 // preferences change with invalid backup. 136 // preferences change with invalid backup.
101 BaseSettingChange* CreatePrefsBackupInvalidChange(); 137 BaseSettingChange* CreatePrefsBackupInvalidChange();
102 138
103 } // namespace protector 139 } // namespace protector
104 140
105 #endif // CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ 141 #endif // CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698