| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_LIVE_SYNC_PREFERENCES_HELPER_H_ | 5 #ifndef CHROME_TEST_LIVE_SYNC_PREFERENCES_HELPER_H_ |
| 6 #define CHROME_TEST_LIVE_SYNC_PREFERENCES_HELPER_H_ | 6 #define CHROME_TEST_LIVE_SYNC_PREFERENCES_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/test/live_sync/sync_datatype_helper.h" | |
| 12 | 11 |
| 13 #include <string> | 12 #include <string> |
| 14 | 13 |
| 15 class PrefService; | 14 class PrefService; |
| 16 | 15 |
| 17 class PreferencesHelper : public SyncDatatypeHelper { | 16 namespace preferences_helper { |
| 18 public: | |
| 19 // Used to access the preferences within a particular sync profile. | |
| 20 static PrefService* GetPrefs(int index); | |
| 21 | 17 |
| 22 // Used to access the preferences within the verifier sync profile. | 18 // Used to access the preferences within a particular sync profile. |
| 23 static PrefService* GetVerifierPrefs(); | 19 PrefService* GetPrefs(int index); |
| 24 | 20 |
| 25 // Inverts the value of the boolean preference with name |pref_name| in the | 21 // Used to access the preferences within the verifier sync profile. |
| 26 // profile with index |index|. Also inverts its value in |verifier| if | 22 PrefService* GetVerifierPrefs(); |
| 27 // DisableVerifier() hasn't been called. | |
| 28 static void ChangeBooleanPref(int index, const char* pref_name); | |
| 29 | 23 |
| 30 // Changes the value of the integer preference with name |pref_name| in the | 24 // Inverts the value of the boolean preference with name |pref_name| in the |
| 31 // profile with index |index| to |new_value|. Also changes its value in | 25 // profile with index |index|. Also inverts its value in |verifier| if |
| 32 // |verifier| if DisableVerifier() hasn't been called. | 26 // DisableVerifier() hasn't been called. |
| 33 static void ChangeIntegerPref(int index, | 27 void ChangeBooleanPref(int index, const char* pref_name); |
| 34 const char* pref_name, | |
| 35 int new_value); | |
| 36 | 28 |
| 37 // Changes the value of the double preference with name |pref_name| in the | 29 // Changes the value of the integer preference with name |pref_name| in the |
| 38 // profile with index |index| to |new_value|. Also changes its value in | 30 // profile with index |index| to |new_value|. Also changes its value in |
| 39 // |verifier| if DisableVerifier() hasn't been called. | 31 // |verifier| if DisableVerifier() hasn't been called. |
| 40 static void ChangeDoublePref(int index, | 32 void ChangeIntegerPref(int index, const char* pref_name, int new_value); |
| 41 const char* pref_name, | |
| 42 double new_value); | |
| 43 | 33 |
| 44 // Changes the value of the string preference with name |pref_name| in the | 34 // Changes the value of the double preference with name |pref_name| in the |
| 45 // profile with index |index| to |new_value|. Also changes its value in | 35 // profile with index |index| to |new_value|. Also changes its value in |
| 46 // |verifier| if DisableVerifier() hasn't been called. | 36 // |verifier| if DisableVerifier() hasn't been called. |
| 47 static void ChangeStringPref(int index, | 37 void ChangeDoublePref(int index, const char* pref_name, double new_value); |
| 48 const char* pref_name, | |
| 49 const std::string& new_value); | |
| 50 | 38 |
| 51 // Modifies the value of the string preference with name |pref_name| in the | 39 // Changes the value of the string preference with name |pref_name| in the |
| 52 // profile with index |index| by appending |append_value| to its current | 40 // profile with index |index| to |new_value|. Also changes its value in |
| 53 // value. Also changes its value in |verifier| if DisableVerifier() hasn't | 41 // |verifier| if DisableVerifier() hasn't been called. |
| 54 // been called. | 42 void ChangeStringPref(int index, |
| 55 static void AppendStringPref(int index, | 43 const char* pref_name, |
| 56 const char* pref_name, | 44 const std::string& new_value); |
| 57 const std::string& append_value); | |
| 58 | 45 |
| 59 // Changes the value of the file path preference with name |pref_name| in the | 46 // Modifies the value of the string preference with name |pref_name| in the |
| 60 // profile with index |index| to |new_value|. Also changes its value in | 47 // profile with index |index| by appending |append_value| to its current |
| 61 // |verifier| if DisableVerifier() hasn't been called. | 48 // value. Also changes its value in |verifier| if DisableVerifier() hasn't |
| 62 static void ChangeFilePathPref(int index, | 49 // been called. |
| 63 const char* pref_name, | 50 void AppendStringPref(int index, |
| 64 const FilePath& new_value); | 51 const char* pref_name, |
| 52 const std::string& append_value); |
| 65 | 53 |
| 66 // Changes the value of the list preference with name |pref_name| in the | 54 // Changes the value of the file path preference with name |pref_name| in the |
| 67 // profile with index |index| to |new_value|. Also changes its value in | 55 // profile with index |index| to |new_value|. Also changes its value in |
| 68 // |verifier| if DisableVerifier() hasn't been called. | 56 // |verifier| if DisableVerifier() hasn't been called. |
| 69 static void ChangeListPref(int index, | 57 void ChangeFilePathPref(int index, |
| 70 const char* pref_name, | 58 const char* pref_name, |
| 71 const ListValue& new_value); | 59 const FilePath& new_value); |
| 72 | 60 |
| 73 // Used to verify that the boolean preference with name |pref_name| has the | 61 // Changes the value of the list preference with name |pref_name| in the |
| 74 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 62 // profile with index |index| to |new_value|. Also changes its value in |
| 75 // hasn't been called. | 63 // |verifier| if DisableVerifier() hasn't been called. |
| 76 static bool BooleanPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 64 void ChangeListPref(int index, |
| 65 const char* pref_name, |
| 66 const ListValue& new_value); |
| 77 | 67 |
| 78 // Used to verify that the integer preference with name |pref_name| has the | 68 // Used to verify that the boolean preference with name |pref_name| has the |
| 79 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 69 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
| 80 // hasn't been called. | 70 // hasn't been called. |
| 81 static bool IntegerPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 71 bool BooleanPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
| 82 | 72 |
| 83 // Used to verify that the double preference with name |pref_name| has the | 73 // Used to verify that the integer preference with name |pref_name| has the |
| 84 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 74 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
| 85 // hasn't been called. | 75 // hasn't been called. |
| 86 static bool DoublePrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 76 bool IntegerPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
| 87 | 77 |
| 88 // Used to verify that the string preference with name |pref_name| has the | 78 // Used to verify that the double preference with name |pref_name| has the |
| 89 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 79 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
| 90 // hasn't been called. | 80 // hasn't been called. |
| 91 static bool StringPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 81 bool DoublePrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
| 92 | 82 |
| 93 // Used to verify that the file path preference with name |pref_name| has the | 83 // Used to verify that the string preference with name |pref_name| has the |
| 94 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 84 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
| 95 // hasn't been called. | 85 // hasn't been called. |
| 96 static bool FilePathPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 86 bool StringPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
| 97 | 87 |
| 98 // Used to verify that the list preference with name |pref_name| has the | 88 // Used to verify that the file path preference with name |pref_name| has the |
| 99 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 89 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
| 100 // hasn't been called. | 90 // hasn't been called. |
| 101 static bool ListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 91 bool FilePathPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
| 102 | 92 |
| 103 // Encrypts the Preferences datatype. | 93 // Used to verify that the list preference with name |pref_name| has the |
| 104 static bool EnableEncryption(int index); | 94 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
| 95 // hasn't been called. |
| 96 bool ListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
| 105 | 97 |
| 106 // Checks if Preferences are encrypted. | 98 // Encrypts the Preferences datatype. |
| 107 static bool IsEncrypted(int index); | 99 bool EnableEncryption(int index); |
| 108 | 100 |
| 109 protected: | 101 // Checks if Preferences are encrypted. |
| 110 PreferencesHelper(); | 102 bool IsEncrypted(int index); |
| 111 virtual ~PreferencesHelper(); | |
| 112 | 103 |
| 113 private: | 104 } // namespace preferences_helper |
| 114 DISALLOW_COPY_AND_ASSIGN(PreferencesHelper); | |
| 115 }; | |
| 116 | 105 |
| 117 #endif // CHROME_TEST_LIVE_SYNC_PREFERENCES_HELPER_H_ | 106 #endif // CHROME_TEST_LIVE_SYNC_PREFERENCES_HELPER_H_ |
| OLD | NEW |