Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/test/testing_profile.cc

Issue 3129007: FBTF: Forward declare everything possible in testing_profile.h (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: argh mac problems now Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/testing_profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/test/testing_profile.h" 5 #include "chrome/test/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8
9 #include "base/base_paths.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h"
9 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h"
10 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
11 #include "chrome/common/url_constants.h" 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/browser_prefs.h"
18 #include "chrome/browser/browser_theme_provider.h"
19 #include "chrome/browser/chrome_thread.h"
13 #include "chrome/browser/dom_ui/ntp_resource_cache.h" 20 #include "chrome/browser/dom_ui/ntp_resource_cache.h"
21 #include "chrome/browser/favicon_service.h"
22 #include "chrome/browser/find_bar_state.h"
23 #include "chrome/browser/geolocation/geolocation_content_settings_map.h"
24 #include "chrome/browser/geolocation/geolocation_permission_context.h"
25 #include "chrome/browser/history/history.h"
14 #include "chrome/browser/history/history_backend.h" 26 #include "chrome/browser/history/history_backend.h"
27 #include "chrome/browser/history/top_sites.h"
28 #include "chrome/browser/in_process_webkit/webkit_context.h"
29 #include "chrome/browser/host_content_settings_map.h"
15 #include "chrome/browser/net/gaia/token_service.h" 30 #include "chrome/browser/net/gaia/token_service.h"
31 #include "chrome/browser/notifications/desktop_notification_service.h"
32 #include "chrome/browser/search_engines/template_url_model.h"
16 #include "chrome/browser/sessions/session_service.h" 33 #include "chrome/browser/sessions/session_service.h"
17 #include "chrome/browser/sync/profile_sync_service_mock.h" 34 #include "chrome/browser/sync/profile_sync_service_mock.h"
18 #include "chrome/common/chrome_constants.h" 35 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/net/url_request_context_getter.h" 36 #include "chrome/common/net/url_request_context_getter.h"
20 #include "chrome/common/notification_service.h" 37 #include "chrome/common/notification_service.h"
38 #include "chrome/common/url_constants.h"
39 #include "chrome/test/testing_pref_service.h"
40 #include "net/base/cookie_monster.h"
21 #include "net/url_request/url_request_context.h" 41 #include "net/url_request/url_request_context.h"
22 #include "testing/gmock/include/gmock/gmock.h" 42 #include "testing/gmock/include/gmock/gmock.h"
23 #include "webkit/database/database_tracker.h" 43 #include "webkit/database/database_tracker.h"
24 44
25 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) 45 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
26 #include "chrome/browser/gtk/gtk_theme_provider.h" 46 #include "chrome/browser/gtk/gtk_theme_provider.h"
27 #endif 47 #endif
28 48
29 using base::Time; 49 using base::Time;
30 using testing::NiceMock; 50 using testing::NiceMock;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 void TestingProfile::CreateTemplateURLModel() { 313 void TestingProfile::CreateTemplateURLModel() {
294 template_url_model_.reset(new TemplateURLModel(this)); 314 template_url_model_.reset(new TemplateURLModel(this));
295 } 315 }
296 316
297 void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { 317 void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) {
298 theme_provider->Init(this); 318 theme_provider->Init(this);
299 created_theme_provider_ = true; 319 created_theme_provider_ = true;
300 theme_provider_.reset(theme_provider); 320 theme_provider_.reset(theme_provider);
301 } 321 }
302 322
323 TestingPrefService* TestingProfile::GetTestingPrefService() {
324 return static_cast<TestingPrefService*>(GetPrefs());
325 }
326
303 webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() { 327 webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() {
304 if (!db_tracker_) 328 if (!db_tracker_)
305 db_tracker_ = new webkit_database::DatabaseTracker(GetPath(), false); 329 db_tracker_ = new webkit_database::DatabaseTracker(GetPath(), false);
306 return db_tracker_; 330 return db_tracker_;
307 } 331 }
308 332
333 net::CookieMonster* TestingProfile::GetCookieMonster() {
334 if (!GetRequestContext())
335 return NULL;
336 return GetRequestContext()->GetCookieStore()->GetCookieMonster();
337 }
338
309 void TestingProfile::InitThemes() { 339 void TestingProfile::InitThemes() {
310 if (!created_theme_provider_) { 340 if (!created_theme_provider_) {
311 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) 341 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
312 theme_provider_.reset(new GtkThemeProvider); 342 theme_provider_.reset(new GtkThemeProvider);
313 #else 343 #else
314 theme_provider_.reset(new BrowserThemeProvider); 344 theme_provider_.reset(new BrowserThemeProvider);
315 #endif 345 #endif
316 theme_provider_->Init(this); 346 theme_provider_->Init(this);
317 created_theme_provider_ = true; 347 created_theme_provider_ = true;
318 } 348 }
319 } 349 }
320 350
351 PrefService* TestingProfile::GetPrefs() {
352 if (!prefs_.get()) {
353 prefs_.reset(new TestingPrefService());
354 Profile::RegisterUserPrefs(prefs_.get());
355 browser::RegisterAllPrefs(prefs_.get(), prefs_.get());
356 }
357 return prefs_.get();
358 }
359
360 history::TopSites* TestingProfile::GetTopSites() {
361 if (!top_sites_.get()) {
362 top_sites_ = new history::TopSites(this);
363 if (!temp_dir_.CreateUniqueTempDir())
364 return NULL;
365 FilePath file_name = temp_dir_.path().AppendASCII("TopSites.db");
366 top_sites_->Init(file_name);
367 }
368 return top_sites_;
369 }
370
321 URLRequestContextGetter* TestingProfile::GetRequestContext() { 371 URLRequestContextGetter* TestingProfile::GetRequestContext() {
322 return request_context_.get(); 372 return request_context_.get();
323 } 373 }
324 374
325 void TestingProfile::CreateRequestContext() { 375 void TestingProfile::CreateRequestContext() {
326 if (!request_context_) 376 if (!request_context_)
327 request_context_ = new TestURLRequestContextGetter(); 377 request_context_ = new TestURLRequestContextGetter();
328 } 378 }
329 379
330 URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { 380 URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
331 if (!extensions_request_context_) 381 if (!extensions_request_context_)
332 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); 382 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
333 return extensions_request_context_.get(); 383 return extensions_request_context_.get();
334 } 384 }
335 385
386 FindBarState* TestingProfile::GetFindBarState() {
387 if (!find_bar_state_.get())
388 find_bar_state_.reset(new FindBarState());
389 return find_bar_state_.get();
390 }
391
392 HostContentSettingsMap* TestingProfile::GetHostContentSettingsMap() {
393 if (!host_content_settings_map_.get())
394 host_content_settings_map_ = new HostContentSettingsMap(this);
395 return host_content_settings_map_.get();
396 }
397
398 GeolocationContentSettingsMap*
399 TestingProfile::GetGeolocationContentSettingsMap() {
400 if (!geolocation_content_settings_map_.get()) {
401 geolocation_content_settings_map_ =
402 new GeolocationContentSettingsMap(this);
403 }
404 return geolocation_content_settings_map_.get();
405 }
406
407 GeolocationPermissionContext*
408 TestingProfile::GetGeolocationPermissionContext() {
409 if (!geolocation_permission_context_.get()) {
410 geolocation_permission_context_ =
411 new GeolocationPermissionContext(this);
412 }
413 return geolocation_permission_context_.get();
414 }
415
336 void TestingProfile::set_session_service(SessionService* session_service) { 416 void TestingProfile::set_session_service(SessionService* session_service) {
337 session_service_ = session_service; 417 session_service_ = session_service;
338 } 418 }
339 419
420 WebKitContext* TestingProfile::GetWebKitContext() {
421 if (webkit_context_ == NULL)
422 webkit_context_ = new WebKitContext(this);
423 return webkit_context_;
424 }
425
340 NTPResourceCache* TestingProfile::GetNTPResourceCache() { 426 NTPResourceCache* TestingProfile::GetNTPResourceCache() {
341 if (!ntp_resource_cache_.get()) 427 if (!ntp_resource_cache_.get())
342 ntp_resource_cache_.reset(new NTPResourceCache(this)); 428 ntp_resource_cache_.reset(new NTPResourceCache(this));
343 return ntp_resource_cache_.get(); 429 return ntp_resource_cache_.get();
344 } 430 }
345 431
432 DesktopNotificationService* TestingProfile::GetDesktopNotificationService() {
433 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
434 if (!desktop_notification_service_.get()) {
435 desktop_notification_service_.reset(new DesktopNotificationService(
436 this, NULL));
437 }
438 return desktop_notification_service_.get();
439 }
440
346 void TestingProfile::BlockUntilHistoryProcessesPendingRequests() { 441 void TestingProfile::BlockUntilHistoryProcessesPendingRequests() {
347 DCHECK(history_service_.get()); 442 DCHECK(history_service_.get());
348 DCHECK(MessageLoop::current()); 443 DCHECK(MessageLoop::current());
349 444
350 CancelableRequestConsumer consumer; 445 CancelableRequestConsumer consumer;
351 history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer); 446 history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer);
352 MessageLoop::current()->Run(); 447 MessageLoop::current()->Run();
353 } 448 }
354 449
355 TokenService* TestingProfile::GetTokenService() { 450 TokenService* TestingProfile::GetTokenService() {
(...skipping 13 matching lines...) Expand all
369 } 464 }
370 return profile_sync_service_.get(); 465 return profile_sync_service_.get();
371 } 466 }
372 467
373 void TestingProfile::DestroyWebDataService() { 468 void TestingProfile::DestroyWebDataService() {
374 if (!web_data_service_.get()) 469 if (!web_data_service_.get())
375 return; 470 return;
376 471
377 web_data_service_->Shutdown(); 472 web_data_service_->Shutdown();
378 } 473 }
OLDNEW
« no previous file with comments | « chrome/test/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698