| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/content_settings/host_content_settings_map.h" | 22 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 24 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 25 #include "chrome/browser/extensions/extension_system_factory.h" | 25 #include "chrome/browser/extensions/extension_system_factory.h" |
| 26 #include "chrome/browser/extensions/test_extension_system.h" | 26 #include "chrome/browser/extensions/test_extension_system.h" |
| 27 #include "chrome/browser/favicon/favicon_service.h" | 27 #include "chrome/browser/favicon/favicon_service.h" |
| 28 #include "chrome/browser/favicon/favicon_service_factory.h" | 28 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 29 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 29 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto
ry.h" | 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto
ry.h" |
| 31 #include "chrome/browser/guest_view/guest_view_manager.h" | 31 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 32 #include "chrome/browser/history/chrome_history_client.h" |
| 32 #include "chrome/browser/history/history_backend.h" | 33 #include "chrome/browser/history/history_backend.h" |
| 33 #include "chrome/browser/history/history_db_task.h" | 34 #include "chrome/browser/history/history_db_task.h" |
| 34 #include "chrome/browser/history/history_service.h" | 35 #include "chrome/browser/history/history_service.h" |
| 35 #include "chrome/browser/history/history_service_factory.h" | 36 #include "chrome/browser/history/history_service_factory.h" |
| 36 #include "chrome/browser/history/top_sites.h" | 37 #include "chrome/browser/history/top_sites.h" |
| 37 #include "chrome/browser/history/web_history_service_factory.h" | 38 #include "chrome/browser/history/web_history_service_factory.h" |
| 38 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 39 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 39 #include "chrome/browser/net/proxy_service_factory.h" | 40 #include "chrome/browser/net/proxy_service_factory.h" |
| 40 #include "chrome/browser/notifications/desktop_notification_service.h" | 41 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 41 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 42 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 89 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 89 | 90 |
| 90 #if defined(ENABLE_MANAGED_USERS) | 91 #if defined(ENABLE_MANAGED_USERS) |
| 91 #include "chrome/browser/managed_mode/managed_user_settings_service.h" | 92 #include "chrome/browser/managed_mode/managed_user_settings_service.h" |
| 92 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" | 93 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" |
| 93 #endif | 94 #endif |
| 94 | 95 |
| 95 using base::Time; | 96 using base::Time; |
| 96 using content::BrowserThread; | 97 using content::BrowserThread; |
| 97 using content::DownloadManagerDelegate; | 98 using content::DownloadManagerDelegate; |
| 99 using history::ChromeHistoryClient; |
| 98 using testing::NiceMock; | 100 using testing::NiceMock; |
| 99 using testing::Return; | 101 using testing::Return; |
| 100 | 102 |
| 101 namespace { | 103 namespace { |
| 102 | 104 |
| 103 // Task used to make sure history has finished processing a request. Intended | 105 // Task used to make sure history has finished processing a request. Intended |
| 104 // for use with BlockUntilHistoryProcessesPendingRequests. | 106 // for use with BlockUntilHistoryProcessesPendingRequests. |
| 105 | 107 |
| 106 class QuittingHistoryDBTask : public history::HistoryDBTask { | 108 class QuittingHistoryDBTask : public history::HistoryDBTask { |
| 107 public: | 109 public: |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 return new FaviconService(static_cast<Profile*>(profile)); | 422 return new FaviconService(static_cast<Profile*>(profile)); |
| 421 } | 423 } |
| 422 | 424 |
| 423 void TestingProfile::CreateFaviconService() { | 425 void TestingProfile::CreateFaviconService() { |
| 424 // It is up to the caller to create the history service if one is needed. | 426 // It is up to the caller to create the history service if one is needed. |
| 425 FaviconServiceFactory::GetInstance()->SetTestingFactory( | 427 FaviconServiceFactory::GetInstance()->SetTestingFactory( |
| 426 this, BuildFaviconService); | 428 this, BuildFaviconService); |
| 427 } | 429 } |
| 428 | 430 |
| 429 static KeyedService* BuildHistoryService(content::BrowserContext* profile) { | 431 static KeyedService* BuildHistoryService(content::BrowserContext* profile) { |
| 430 return new HistoryService(static_cast<Profile*>(profile)); | 432 return new ChromeHistoryClient(static_cast<Profile*>(profile)); |
| 431 } | 433 } |
| 432 | 434 |
| 433 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 435 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
| 434 DestroyHistoryService(); | 436 DestroyHistoryService(); |
| 435 if (delete_file) { | 437 if (delete_file) { |
| 436 base::FilePath path = GetPath(); | 438 base::FilePath path = GetPath(); |
| 437 path = path.Append(chrome::kHistoryFilename); | 439 path = path.Append(chrome::kHistoryFilename); |
| 438 if (!base::DeleteFile(path, false) || base::PathExists(path)) | 440 if (!base::DeleteFile(path, false) || base::PathExists(path)) |
| 439 return false; | 441 return false; |
| 440 } | 442 } |
| 441 // This will create and init the history service. | 443 // This will create and init the history service. |
| 442 HistoryService* history_service = static_cast<HistoryService*>( | 444 ChromeHistoryClient* history_client = static_cast<ChromeHistoryClient*>( |
| 443 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 445 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 444 this, BuildHistoryService)); | 446 this, BuildHistoryService)); |
| 447 HistoryService* history_service = history_client->history_service(); |
| 445 if (!history_service->Init(this->GetPath(), | 448 if (!history_service->Init(this->GetPath(), |
| 446 BookmarkModelFactory::GetForProfile(this), | 449 BookmarkModelFactory::GetForProfile(this), |
| 447 no_db)) { | 450 no_db)) { |
| 448 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); | 451 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); |
| 449 } | 452 } |
| 450 // Disable WebHistoryService by default, since it makes network requests. | 453 // Disable WebHistoryService by default, since it makes network requests. |
| 451 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL); | 454 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL); |
| 452 return true; | 455 return true; |
| 453 } | 456 } |
| 454 | 457 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 path_, | 988 path_, |
| 986 delegate_, | 989 delegate_, |
| 987 extension_policy_, | 990 extension_policy_, |
| 988 pref_service_.Pass(), | 991 pref_service_.Pass(), |
| 989 incognito_, | 992 incognito_, |
| 990 guest_session_, | 993 guest_session_, |
| 991 managed_user_id_, | 994 managed_user_id_, |
| 992 policy_service_.Pass(), | 995 policy_service_.Pass(), |
| 993 testing_factories_)); | 996 testing_factories_)); |
| 994 } | 997 } |
| OLD | NEW |