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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 #include "components/policy/core/common/policy_service_stub.h" | 93 #include "components/policy/core/common/policy_service_stub.h" |
94 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 94 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
95 | 95 |
96 #if defined(ENABLE_EXTENSIONS) | 96 #if defined(ENABLE_EXTENSIONS) |
97 #include "chrome/browser/extensions/extension_service.h" | 97 #include "chrome/browser/extensions/extension_service.h" |
98 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 98 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
99 #include "chrome/browser/extensions/extension_system_factory.h" | 99 #include "chrome/browser/extensions/extension_system_factory.h" |
100 #include "chrome/browser/extensions/test_extension_system.h" | 100 #include "chrome/browser/extensions/test_extension_system.h" |
101 #include "components/guest_view/browser/guest_view_manager.h" | 101 #include "components/guest_view/browser/guest_view_manager.h" |
102 #include "extensions/browser/event_router_factory.h" | 102 #include "extensions/browser/event_router_factory.h" |
| 103 #include "extensions/browser/extension_pref_value_map.h" |
| 104 #include "extensions/browser/extension_pref_value_map_factory.h" |
103 #include "extensions/browser/extension_prefs.h" | 105 #include "extensions/browser/extension_prefs.h" |
104 #include "extensions/browser/extension_prefs_factory.h" | 106 #include "extensions/browser/extension_prefs_factory.h" |
| 107 #include "extensions/browser/extension_prefs_observer.h" |
105 #include "extensions/browser/extension_system.h" | 108 #include "extensions/browser/extension_system.h" |
106 #endif | 109 #endif |
107 | 110 |
108 #if defined(OS_ANDROID) | 111 #if defined(OS_ANDROID) |
109 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" | 112 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" |
110 #endif | 113 #endif |
111 | 114 |
112 #if defined(ENABLE_SUPERVISED_USERS) | 115 #if defined(ENABLE_SUPERVISED_USERS) |
113 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 116 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
114 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 117 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 417 |
415 // TODO(joaodasilva): remove this once this PKS isn't created in ProfileImpl | 418 // TODO(joaodasilva): remove this once this PKS isn't created in ProfileImpl |
416 // anymore, after converting the PrefService to a PKS. Until then it must | 419 // anymore, after converting the PrefService to a PKS. Until then it must |
417 // be associated with a TestingProfile too. | 420 // be associated with a TestingProfile too. |
418 if (!IsOffTheRecord()) | 421 if (!IsOffTheRecord()) |
419 CreateProfilePolicyConnector(); | 422 CreateProfilePolicyConnector(); |
420 | 423 |
421 extensions_path_ = profile_path_.AppendASCII("Extensions"); | 424 extensions_path_ = profile_path_.AppendASCII("Extensions"); |
422 | 425 |
423 #if defined(ENABLE_EXTENSIONS) | 426 #if defined(ENABLE_EXTENSIONS) |
| 427 // Note that the GetPrefs() creates a TestingPrefService, therefore |
| 428 // the extension controlled pref values set in ExtensionPrefs |
| 429 // are not reflected in the pref service. One would need to |
| 430 // inject a new ExtensionPrefStore(extension_pref_value_map, false). |
| 431 bool extensions_disabled = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 432 switches::kDisableExtensions); |
| 433 scoped_ptr<extensions::ExtensionPrefs> extension_prefs( |
| 434 extensions::ExtensionPrefs::Create( |
| 435 this, GetPrefs(), extensions_path_, |
| 436 ExtensionPrefValueMapFactory::GetForBrowserContext(this), |
| 437 extensions_disabled, |
| 438 std::vector<extensions::ExtensionPrefsObserver*>())); |
| 439 extensions::ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting( |
| 440 this, extension_prefs.Pass()); |
| 441 |
424 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory( | 442 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory( |
425 this, extensions::TestExtensionSystem::Build); | 443 this, extensions::TestExtensionSystem::Build); |
426 | 444 |
427 extensions::TestExtensionSystem* test_extension_system = | |
428 static_cast<extensions::TestExtensionSystem*>( | |
429 extensions::ExtensionSystem::Get(this)); | |
430 scoped_ptr<extensions::ExtensionPrefs> extension_prefs = | |
431 test_extension_system->CreateExtensionPrefs( | |
432 base::CommandLine::ForCurrentProcess(), extensions_path_); | |
433 extensions::ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting( | |
434 this, extension_prefs.Pass()); | |
435 | |
436 extensions::EventRouterFactory::GetInstance()->SetTestingFactory(this, | 445 extensions::EventRouterFactory::GetInstance()->SetTestingFactory(this, |
437 nullptr); | 446 nullptr); |
438 #endif | 447 #endif |
439 | 448 |
440 // Prefs for incognito profiles are set in CreateIncognitoPrefService() by | 449 // Prefs for incognito profiles are set in CreateIncognitoPrefService() by |
441 // simulating ProfileImpl::GetOffTheRecordPrefs(). | 450 // simulating ProfileImpl::GetOffTheRecordPrefs(). |
442 if (!IsOffTheRecord()) { | 451 if (!IsOffTheRecord()) { |
443 DCHECK(!original_profile_); | 452 DCHECK(!original_profile_); |
444 user_prefs::PrefRegistrySyncable* pref_registry = | 453 user_prefs::PrefRegistrySyncable* pref_registry = |
445 static_cast<user_prefs::PrefRegistrySyncable*>( | 454 static_cast<user_prefs::PrefRegistrySyncable*>( |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 #if defined(ENABLE_EXTENSIONS) | 1054 #if defined(ENABLE_EXTENSIONS) |
1046 extension_policy_, | 1055 extension_policy_, |
1047 #endif | 1056 #endif |
1048 pref_service_.Pass(), | 1057 pref_service_.Pass(), |
1049 original_profile, | 1058 original_profile, |
1050 guest_session_, | 1059 guest_session_, |
1051 supervised_user_id_, | 1060 supervised_user_id_, |
1052 policy_service_.Pass(), | 1061 policy_service_.Pass(), |
1053 testing_factories_); | 1062 testing_factories_); |
1054 } | 1063 } |
OLD | NEW |