OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ | 5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ |
6 #define CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ | 6 #define CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "chrome/browser/prefs/session_startup_pref.h" | 9 #include "chrome/browser/prefs/session_startup_pref.h" |
10 | 10 |
11 namespace base { | |
12 class ListValue; | |
13 } | |
14 | |
11 // ResettableSettingsSnapshot captures some settings values at constructor. It | 15 // ResettableSettingsSnapshot captures some settings values at constructor. It |
12 // can calculate the difference between two snapshots. That is, modified fields. | 16 // can calculate the difference between two snapshots. That is, modified fields. |
13 class ResettableSettingsSnapshot { | 17 class ResettableSettingsSnapshot { |
14 public: | 18 public: |
19 typedef std::vector<std::pair<std::string, std::string> > ExtensionList; | |
battre
2013/09/12 14:03:14
Can you please describe the components of the pair
vasilii
2013/09/16 13:58:02
Done.
| |
15 // All types of settings handled by this class. | 20 // All types of settings handled by this class. |
16 enum Field { | 21 enum Field { |
17 STARTUP_URLS = 1 << 0, | 22 STARTUP_URLS = 1 << 0, |
18 STARTUP_TYPE = 1 << 1, | 23 STARTUP_TYPE = 1 << 1, |
19 HOMEPAGE = 1 << 2, | 24 HOMEPAGE = 1 << 2, |
20 HOMEPAGE_IS_NTP = 1 << 3, | 25 HOMEPAGE_IS_NTP = 1 << 3, |
21 DSE_URL = 1 << 4, | 26 DSE_URL = 1 << 4, |
22 EXTENSIONS = 1 << 5, | 27 EXTENSIONS = 1 << 5, |
23 | 28 |
24 ALL_FIELDS = STARTUP_URLS | STARTUP_TYPE | HOMEPAGE | | 29 ALL_FIELDS = STARTUP_URLS | STARTUP_TYPE | HOMEPAGE | |
25 HOMEPAGE_IS_NTP | DSE_URL | EXTENSIONS, | 30 HOMEPAGE_IS_NTP | DSE_URL | EXTENSIONS, |
26 }; | 31 }; |
27 | 32 |
28 explicit ResettableSettingsSnapshot(Profile* profile); | 33 explicit ResettableSettingsSnapshot(Profile* profile); |
29 ~ResettableSettingsSnapshot(); | 34 ~ResettableSettingsSnapshot(); |
30 | 35 |
31 // Getters. | 36 // Getters. |
32 const std::vector<GURL>& startup_urls() const { return startup_.urls; } | 37 const std::vector<GURL>& startup_urls() const { return startup_.urls; } |
33 | 38 |
34 SessionStartupPref::Type startup_type() const { return startup_.type; } | 39 SessionStartupPref::Type startup_type() const { return startup_.type; } |
35 | 40 |
36 const std::string& homepage() const { return homepage_; } | 41 const std::string& homepage() const { return homepage_; } |
37 | 42 |
38 bool homepage_is_ntp() const { return homepage_is_ntp_; } | 43 bool homepage_is_ntp() const { return homepage_is_ntp_; } |
39 | 44 |
40 const std::string& dse_url() const { return dse_url_; } | 45 const std::string& dse_url() const { return dse_url_; } |
41 | 46 |
42 const std::vector<std::string>& enabled_extensions() const { | 47 const ExtensionList& enabled_extensions() const { |
43 return enabled_extensions_; | 48 return enabled_extensions_; |
44 } | 49 } |
45 | 50 |
46 // Substitutes |startup_.urls| with |startup_.urls|\|snapshot.startup_.urls|. | 51 // Substitutes |startup_.urls| with |startup_.urls|\|snapshot.startup_.urls|. |
47 // Substitutes |enabled_extensions_| with | 52 // Substitutes |enabled_extensions_| with |
48 // |enabled_extensions_|\|snapshot.enabled_extensions_|. | 53 // |enabled_extensions_|\|snapshot.enabled_extensions_|. |
49 void Subtract(const ResettableSettingsSnapshot& snapshot); | 54 void Subtract(const ResettableSettingsSnapshot& snapshot); |
50 | 55 |
51 // For each member 'm' compares |this->m| with |snapshot.m| and sets the | 56 // For each member 'm' compares |this->m| with |snapshot.m| and sets the |
52 // corresponding |ResetableSettingsSnapshot::Field| bit to 1 in case of | 57 // corresponding |ResetableSettingsSnapshot::Field| bit to 1 in case of |
53 // difference. | 58 // difference. |
54 // The return value is a bit mask of Field values signifying which members | 59 // The return value is a bit mask of Field values signifying which members |
55 // were different. | 60 // were different. |
56 int FindDifferentFields(const ResettableSettingsSnapshot& snapshot) const; | 61 int FindDifferentFields(const ResettableSettingsSnapshot& snapshot) const; |
57 | 62 |
58 private: | 63 private: |
59 // Startup pages. URLs are always stored sorted. | 64 // Startup pages. URLs are always stored sorted. |
60 SessionStartupPref startup_; | 65 SessionStartupPref startup_; |
61 | 66 |
62 std::string homepage_; | 67 std::string homepage_; |
63 bool homepage_is_ntp_; | 68 bool homepage_is_ntp_; |
64 | 69 |
65 // Default search engine. | 70 // Default search engine. |
66 std::string dse_url_; | 71 std::string dse_url_; |
67 | 72 |
68 // Enabled extension ids. Always sorted. | 73 // List of pairs [id, name] for enabled extensions. Always sorted. |
69 std::vector<std::string> enabled_extensions_; | 74 ExtensionList enabled_extensions_; |
70 | 75 |
71 DISALLOW_COPY_AND_ASSIGN(ResettableSettingsSnapshot); | 76 DISALLOW_COPY_AND_ASSIGN(ResettableSettingsSnapshot); |
72 }; | 77 }; |
73 | 78 |
74 // Serializes specified |snapshot| members to JSON format. |field_mask| is a bit | 79 // Serializes specified |snapshot| members to JSON format. |field_mask| is a bit |
75 // mask of ResettableSettingsSnapshot::Field values. | 80 // mask of ResettableSettingsSnapshot::Field values. |
76 std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot, | 81 std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot, |
77 int field_mask); | 82 int field_mask); |
78 | 83 |
79 // Sends |report| as a feedback. |report| is supposed to be result of | 84 // Sends |report| as a feedback. |report| is supposed to be result of |
80 // SerializeSettingsReport(). | 85 // SerializeSettingsReport(). |
81 void SendSettingsFeedback(const std::string& report, Profile* profile); | 86 void SendSettingsFeedback(const std::string& report, Profile* profile); |
82 | 87 |
88 // Returns list of key/value pairs for all reported information from the | |
89 // |profile| and some additional fields. | |
90 base::ListValue* GetReadableFeedback(Profile* profile); | |
91 | |
83 #endif // CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ | 92 #endif // CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ |
OLD | NEW |