| 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 <utility> | 7 #include <utility> |
| 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 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 26 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 27 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" | 27 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" |
| 28 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | 28 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
| 29 #include "chrome/browser/favicon/favicon_service_factory.h" | 29 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 30 #include "chrome/browser/history/chrome_history_client.h" | 30 #include "chrome/browser/history/chrome_history_client.h" |
| 31 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
| 32 #include "chrome/browser/history/web_history_service_factory.h" | 32 #include "chrome/browser/history/web_history_service_factory.h" |
| 33 #include "chrome/browser/net/proxy_service_factory.h" | 33 #include "chrome/browser/net/proxy_service_factory.h" |
| 34 #include "chrome/browser/policy/profile_policy_connector.h" | 34 #include "chrome/browser/policy/profile_policy_connector.h" |
| 35 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 35 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 36 #include "chrome/browser/policy/schema_registry_service.h" |
| 37 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 36 #include "chrome/browser/prefs/browser_prefs.h" | 38 #include "chrome/browser/prefs/browser_prefs.h" |
| 37 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 39 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 38 #include "chrome/browser/prerender/prerender_manager.h" | 40 #include "chrome/browser/prerender/prerender_manager.h" |
| 39 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" | 41 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
| 40 #include "chrome/browser/profiles/profile_manager.h" | 42 #include "chrome/browser/profiles/profile_manager.h" |
| 41 #include "chrome/browser/profiles/storage_partition_descriptor.h" | 43 #include "chrome/browser/profiles/storage_partition_descriptor.h" |
| 42 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
| 43 #include "chrome/browser/search_engines/template_url_service_factory.h" | 45 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 44 #include "chrome/browser/sync/glue/sync_start_util.h" | 46 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 45 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 47 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 #include "components/history/core/browser/history_backend.h" | 61 #include "components/history/core/browser/history_backend.h" |
| 60 #include "components/history/core/browser/history_constants.h" | 62 #include "components/history/core/browser/history_constants.h" |
| 61 #include "components/history/core/browser/history_database_params.h" | 63 #include "components/history/core/browser/history_database_params.h" |
| 62 #include "components/history/core/browser/history_db_task.h" | 64 #include "components/history/core/browser/history_db_task.h" |
| 63 #include "components/history/core/browser/history_service.h" | 65 #include "components/history/core/browser/history_service.h" |
| 64 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 66 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 65 #include "components/keyed_service/core/refcounted_keyed_service.h" | 67 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| 66 #include "components/omnibox/browser/autocomplete_classifier.h" | 68 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 67 #include "components/omnibox/browser/history_index_restore_observer.h" | 69 #include "components/omnibox/browser/history_index_restore_observer.h" |
| 68 #include "components/omnibox/browser/in_memory_url_index.h" | 70 #include "components/omnibox/browser/in_memory_url_index.h" |
| 71 #include "components/policy/core/common/configuration_policy_provider.h" |
| 69 #include "components/policy/core/common/policy_service.h" | 72 #include "components/policy/core/common/policy_service.h" |
| 73 #include "components/policy/core/common/policy_service_impl.h" |
| 74 #include "components/policy/core/common/schema.h" |
| 70 #include "components/prefs/testing_pref_store.h" | 75 #include "components/prefs/testing_pref_store.h" |
| 71 #include "components/proxy_config/pref_proxy_config_tracker.h" | 76 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 72 #include "components/syncable_prefs/pref_service_syncable.h" | 77 #include "components/syncable_prefs/pref_service_syncable.h" |
| 73 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 78 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 74 #include "components/ui/zoom/zoom_event_manager.h" | 79 #include "components/ui/zoom/zoom_event_manager.h" |
| 75 #include "components/user_prefs/user_prefs.h" | 80 #include "components/user_prefs/user_prefs.h" |
| 76 #include "components/webdata_services/web_data_service_wrapper.h" | 81 #include "components/webdata_services/web_data_service_wrapper.h" |
| 77 #include "content/public/browser/browser_thread.h" | 82 #include "content/public/browser/browser_thread.h" |
| 78 #include "content/public/browser/cookie_store_factory.h" | 83 #include "content/public/browser/cookie_store_factory.h" |
| 79 #include "content/public/browser/notification_service.h" | 84 #include "content/public/browser/notification_service.h" |
| 80 #include "content/public/browser/render_process_host.h" | 85 #include "content/public/browser/render_process_host.h" |
| 81 #include "content/public/browser/storage_partition.h" | 86 #include "content/public/browser/storage_partition.h" |
| 82 #include "content/public/browser/zoom_level_delegate.h" | 87 #include "content/public/browser/zoom_level_delegate.h" |
| 83 #include "content/public/test/mock_resource_context.h" | 88 #include "content/public/test/mock_resource_context.h" |
| 84 #include "content/public/test/test_utils.h" | 89 #include "content/public/test/test_utils.h" |
| 85 #include "extensions/common/constants.h" | 90 #include "extensions/common/constants.h" |
| 86 #include "net/cookies/cookie_store.h" | 91 #include "net/cookies/cookie_store.h" |
| 87 #include "net/url_request/url_request_context.h" | 92 #include "net/url_request/url_request_context.h" |
| 88 #include "net/url_request/url_request_context_getter.h" | 93 #include "net/url_request/url_request_context_getter.h" |
| 89 #include "net/url_request/url_request_test_util.h" | 94 #include "net/url_request/url_request_test_util.h" |
| 90 #include "testing/gmock/include/gmock/gmock.h" | 95 #include "testing/gmock/include/gmock/gmock.h" |
| 91 | 96 |
| 92 #if defined(ENABLE_CONFIGURATION_POLICY) | |
| 93 #include "chrome/browser/policy/schema_registry_service.h" | |
| 94 #include "chrome/browser/policy/schema_registry_service_factory.h" | |
| 95 #include "components/policy/core/common/configuration_policy_provider.h" | |
| 96 #include "components/policy/core/common/policy_service_impl.h" | |
| 97 #include "components/policy/core/common/schema.h" | |
| 98 #else | |
| 99 #include "components/policy/core/common/policy_service_stub.h" | |
| 100 #endif // defined(ENABLE_CONFIGURATION_POLICY) | |
| 101 | |
| 102 #if defined(ENABLE_EXTENSIONS) | 97 #if defined(ENABLE_EXTENSIONS) |
| 103 #include "chrome/browser/extensions/extension_service.h" | 98 #include "chrome/browser/extensions/extension_service.h" |
| 104 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 99 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 105 #include "chrome/browser/extensions/extension_system_factory.h" | 100 #include "chrome/browser/extensions/extension_system_factory.h" |
| 106 #include "chrome/browser/extensions/test_extension_system.h" | 101 #include "chrome/browser/extensions/test_extension_system.h" |
| 107 #include "components/guest_view/browser/guest_view_manager.h" | 102 #include "components/guest_view/browser/guest_view_manager.h" |
| 108 #include "extensions/browser/event_router_factory.h" | 103 #include "extensions/browser/event_router_factory.h" |
| 109 #include "extensions/browser/extension_pref_value_map.h" | 104 #include "extensions/browser/extension_pref_value_map.h" |
| 110 #include "extensions/browser/extension_pref_value_map_factory.h" | 105 #include "extensions/browser/extension_pref_value_map_factory.h" |
| 111 #include "extensions/browser/extension_prefs.h" | 106 #include "extensions/browser/extension_prefs.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 DCHECK(original_profile_); | 751 DCHECK(original_profile_); |
| 757 DCHECK(!testing_prefs_); | 752 DCHECK(!testing_prefs_); |
| 758 // Simplified version of ProfileImpl::GetOffTheRecordPrefs(). Note this | 753 // Simplified version of ProfileImpl::GetOffTheRecordPrefs(). Note this |
| 759 // leaves testing_prefs_ unset. | 754 // leaves testing_prefs_ unset. |
| 760 prefs_.reset(CreateIncognitoPrefServiceSyncable( | 755 prefs_.reset(CreateIncognitoPrefServiceSyncable( |
| 761 original_profile_->prefs_.get(), NULL)); | 756 original_profile_->prefs_.get(), NULL)); |
| 762 user_prefs::UserPrefs::Set(this, prefs_.get()); | 757 user_prefs::UserPrefs::Set(this, prefs_.get()); |
| 763 } | 758 } |
| 764 | 759 |
| 765 void TestingProfile::CreateProfilePolicyConnector() { | 760 void TestingProfile::CreateProfilePolicyConnector() { |
| 766 #if defined(ENABLE_CONFIGURATION_POLICY) | |
| 767 schema_registry_service_ = | 761 schema_registry_service_ = |
| 768 policy::SchemaRegistryServiceFactory::CreateForContext( | 762 policy::SchemaRegistryServiceFactory::CreateForContext( |
| 769 this, policy::Schema(), NULL); | 763 this, policy::Schema(), NULL); |
| 770 CHECK_EQ(schema_registry_service_.get(), | 764 CHECK_EQ(schema_registry_service_.get(), |
| 771 policy::SchemaRegistryServiceFactory::GetForContext(this)); | 765 policy::SchemaRegistryServiceFactory::GetForContext(this)); |
| 772 #endif // defined(ENABLE_CONFIGURATION_POLICY) | |
| 773 | 766 |
| 774 if (!policy_service_) { | 767 if (!policy_service_) { |
| 775 #if defined(ENABLE_CONFIGURATION_POLICY) | |
| 776 std::vector<policy::ConfigurationPolicyProvider*> providers; | 768 std::vector<policy::ConfigurationPolicyProvider*> providers; |
| 777 policy_service_.reset(new policy::PolicyServiceImpl(providers)); | 769 policy_service_.reset(new policy::PolicyServiceImpl(providers)); |
| 778 #else | |
| 779 policy_service_.reset(new policy::PolicyServiceStub()); | |
| 780 #endif | |
| 781 } | 770 } |
| 782 profile_policy_connector_.reset(new policy::ProfilePolicyConnector()); | 771 profile_policy_connector_.reset(new policy::ProfilePolicyConnector()); |
| 783 profile_policy_connector_->InitForTesting(std::move(policy_service_)); | 772 profile_policy_connector_->InitForTesting(std::move(policy_service_)); |
| 784 policy::ProfilePolicyConnectorFactory::GetInstance()->SetServiceForTesting( | 773 policy::ProfilePolicyConnectorFactory::GetInstance()->SetServiceForTesting( |
| 785 this, profile_policy_connector_.get()); | 774 this, profile_policy_connector_.get()); |
| 786 CHECK_EQ(profile_policy_connector_.get(), | 775 CHECK_EQ(profile_policy_connector_.get(), |
| 787 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(this)); | 776 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(this)); |
| 788 } | 777 } |
| 789 | 778 |
| 790 PrefService* TestingProfile::GetPrefs() { | 779 PrefService* TestingProfile::GetPrefs() { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 // Note: Owned by |original_profile|. | 1045 // Note: Owned by |original_profile|. |
| 1057 return new TestingProfile(path_, delegate_, | 1046 return new TestingProfile(path_, delegate_, |
| 1058 #if defined(ENABLE_EXTENSIONS) | 1047 #if defined(ENABLE_EXTENSIONS) |
| 1059 extension_policy_, | 1048 extension_policy_, |
| 1060 #endif | 1049 #endif |
| 1061 std::move(pref_service_), original_profile, | 1050 std::move(pref_service_), original_profile, |
| 1062 guest_session_, supervised_user_id_, | 1051 guest_session_, supervised_user_id_, |
| 1063 std::move(policy_service_), testing_factories_, | 1052 std::move(policy_service_), testing_factories_, |
| 1064 profile_name_); | 1053 profile_name_); |
| 1065 } | 1054 } |
| OLD | NEW |