Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 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_TESTING_PROFILE_H_ | 5 #ifndef CHROME_TEST_TESTING_PROFILE_H_ |
| 6 #define CHROME_TEST_TESTING_PROFILE_H_ | 6 #define CHROME_TEST_TESTING_PROFILE_H_ |
| 7 | 7 |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/browser_prefs.h" | 12 #include "chrome/browser/browser_prefs.h" |
| 13 #include "chrome/browser/browser_theme_provider.h" | 13 #include "chrome/browser/browser_theme_provider.h" |
| 14 #include "chrome/browser/favicon_service.h" | 14 #include "chrome/browser/favicon_service.h" |
| 15 #include "chrome/browser/history/history.h" | 15 #include "chrome/browser/history/history.h" |
| 16 #include "chrome/browser/net/url_request_context_getter.h" | |
| 16 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 17 #include "chrome/browser/search_engines/template_url_model.h" | 18 #include "chrome/browser/search_engines/template_url_model.h" |
| 18 #include "chrome/browser/sessions/session_service.h" | 19 #include "chrome/browser/sessions/session_service.h" |
| 19 #include "chrome/common/pref_service.h" | 20 #include "chrome/common/pref_service.h" |
| 21 #include "net/base/cookie_monster.h" | |
| 20 | 22 |
| 21 class TestingProfile : public Profile { | 23 class TestingProfile : public Profile { |
| 22 public: | 24 public: |
| 23 TestingProfile(); | 25 TestingProfile(); |
| 24 | 26 |
| 25 // Creates a new profile by adding |count| to the end of the path. Use this | 27 // Creates a new profile by adding |count| to the end of the path. Use this |
| 26 // when you need to have more than one TestingProfile running at the same | 28 // when you need to have more than one TestingProfile running at the same |
| 27 // time. | 29 // time. |
| 28 explicit TestingProfile(int count); | 30 explicit TestingProfile(int count); |
| 29 | 31 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 95 } |
| 94 virtual HistoryService* GetHistoryService(ServiceAccessType access) { | 96 virtual HistoryService* GetHistoryService(ServiceAccessType access) { |
| 95 return history_service_.get(); | 97 return history_service_.get(); |
| 96 } | 98 } |
| 97 virtual HistoryService* GetHistoryServiceWithoutCreating() { | 99 virtual HistoryService* GetHistoryServiceWithoutCreating() { |
| 98 return history_service_.get(); | 100 return history_service_.get(); |
| 99 } | 101 } |
| 100 void set_has_history_service(bool has_history_service) { | 102 void set_has_history_service(bool has_history_service) { |
| 101 has_history_service_ = has_history_service; | 103 has_history_service_ = has_history_service; |
| 102 } | 104 } |
| 105 net::CookieMonster* GetCookieMonster() { | |
|
John Grabowski
2010/01/08 04:01:55
Add comment with reference to CreateRequestContext
| |
| 106 if (!GetRequestContext()) | |
| 107 return NULL; | |
| 108 return GetRequestContext()->GetCookieStore()->GetCookieMonster(); | |
| 109 } | |
| 103 virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() { | 110 virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() { |
| 104 return NULL; | 111 return NULL; |
| 105 } | 112 } |
| 106 virtual WebDataService* GetWebDataService(ServiceAccessType access) { | 113 virtual WebDataService* GetWebDataService(ServiceAccessType access) { |
| 107 return NULL; | 114 return NULL; |
| 108 } | 115 } |
| 109 virtual WebDataService* GetWebDataServiceWithoutCreating() { | 116 virtual WebDataService* GetWebDataServiceWithoutCreating() { |
| 110 return NULL; | 117 return NULL; |
| 111 } | 118 } |
| 112 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { | 119 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 132 virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } | 139 virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } |
| 133 virtual void InitThemes(); | 140 virtual void InitThemes(); |
| 134 virtual void SetTheme(Extension* extension) {} | 141 virtual void SetTheme(Extension* extension) {} |
| 135 virtual void SetNativeTheme() {} | 142 virtual void SetNativeTheme() {} |
| 136 virtual void ClearTheme() {} | 143 virtual void ClearTheme() {} |
| 137 virtual Extension* GetTheme() { return NULL; } | 144 virtual Extension* GetTheme() { return NULL; } |
| 138 virtual BrowserThemeProvider* GetThemeProvider() { | 145 virtual BrowserThemeProvider* GetThemeProvider() { |
| 139 InitThemes(); | 146 InitThemes(); |
| 140 return theme_provider_.get(); | 147 return theme_provider_.get(); |
| 141 } | 148 } |
| 142 virtual URLRequestContextGetter* GetRequestContext() { return NULL; } | 149 |
| 150 // Returns a testing ContextGetter if one has been created (this can return | |
| 151 // NULL). This getter is currently only capable of returning a Context that | |
| 152 // helps test the CookieMonster. See implementation comments for more | |
| 153 // details. | |
| 154 virtual URLRequestContextGetter* GetRequestContext(); | |
| 155 void CreateRequestContext(); | |
| 156 | |
| 143 virtual URLRequestContextGetter* GetRequestContextForMedia() { return NULL; } | 157 virtual URLRequestContextGetter* GetRequestContextForMedia() { return NULL; } |
| 144 virtual URLRequestContextGetter* GetRequestContextForExtensions() { | 158 virtual URLRequestContextGetter* GetRequestContextForExtensions() { |
| 145 return NULL; | 159 return NULL; |
| 146 } | 160 } |
| 161 | |
| 147 virtual net::SSLConfigService* GetSSLConfigService() { return NULL; } | 162 virtual net::SSLConfigService* GetSSLConfigService() { return NULL; } |
| 148 virtual BlacklistManager* GetBlacklistManager() { return NULL; } | 163 virtual BlacklistManager* GetBlacklistManager() { return NULL; } |
| 149 virtual HostZoomMap* GetHostZoomMap() { return NULL; } | 164 virtual HostZoomMap* GetHostZoomMap() { return NULL; } |
| 150 void set_session_service(SessionService* session_service) { | 165 void set_session_service(SessionService* session_service) { |
| 151 session_service_ = session_service; | 166 session_service_ = session_service; |
| 152 } | 167 } |
| 153 virtual SessionService* GetSessionService() { return session_service_.get(); } | 168 virtual SessionService* GetSessionService() { return session_service_.get(); } |
| 154 virtual void ShutdownSessionService() {} | 169 virtual void ShutdownSessionService() {} |
| 155 virtual bool HasSessionService() const { | 170 virtual bool HasSessionService() const { |
| 156 return (session_service_.get() != NULL); | 171 return (session_service_.get() != NULL); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 238 |
| 224 scoped_ptr<NTPResourceCache> ntp_resource_cache_; | 239 scoped_ptr<NTPResourceCache> ntp_resource_cache_; |
| 225 | 240 |
| 226 // The SessionService. Defaults to NULL, but can be set using the setter. | 241 // The SessionService. Defaults to NULL, but can be set using the setter. |
| 227 scoped_refptr<SessionService> session_service_; | 242 scoped_refptr<SessionService> session_service_; |
| 228 | 243 |
| 229 // The theme provider. Created lazily by GetThemeProvider()/InitThemes(). | 244 // The theme provider. Created lazily by GetThemeProvider()/InitThemes(). |
| 230 scoped_ptr<BrowserThemeProvider> theme_provider_; | 245 scoped_ptr<BrowserThemeProvider> theme_provider_; |
| 231 bool created_theme_provider_; | 246 bool created_theme_provider_; |
| 232 | 247 |
| 248 // Internally, this is a TestURLRequestContextGetter that creates a dummy | |
| 249 // request context. Currently, only the CookieMonster is hooked up. | |
| 250 scoped_refptr<URLRequestContextGetter> request_context_; | |
| 251 | |
| 233 // Do we have a history service? This defaults to the value of | 252 // Do we have a history service? This defaults to the value of |
| 234 // history_service, but can be explicitly set. | 253 // history_service, but can be explicitly set. |
| 235 bool has_history_service_; | 254 bool has_history_service_; |
| 236 | 255 |
| 237 std::wstring id_; | 256 std::wstring id_; |
| 238 | 257 |
| 239 bool off_the_record_; | 258 bool off_the_record_; |
| 240 | 259 |
| 241 // Did the last session exit cleanly? Default is true. | 260 // Did the last session exit cleanly? Default is true. |
| 242 bool last_session_exited_cleanly_; | 261 bool last_session_exited_cleanly_; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 256 | 275 |
| 257 virtual ProfileId GetRuntimeId() { | 276 virtual ProfileId GetRuntimeId() { |
| 258 return original_profile_->GetRuntimeId(); | 277 return original_profile_->GetRuntimeId(); |
| 259 } | 278 } |
| 260 | 279 |
| 261 protected: | 280 protected: |
| 262 Profile* original_profile_; | 281 Profile* original_profile_; |
| 263 }; | 282 }; |
| 264 | 283 |
| 265 #endif // CHROME_TEST_TESTING_PROFILE_H_ | 284 #endif // CHROME_TEST_TESTING_PROFILE_H_ |
| OLD | NEW |