| 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 #include "chrome/test/base/testing_profile.h" | 5 #include "chrome/test/base/testing_profile.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/prefs/testing_pref_store.h" | 14 #include "base/prefs/testing_pref_store.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
| 20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/content_settings/host_content_settings_map.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 25 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 25 #include "chrome/browser/extensions/extension_system_factory.h" | 26 #include "chrome/browser/extensions/extension_system_factory.h" |
| 26 #include "chrome/browser/extensions/test_extension_system.h" | 27 #include "chrome/browser/extensions/test_extension_system.h" |
| 27 #include "chrome/browser/favicon/favicon_service.h" | 28 #include "chrome/browser/favicon/favicon_service.h" |
| 28 #include "chrome/browser/favicon/favicon_service_factory.h" | 29 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 29 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // need to be run to properly shutdown. Run all pending tasks now. This is | 495 // need to be run to properly shutdown. Run all pending tasks now. This is |
| 495 // normally handled by browser_process shutdown. | 496 // normally handled by browser_process shutdown. |
| 496 if (base::MessageLoop::current()) | 497 if (base::MessageLoop::current()) |
| 497 base::MessageLoop::current()->RunUntilIdle(); | 498 base::MessageLoop::current()->RunUntilIdle(); |
| 498 } | 499 } |
| 499 } | 500 } |
| 500 | 501 |
| 501 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) { | 502 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) { |
| 502 Profile* profile = static_cast<Profile*>(context); | 503 Profile* profile = static_cast<Profile*>(context); |
| 503 ChromeBookmarkClient* bookmark_client = | 504 ChromeBookmarkClient* bookmark_client = |
| 504 new ChromeBookmarkClient(profile, false); | 505 ChromeBookmarkClientFactory::GetForProfile(profile); |
| 505 bookmark_client->model()->Load( | 506 BookmarkModel* bookmark_model = new BookmarkModel(bookmark_client, false); |
| 506 profile->GetPrefs(), | 507 bookmark_client->Init(bookmark_model); |
| 507 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 508 bookmark_model->Load(profile->GetPrefs(), |
| 508 profile->GetPath(), | 509 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 509 profile->GetIOTaskRunner(), | 510 profile->GetPath(), |
| 510 content::BrowserThread::GetMessageLoopProxyForThread( | 511 profile->GetIOTaskRunner(), |
| 511 content::BrowserThread::UI)); | 512 content::BrowserThread::GetMessageLoopProxyForThread( |
| 512 return bookmark_client; | 513 content::BrowserThread::UI)); |
| 514 return bookmark_model; |
| 515 } |
| 516 |
| 517 static KeyedService* BuildChromeBookmarkClient( |
| 518 content::BrowserContext* context) { |
| 519 return new ChromeBookmarkClient(static_cast<Profile*>(context)); |
| 513 } | 520 } |
| 514 | 521 |
| 515 static KeyedService* BuildChromeHistoryClient( | 522 static KeyedService* BuildChromeHistoryClient( |
| 516 content::BrowserContext* context) { | 523 content::BrowserContext* context) { |
| 517 Profile* profile = static_cast<Profile*>(context); | 524 Profile* profile = static_cast<Profile*>(context); |
| 518 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile)); | 525 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile)); |
| 519 } | 526 } |
| 520 | 527 |
| 521 void TestingProfile::CreateBookmarkModel(bool delete_file) { | 528 void TestingProfile::CreateBookmarkModel(bool delete_file) { |
| 522 if (delete_file) { | 529 if (delete_file) { |
| 523 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); | 530 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); |
| 524 base::DeleteFile(path, false); | 531 base::DeleteFile(path, false); |
| 525 } | 532 } |
| 526 // This will create a bookmark model. | |
| 527 ChromeHistoryClientFactory::GetInstance()->SetTestingFactory( | 533 ChromeHistoryClientFactory::GetInstance()->SetTestingFactory( |
| 528 this, BuildChromeHistoryClient); | 534 this, BuildChromeHistoryClient); |
| 529 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( | 535 ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory( |
| 530 this, BuildBookmarkModel); | 536 this, BuildChromeBookmarkClient); |
| 537 // This creates the BookmarkModel. |
| 538 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( |
| 539 this, BuildBookmarkModel)); |
| 531 } | 540 } |
| 532 | 541 |
| 533 static KeyedService* BuildWebDataService(content::BrowserContext* profile) { | 542 static KeyedService* BuildWebDataService(content::BrowserContext* profile) { |
| 534 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); | 543 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); |
| 535 } | 544 } |
| 536 | 545 |
| 537 void TestingProfile::CreateWebDataService() { | 546 void TestingProfile::CreateWebDataService() { |
| 538 WebDataServiceFactory::GetInstance()->SetTestingFactory( | 547 WebDataServiceFactory::GetInstance()->SetTestingFactory( |
| 539 this, BuildWebDataService); | 548 this, BuildWebDataService); |
| 540 } | 549 } |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 path_, | 992 path_, |
| 984 delegate_, | 993 delegate_, |
| 985 extension_policy_, | 994 extension_policy_, |
| 986 pref_service_.Pass(), | 995 pref_service_.Pass(), |
| 987 incognito_, | 996 incognito_, |
| 988 guest_session_, | 997 guest_session_, |
| 989 managed_user_id_, | 998 managed_user_id_, |
| 990 policy_service_.Pass(), | 999 policy_service_.Pass(), |
| 991 testing_factories_)); | 1000 testing_factories_)); |
| 992 } | 1001 } |
| OLD | NEW |