| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "chrome/browser/webdata/web_data_service.h" | 48 #include "chrome/browser/webdata/web_data_service.h" |
| 49 #include "chrome/browser/webdata/web_data_service_factory.h" | 49 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 50 #include "chrome/common/chrome_constants.h" | 50 #include "chrome/common/chrome_constants.h" |
| 51 #include "chrome/common/chrome_notification_types.h" | 51 #include "chrome/common/chrome_notification_types.h" |
| 52 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/url_constants.h" | 53 #include "chrome/common/url_constants.h" |
| 54 #include "chrome/test/base/bookmark_load_observer.h" | 54 #include "chrome/test/base/bookmark_load_observer.h" |
| 55 #include "chrome/test/base/history_index_restore_observer.h" | 55 #include "chrome/test/base/history_index_restore_observer.h" |
| 56 #include "chrome/test/base/testing_pref_service_syncable.h" | 56 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 57 #include "chrome/test/base/ui_test_utils.h" | 57 #include "chrome/test/base/ui_test_utils.h" |
| 58 #include "components/user_prefs/user_prefs.h" |
| 58 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
| 59 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
| 60 #include "content/public/browser/render_process_host.h" | 61 #include "content/public/browser/render_process_host.h" |
| 61 #include "content/public/browser/storage_partition.h" | 62 #include "content/public/browser/storage_partition.h" |
| 62 #include "content/public/test/mock_resource_context.h" | 63 #include "content/public/test/mock_resource_context.h" |
| 63 #include "content/public/test/test_utils.h" | 64 #include "content/public/test/test_utils.h" |
| 64 #include "extensions/common/constants.h" | 65 #include "extensions/common/constants.h" |
| 65 #include "net/cookies/cookie_monster.h" | 66 #include "net/cookies/cookie_monster.h" |
| 66 #include "net/url_request/url_request_context.h" | 67 #include "net/url_request/url_request_context.h" |
| 67 #include "net/url_request/url_request_context_getter.h" | 68 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // That shouldn't happen, but if it does, try to recover. | 265 // That shouldn't happen, but if it does, try to recover. |
| 265 LOG(ERROR) << "Failed to use a fallback temporary directory."; | 266 LOG(ERROR) << "Failed to use a fallback temporary directory."; |
| 266 | 267 |
| 267 // We're screwed if this fails, see CHECK above. | 268 // We're screwed if this fails, see CHECK above. |
| 268 CHECK(temp_dir_.Set(system_tmp_dir)); | 269 CHECK(temp_dir_.Set(system_tmp_dir)); |
| 269 } | 270 } |
| 270 } | 271 } |
| 271 } | 272 } |
| 272 | 273 |
| 273 void TestingProfile::Init() { | 274 void TestingProfile::Init() { |
| 275 if (prefs_.get()) |
| 276 components::UserPrefs::Set(this, prefs_.get()); |
| 277 |
| 274 if (!file_util::PathExists(profile_path_)) | 278 if (!file_util::PathExists(profile_path_)) |
| 275 file_util::CreateDirectory(profile_path_); | 279 file_util::CreateDirectory(profile_path_); |
| 276 | 280 |
| 277 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory( | 281 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory( |
| 278 this, extensions::TestExtensionSystem::Build); | 282 this, extensions::TestExtensionSystem::Build); |
| 279 | 283 |
| 280 profile_dependency_manager_->CreateProfileServices(this, true); | 284 profile_dependency_manager_->CreateProfileServices(this, true); |
| 281 | 285 |
| 282 #if defined(ENABLE_NOTIFICATIONS) | 286 #if defined(ENABLE_NOTIFICATIONS) |
| 283 // Install profile keyed service factory hooks for dummy/test services | 287 // Install profile keyed service factory hooks for dummy/test services |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 policy_service_.reset(new policy::PolicyServiceStub()); | 556 policy_service_.reset(new policy::PolicyServiceStub()); |
| 553 #endif | 557 #endif |
| 554 } | 558 } |
| 555 return policy_service_.get(); | 559 return policy_service_.get(); |
| 556 } | 560 } |
| 557 | 561 |
| 558 void TestingProfile::CreateTestingPrefService() { | 562 void TestingProfile::CreateTestingPrefService() { |
| 559 DCHECK(!prefs_.get()); | 563 DCHECK(!prefs_.get()); |
| 560 testing_prefs_ = new TestingPrefServiceSyncable(); | 564 testing_prefs_ = new TestingPrefServiceSyncable(); |
| 561 prefs_.reset(testing_prefs_); | 565 prefs_.reset(testing_prefs_); |
| 566 components::UserPrefs::Set(this, prefs_.get()); |
| 562 chrome::RegisterUserPrefs(testing_prefs_->registry()); | 567 chrome::RegisterUserPrefs(testing_prefs_->registry()); |
| 563 } | 568 } |
| 564 | 569 |
| 565 PrefService* TestingProfile::GetPrefs() { | 570 PrefService* TestingProfile::GetPrefs() { |
| 566 if (!prefs_.get()) { | 571 if (!prefs_.get()) { |
| 567 CreateTestingPrefService(); | 572 CreateTestingPrefService(); |
| 568 } | 573 } |
| 569 return prefs_.get(); | 574 return prefs_.get(); |
| 570 } | 575 } |
| 571 | 576 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 817 |
| 813 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 818 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
| 814 DCHECK(!build_called_); | 819 DCHECK(!build_called_); |
| 815 build_called_ = true; | 820 build_called_ = true; |
| 816 return scoped_ptr<TestingProfile>(new TestingProfile( | 821 return scoped_ptr<TestingProfile>(new TestingProfile( |
| 817 path_, | 822 path_, |
| 818 delegate_, | 823 delegate_, |
| 819 extension_policy_, | 824 extension_policy_, |
| 820 pref_service_.Pass())); | 825 pref_service_.Pass())); |
| 821 } | 826 } |
| OLD | NEW |