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 | 9 |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 // Sets the PrefService to be used by this profile. | 94 // Sets the PrefService to be used by this profile. |
95 void SetPrefService(scoped_ptr<PrefServiceSyncable> prefs); | 95 void SetPrefService(scoped_ptr<PrefServiceSyncable> prefs); |
96 | 96 |
97 // Makes the Profile being built an incognito profile. | 97 // Makes the Profile being built an incognito profile. |
98 void SetIncognito(); | 98 void SetIncognito(); |
99 | 99 |
100 // Makes the Profile being built a guest profile. | 100 // Makes the Profile being built a guest profile. |
101 void SetGuestSession(); | 101 void SetGuestSession(); |
102 | 102 |
103 // Sets the managed user ID (which is empty by default). If it is set to a | 103 // Sets the supervised user ID (which is empty by default). If it is set to |
104 // non-empty string, the profile is managed. | 104 // a non-empty string, the profile is supervised. |
105 void SetManagedUserId(const std::string& managed_user_id); | 105 void SetSupervisedUserId(const std::string& supervised_user_id); |
106 | 106 |
107 // Sets the PolicyService to be used by this profile. | 107 // Sets the PolicyService to be used by this profile. |
108 void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service); | 108 void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service); |
109 | 109 |
110 // Creates the TestingProfile using previously-set settings. | 110 // Creates the TestingProfile using previously-set settings. |
111 scoped_ptr<TestingProfile> Build(); | 111 scoped_ptr<TestingProfile> Build(); |
112 | 112 |
113 private: | 113 private: |
114 // If true, Build() has already been called. | 114 // If true, Build() has already been called. |
115 bool build_called_; | 115 bool build_called_; |
116 | 116 |
117 // Various staging variables where values are held until Build() is invoked. | 117 // Various staging variables where values are held until Build() is invoked. |
118 scoped_ptr<PrefServiceSyncable> pref_service_; | 118 scoped_ptr<PrefServiceSyncable> pref_service_; |
119 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; | 119 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; |
120 base::FilePath path_; | 120 base::FilePath path_; |
121 Delegate* delegate_; | 121 Delegate* delegate_; |
122 bool incognito_; | 122 bool incognito_; |
123 bool guest_session_; | 123 bool guest_session_; |
124 std::string managed_user_id_; | 124 std::string supervised_user_id_; |
125 scoped_ptr<policy::PolicyService> policy_service_; | 125 scoped_ptr<policy::PolicyService> policy_service_; |
126 TestingFactories testing_factories_; | 126 TestingFactories testing_factories_; |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(Builder); | 128 DISALLOW_COPY_AND_ASSIGN(Builder); |
129 }; | 129 }; |
130 | 130 |
131 // Multi-profile aware constructor that takes the path to a directory managed | 131 // Multi-profile aware constructor that takes the path to a directory managed |
132 // for this profile. This constructor is meant to be used by | 132 // for this profile. This constructor is meant to be used by |
133 // TestingProfileManager::CreateTestingProfile. If you need to create multi- | 133 // TestingProfileManager::CreateTestingProfile. If you need to create multi- |
134 // profile profiles, use that factory method instead of this directly. | 134 // profile profiles, use that factory method instead of this directly. |
135 // Exception: if you need to create multi-profile profiles for testing the | 135 // Exception: if you need to create multi-profile profiles for testing the |
136 // ProfileManager, then use the constructor below instead. | 136 // ProfileManager, then use the constructor below instead. |
137 explicit TestingProfile(const base::FilePath& path); | 137 explicit TestingProfile(const base::FilePath& path); |
138 | 138 |
139 // Multi-profile aware constructor that takes the path to a directory managed | 139 // Multi-profile aware constructor that takes the path to a directory managed |
140 // for this profile and a delegate. This constructor is meant to be used | 140 // for this profile and a delegate. This constructor is meant to be used |
141 // for unittesting the ProfileManager. | 141 // for unittesting the ProfileManager. |
142 TestingProfile(const base::FilePath& path, Delegate* delegate); | 142 TestingProfile(const base::FilePath& path, Delegate* delegate); |
143 | 143 |
144 // Full constructor allowing the setting of all possible instance data. | 144 // Full constructor allowing the setting of all possible instance data. |
145 // Callers should use Builder::Build() instead of invoking this constructor. | 145 // Callers should use Builder::Build() instead of invoking this constructor. |
146 TestingProfile(const base::FilePath& path, | 146 TestingProfile(const base::FilePath& path, |
147 Delegate* delegate, | 147 Delegate* delegate, |
148 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 148 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
149 scoped_ptr<PrefServiceSyncable> prefs, | 149 scoped_ptr<PrefServiceSyncable> prefs, |
150 bool incognito, | 150 bool incognito, |
151 bool guest_session, | 151 bool guest_session, |
152 const std::string& managed_user_id, | 152 const std::string& supervised_user_id, |
153 scoped_ptr<policy::PolicyService> policy_service, | 153 scoped_ptr<policy::PolicyService> policy_service, |
154 const TestingFactories& factories); | 154 const TestingFactories& factories); |
155 | 155 |
156 virtual ~TestingProfile(); | 156 virtual ~TestingProfile(); |
157 | 157 |
158 // Creates the favicon service. Consequent calls would recreate the service. | 158 // Creates the favicon service. Consequent calls would recreate the service. |
159 void CreateFaviconService(); | 159 void CreateFaviconService(); |
160 | 160 |
161 // Creates the history service. If |delete_file| is true, the history file is | 161 // Creates the history service. If |delete_file| is true, the history file is |
162 // deleted first, then the HistoryService is created. As TestingProfile | 162 // deleted first, then the HistoryService is created. As TestingProfile |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 force_incognito_ = force_incognito; | 243 force_incognito_ = force_incognito; |
244 } | 244 } |
245 | 245 |
246 // Assumes ownership. | 246 // Assumes ownership. |
247 virtual void SetOffTheRecordProfile(scoped_ptr<Profile> profile); | 247 virtual void SetOffTheRecordProfile(scoped_ptr<Profile> profile); |
248 virtual void SetOriginalProfile(Profile* profile); | 248 virtual void SetOriginalProfile(Profile* profile); |
249 virtual Profile* GetOffTheRecordProfile() OVERRIDE; | 249 virtual Profile* GetOffTheRecordProfile() OVERRIDE; |
250 virtual void DestroyOffTheRecordProfile() OVERRIDE {} | 250 virtual void DestroyOffTheRecordProfile() OVERRIDE {} |
251 virtual bool HasOffTheRecordProfile() OVERRIDE; | 251 virtual bool HasOffTheRecordProfile() OVERRIDE; |
252 virtual Profile* GetOriginalProfile() OVERRIDE; | 252 virtual Profile* GetOriginalProfile() OVERRIDE; |
253 virtual bool IsManaged() OVERRIDE; | 253 virtual bool IsSupervised() OVERRIDE; |
254 virtual ExtensionService* GetExtensionService() OVERRIDE; | 254 virtual ExtensionService* GetExtensionService() OVERRIDE; |
255 void SetExtensionSpecialStoragePolicy( | 255 void SetExtensionSpecialStoragePolicy( |
256 ExtensionSpecialStoragePolicy* extension_special_storage_policy); | 256 ExtensionSpecialStoragePolicy* extension_special_storage_policy); |
257 virtual ExtensionSpecialStoragePolicy* | 257 virtual ExtensionSpecialStoragePolicy* |
258 GetExtensionSpecialStoragePolicy() OVERRIDE; | 258 GetExtensionSpecialStoragePolicy() OVERRIDE; |
259 // TODO(ajwong): Remove this API in favor of directly retrieving the | 259 // TODO(ajwong): Remove this API in favor of directly retrieving the |
260 // CookieStore from the StoragePartition after ExtensionURLRequestContext | 260 // CookieStore from the StoragePartition after ExtensionURLRequestContext |
261 // has been removed. | 261 // has been removed. |
262 net::CookieMonster* GetCookieMonster(); | 262 net::CookieMonster* GetCookieMonster(); |
263 | 263 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // request context. Currently, only the CookieMonster is hooked up. | 374 // request context. Currently, only the CookieMonster is hooked up. |
375 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; | 375 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; |
376 | 376 |
377 bool incognito_; | 377 bool incognito_; |
378 bool force_incognito_; | 378 bool force_incognito_; |
379 scoped_ptr<Profile> incognito_profile_; | 379 scoped_ptr<Profile> incognito_profile_; |
380 Profile* original_profile_; | 380 Profile* original_profile_; |
381 | 381 |
382 bool guest_session_; | 382 bool guest_session_; |
383 | 383 |
384 std::string managed_user_id_; | 384 std::string supervised_user_id_; |
385 | 385 |
386 // Did the last session exit cleanly? Default is true. | 386 // Did the last session exit cleanly? Default is true. |
387 bool last_session_exited_cleanly_; | 387 bool last_session_exited_cleanly_; |
388 | 388 |
389 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 389 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
390 | 390 |
391 base::FilePath last_selected_directory_; | 391 base::FilePath last_selected_directory_; |
392 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. | 392 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. |
393 | 393 |
394 scoped_refptr<ExtensionSpecialStoragePolicy> | 394 scoped_refptr<ExtensionSpecialStoragePolicy> |
(...skipping 26 matching lines...) Expand all Loading... |
421 | 421 |
422 // Weak pointer to a delegate for indicating that a profile was created. | 422 // Weak pointer to a delegate for indicating that a profile was created. |
423 Delegate* delegate_; | 423 Delegate* delegate_; |
424 | 424 |
425 std::string profile_name_; | 425 std::string profile_name_; |
426 | 426 |
427 scoped_ptr<policy::PolicyService> policy_service_; | 427 scoped_ptr<policy::PolicyService> policy_service_; |
428 }; | 428 }; |
429 | 429 |
430 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 430 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
OLD | NEW |