| 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: |
| 15 // All types of settings handled by this class. | 19 // All types of settings handled by this class. |
| 16 enum Field { | 20 enum Field { |
| 17 STARTUP_URLS = 1 << 0, | 21 STARTUP_URLS = 1 << 0, |
| 18 STARTUP_TYPE = 1 << 1, | 22 STARTUP_TYPE = 1 << 1, |
| 19 HOMEPAGE = 1 << 2, | 23 HOMEPAGE = 1 << 2, |
| 20 HOMEPAGE_IS_NTP = 1 << 3, | 24 HOMEPAGE_IS_NTP = 1 << 3, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 const std::vector<GURL>& startup_urls() const { return startup_.urls; } | 36 const std::vector<GURL>& startup_urls() const { return startup_.urls; } |
| 33 | 37 |
| 34 SessionStartupPref::Type startup_type() const { return startup_.type; } | 38 SessionStartupPref::Type startup_type() const { return startup_.type; } |
| 35 | 39 |
| 36 const std::string& homepage() const { return homepage_; } | 40 const std::string& homepage() const { return homepage_; } |
| 37 | 41 |
| 38 bool homepage_is_ntp() const { return homepage_is_ntp_; } | 42 bool homepage_is_ntp() const { return homepage_is_ntp_; } |
| 39 | 43 |
| 40 const std::string& dse_url() const { return dse_url_; } | 44 const std::string& dse_url() const { return dse_url_; } |
| 41 | 45 |
| 46 const std::string& dse_host() const { return dse_host_; } |
| 47 |
| 42 const std::vector<std::string>& enabled_extensions() const { | 48 const std::vector<std::string>& enabled_extensions() const { |
| 43 return enabled_extensions_; | 49 return enabled_extensions_; |
| 44 } | 50 } |
| 45 | 51 |
| 46 // Substitutes |startup_.urls| with |startup_.urls|\|snapshot.startup_.urls|. | 52 // Substitutes |startup_.urls| with |startup_.urls|\|snapshot.startup_.urls|. |
| 47 // Substitutes |enabled_extensions_| with | 53 // Substitutes |enabled_extensions_| with |
| 48 // |enabled_extensions_|\|snapshot.enabled_extensions_|. | 54 // |enabled_extensions_|\|snapshot.enabled_extensions_|. |
| 49 void Subtract(const ResettableSettingsSnapshot& snapshot); | 55 void Subtract(const ResettableSettingsSnapshot& snapshot); |
| 50 | 56 |
| 51 // For each member 'm' compares |this->m| with |snapshot.m| and sets the | 57 // For each member 'm' compares |this->m| with |snapshot.m| and sets the |
| 52 // corresponding |ResetableSettingsSnapshot::Field| bit to 1 in case of | 58 // corresponding |ResetableSettingsSnapshot::Field| bit to 1 in case of |
| 53 // difference. | 59 // difference. |
| 54 // The return value is a bit mask of Field values signifying which members | 60 // The return value is a bit mask of Field values signifying which members |
| 55 // were different. | 61 // were different. |
| 56 int FindDifferentFields(const ResettableSettingsSnapshot& snapshot) const; | 62 int FindDifferentFields(const ResettableSettingsSnapshot& snapshot) const; |
| 57 | 63 |
| 58 private: | 64 private: |
| 59 // Startup pages. URLs are always stored sorted. | 65 // Startup pages. URLs are always stored sorted. |
| 60 SessionStartupPref startup_; | 66 SessionStartupPref startup_; |
| 61 | 67 |
| 62 std::string homepage_; | 68 std::string homepage_; |
| 63 bool homepage_is_ntp_; | 69 bool homepage_is_ntp_; |
| 64 | 70 |
| 65 // Default search engine. | 71 // Default search engine. |
| 66 std::string dse_url_; | 72 std::string dse_url_; |
| 73 // The host is used for human-readable reporting. |
| 74 std::string dse_host_; |
| 67 | 75 |
| 68 // Enabled extension ids. Always sorted. | 76 // Enabled extension ids. Always sorted. |
| 69 std::vector<std::string> enabled_extensions_; | 77 std::vector<std::string> enabled_extensions_; |
| 70 | 78 |
| 71 DISALLOW_COPY_AND_ASSIGN(ResettableSettingsSnapshot); | 79 DISALLOW_COPY_AND_ASSIGN(ResettableSettingsSnapshot); |
| 72 }; | 80 }; |
| 73 | 81 |
| 74 // Serializes specified |snapshot| members to JSON format. |field_mask| is a bit | 82 // Serializes specified |snapshot| members to JSON format. |field_mask| is a bit |
| 75 // mask of ResettableSettingsSnapshot::Field values. | 83 // mask of ResettableSettingsSnapshot::Field values. |
| 76 std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot, | 84 std::string SerializeSettingsReport(const ResettableSettingsSnapshot& snapshot, |
| 77 int field_mask); | 85 int field_mask); |
| 78 | 86 |
| 79 // Sends |report| as a feedback. |report| is supposed to be result of | 87 // Sends |report| as a feedback. |report| is supposed to be result of |
| 80 // SerializeSettingsReport(). | 88 // SerializeSettingsReport(). |
| 81 void SendSettingsFeedback(const std::string& report, Profile* profile); | 89 void SendSettingsFeedback(const std::string& report, Profile* profile); |
| 82 | 90 |
| 91 // Returns list of key/value pairs for all information in the |snapshot| and |
| 92 // some additional fields. |
| 93 base::ListValue* GetReadableFeedback( |
| 94 const ResettableSettingsSnapshot& snapshot); |
| 95 |
| 83 #endif // CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ | 96 #endif // CHROME_BROWSER_PROFILE_RESETTER_RESETTABLE_SETTINGS_SNAPSHOT_H_ |
| OLD | NEW |