OLD | NEW |
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_TEST_BASE_TESTING_PROFILE_H_ | 5 #ifndef CHROME_TEST_BASE_TESTING_PROFILE_H_ |
6 #define CHROME_TEST_BASE_TESTING_PROFILE_H_ | 6 #define CHROME_TEST_BASE_TESTING_PROFILE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Makes the Profile being built a guest profile. | 104 // Makes the Profile being built a guest profile. |
105 void SetGuestSession(); | 105 void SetGuestSession(); |
106 | 106 |
107 // Sets the supervised user ID (which is empty by default). If it is set to | 107 // Sets the supervised user ID (which is empty by default). If it is set to |
108 // a non-empty string, the profile is supervised. | 108 // a non-empty string, the profile is supervised. |
109 void SetSupervisedUserId(const std::string& supervised_user_id); | 109 void SetSupervisedUserId(const std::string& supervised_user_id); |
110 | 110 |
111 // Sets the PolicyService to be used by this profile. | 111 // Sets the PolicyService to be used by this profile. |
112 void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service); | 112 void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service); |
113 | 113 |
| 114 // Sets the UserProfileName to be used by this profile. |
| 115 void SetProfileName(const std::string& profile_name); |
| 116 |
114 // Creates the TestingProfile using previously-set settings. | 117 // Creates the TestingProfile using previously-set settings. |
115 scoped_ptr<TestingProfile> Build(); | 118 scoped_ptr<TestingProfile> Build(); |
116 | 119 |
117 // Build an incognito profile, owned by |original_profile|. Note: unless you | 120 // Build an incognito profile, owned by |original_profile|. Note: unless you |
118 // need to customize the Builder, or access TestingProfile member functions, | 121 // need to customize the Builder, or access TestingProfile member functions, |
119 // you can use original_profile->GetOffTheRecordProfile(). | 122 // you can use original_profile->GetOffTheRecordProfile(). |
120 TestingProfile* BuildIncognito(TestingProfile* original_profile); | 123 TestingProfile* BuildIncognito(TestingProfile* original_profile); |
121 | 124 |
122 private: | 125 private: |
123 // If true, Build() has already been called. | 126 // If true, Build() has already been called. |
124 bool build_called_; | 127 bool build_called_; |
125 | 128 |
126 // Various staging variables where values are held until Build() is invoked. | 129 // Various staging variables where values are held until Build() is invoked. |
127 scoped_ptr<syncable_prefs::PrefServiceSyncable> pref_service_; | 130 scoped_ptr<syncable_prefs::PrefServiceSyncable> pref_service_; |
128 #if defined(ENABLE_EXTENSIONS) | 131 #if defined(ENABLE_EXTENSIONS) |
129 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; | 132 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; |
130 #endif | 133 #endif |
131 base::FilePath path_; | 134 base::FilePath path_; |
132 Delegate* delegate_; | 135 Delegate* delegate_; |
133 bool guest_session_; | 136 bool guest_session_; |
134 std::string supervised_user_id_; | 137 std::string supervised_user_id_; |
135 scoped_ptr<policy::PolicyService> policy_service_; | 138 scoped_ptr<policy::PolicyService> policy_service_; |
136 TestingFactories testing_factories_; | 139 TestingFactories testing_factories_; |
| 140 std::string profile_name_; |
137 | 141 |
138 DISALLOW_COPY_AND_ASSIGN(Builder); | 142 DISALLOW_COPY_AND_ASSIGN(Builder); |
139 }; | 143 }; |
140 | 144 |
141 // Multi-profile aware constructor that takes the path to a directory managed | 145 // Multi-profile aware constructor that takes the path to a directory managed |
142 // for this profile. This constructor is meant to be used by | 146 // for this profile. This constructor is meant to be used by |
143 // TestingProfileManager::CreateTestingProfile. If you need to create multi- | 147 // TestingProfileManager::CreateTestingProfile. If you need to create multi- |
144 // profile profiles, use that factory method instead of this directly. | 148 // profile profiles, use that factory method instead of this directly. |
145 // Exception: if you need to create multi-profile profiles for testing the | 149 // Exception: if you need to create multi-profile profiles for testing the |
146 // ProfileManager, then use the constructor below instead. | 150 // ProfileManager, then use the constructor below instead. |
147 explicit TestingProfile(const base::FilePath& path); | 151 explicit TestingProfile(const base::FilePath& path); |
148 | 152 |
149 // Multi-profile aware constructor that takes the path to a directory managed | 153 // Multi-profile aware constructor that takes the path to a directory managed |
150 // for this profile and a delegate. This constructor is meant to be used | 154 // for this profile and a delegate. This constructor is meant to be used |
151 // for unittesting the ProfileManager. | 155 // for unittesting the ProfileManager. |
152 TestingProfile(const base::FilePath& path, Delegate* delegate); | 156 TestingProfile(const base::FilePath& path, Delegate* delegate); |
153 | 157 |
154 // Full constructor allowing the setting of all possible instance data. | 158 // Full constructor allowing the setting of all possible instance data. |
155 // Callers should use Builder::Build() instead of invoking this constructor. | 159 // Callers should use Builder::Build() instead of invoking this constructor. |
156 TestingProfile(const base::FilePath& path, | 160 TestingProfile(const base::FilePath& path, |
157 Delegate* delegate, | 161 Delegate* delegate, |
158 #if defined(ENABLE_EXTENSIONS) | 162 #if defined(ENABLE_EXTENSIONS) |
159 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 163 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
160 #endif | 164 #endif |
161 scoped_ptr<syncable_prefs::PrefServiceSyncable> prefs, | 165 scoped_ptr<syncable_prefs::PrefServiceSyncable> prefs, |
162 TestingProfile* parent, | 166 TestingProfile* parent, |
163 bool guest_session, | 167 bool guest_session, |
164 const std::string& supervised_user_id, | 168 const std::string& supervised_user_id, |
165 scoped_ptr<policy::PolicyService> policy_service, | 169 scoped_ptr<policy::PolicyService> policy_service, |
166 const TestingFactories& factories); | 170 const TestingFactories& factories, |
| 171 const std::string& profile_name); |
167 | 172 |
168 ~TestingProfile() override; | 173 ~TestingProfile() override; |
169 | 174 |
170 // Creates the favicon service. Consequent calls would recreate the service. | 175 // Creates the favicon service. Consequent calls would recreate the service. |
171 void CreateFaviconService(); | 176 void CreateFaviconService(); |
172 | 177 |
173 // Creates the history service. If |delete_file| is true, the history file is | 178 // Creates the history service. If |delete_file| is true, the history file is |
174 // deleted first, then the HistoryService is created. As TestingProfile | 179 // deleted first, then the HistoryService is created. As TestingProfile |
175 // deletes the directory containing the files used by HistoryService, this | 180 // deletes the directory containing the files used by HistoryService, this |
176 // only matters if you're recreating the HistoryService. If |no_db| is true, | 181 // only matters if you're recreating the HistoryService. If |no_db| is true, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 414 |
410 // Weak pointer to a delegate for indicating that a profile was created. | 415 // Weak pointer to a delegate for indicating that a profile was created. |
411 Delegate* delegate_; | 416 Delegate* delegate_; |
412 | 417 |
413 std::string profile_name_; | 418 std::string profile_name_; |
414 | 419 |
415 scoped_ptr<policy::PolicyService> policy_service_; | 420 scoped_ptr<policy::PolicyService> policy_service_; |
416 }; | 421 }; |
417 | 422 |
418 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 423 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
OLD | NEW |