| 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/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/testing_pref_service.h" | 12 #include "base/prefs/testing_pref_service.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/test/test_simple_task_runner.h" | 17 #include "base/test/test_simple_task_runner.h" |
| 18 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" | 18 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" |
| 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" | 20 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" |
| 21 #include "chrome/browser/policy/cloud/mock_cloud_external_data_manager.h" | 21 #include "chrome/browser/policy/cloud/mock_cloud_external_data_manager.h" |
| 22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" | 22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" |
| 23 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 23 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
| 24 #include "chrome/browser/policy/cloud/resource_cache.h" | 24 #include "chrome/browser/policy/cloud/resource_cache.h" |
| 25 #include "chrome/browser/policy/external_data_fetcher.h" | 25 #include "chrome/browser/policy/external_data_fetcher.h" |
| 26 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 26 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| 27 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 27 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" |
| 28 #include "chrome/browser/policy/schema_registry.h" |
| 28 #include "chrome/browser/prefs/browser_prefs.h" | 29 #include "chrome/browser/prefs/browser_prefs.h" |
| 29 #include "chrome/browser/prefs/pref_service_syncable.h" | 30 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 30 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 31 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 31 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 32 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 32 #include "chrome/browser/signin/signin_manager.h" | 33 #include "chrome/browser/signin/signin_manager.h" |
| 33 #include "chrome/browser/signin/signin_manager_factory.h" | 34 #include "chrome/browser/signin/signin_manager_factory.h" |
| 34 #include "chrome/browser/signin/token_service.h" | 35 #include "chrome/browser/signin/token_service.h" |
| 35 #include "chrome/browser/signin/token_service_factory.h" | 36 #include "chrome/browser/signin/token_service_factory.h" |
| 36 #include "chrome/common/chrome_constants.h" | 37 #include "chrome/common/chrome_constants.h" |
| 37 #include "chrome/test/base/testing_browser_process.h" | 38 #include "chrome/test/base/testing_browser_process.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 external_data_manager_ = new MockCloudExternalDataManager; | 153 external_data_manager_ = new MockCloudExternalDataManager; |
| 153 external_data_manager_->SetPolicyStore(store_); | 154 external_data_manager_->SetPolicyStore(store_); |
| 154 EXPECT_CALL(*store_, Load()); | 155 EXPECT_CALL(*store_, Load()); |
| 155 manager_.reset(new UserCloudPolicyManagerChromeOS( | 156 manager_.reset(new UserCloudPolicyManagerChromeOS( |
| 156 scoped_ptr<CloudPolicyStore>(store_), | 157 scoped_ptr<CloudPolicyStore>(store_), |
| 157 scoped_ptr<CloudExternalDataManager>(external_data_manager_), | 158 scoped_ptr<CloudExternalDataManager>(external_data_manager_), |
| 158 task_runner_, | 159 task_runner_, |
| 159 scoped_ptr<ResourceCache>(), | 160 scoped_ptr<ResourceCache>(), |
| 160 wait_for_fetch, | 161 wait_for_fetch, |
| 161 base::TimeDelta::FromSeconds(fetch_timeout))); | 162 base::TimeDelta::FromSeconds(fetch_timeout))); |
| 162 manager_->Init(); | 163 manager_->Init(&schema_registry_); |
| 163 manager_->AddObserver(&observer_); | 164 manager_->AddObserver(&observer_); |
| 164 manager_->Connect(&prefs_, &device_management_service_, NULL, | 165 manager_->Connect(&prefs_, &device_management_service_, NULL, |
| 165 USER_AFFILIATION_NONE); | 166 USER_AFFILIATION_NONE); |
| 166 Mock::VerifyAndClearExpectations(store_); | 167 Mock::VerifyAndClearExpectations(store_); |
| 167 EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 168 EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
| 168 EXPECT_FALSE(manager_->core()->service()->IsInitializationComplete()); | 169 EXPECT_FALSE(manager_->core()->service()->IsInitializationComplete()); |
| 169 | 170 |
| 170 if (!wait_for_fetch) { | 171 if (!wait_for_fetch) { |
| 171 // Create the UserCloudPolicyTokenForwarder, which fetches the access | 172 // Create the UserCloudPolicyTokenForwarder, which fetches the access |
| 172 // token using the OAuth2PolicyFetcher and forwards it to the | 173 // token using the OAuth2PolicyFetcher and forwards it to the |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 PolicyBundle expected_bundle_; | 291 PolicyBundle expected_bundle_; |
| 291 | 292 |
| 292 // Policy infrastructure. | 293 // Policy infrastructure. |
| 293 net::TestURLFetcherFactory test_url_fetcher_factory_; | 294 net::TestURLFetcherFactory test_url_fetcher_factory_; |
| 294 TestingPrefServiceSimple prefs_; | 295 TestingPrefServiceSimple prefs_; |
| 295 MockConfigurationPolicyObserver observer_; | 296 MockConfigurationPolicyObserver observer_; |
| 296 MockDeviceManagementService device_management_service_; | 297 MockDeviceManagementService device_management_service_; |
| 297 MockCloudPolicyStore* store_; // Not owned. | 298 MockCloudPolicyStore* store_; // Not owned. |
| 298 MockCloudExternalDataManager* external_data_manager_; // Not owned. | 299 MockCloudExternalDataManager* external_data_manager_; // Not owned. |
| 299 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 300 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
| 301 SchemaRegistry schema_registry_; |
| 300 scoped_ptr<UserCloudPolicyManagerChromeOS> manager_; | 302 scoped_ptr<UserCloudPolicyManagerChromeOS> manager_; |
| 301 scoped_ptr<UserCloudPolicyTokenForwarder> token_forwarder_; | 303 scoped_ptr<UserCloudPolicyTokenForwarder> token_forwarder_; |
| 302 | 304 |
| 303 // Required by ProfileHelper to get the signin Profile context. | 305 // Required by ProfileHelper to get the signin Profile context. |
| 304 scoped_ptr<TestingProfileManager> profile_manager_; | 306 scoped_ptr<TestingProfileManager> profile_manager_; |
| 305 TestingProfile* profile_; | 307 TestingProfile* profile_; |
| 306 TestingProfile* signin_profile_; | 308 TestingProfile* signin_profile_; |
| 307 | 309 |
| 308 static const char kSigninProfile[]; | 310 static const char kSigninProfile[]; |
| 309 | 311 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 554 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
| 553 EXPECT_TRUE(manager_->core()->client()->is_registered()); | 555 EXPECT_TRUE(manager_->core()->client()->is_registered()); |
| 554 | 556 |
| 555 // The refresh scheduler takes care of the initial fetch for unmanaged users. | 557 // The refresh scheduler takes care of the initial fetch for unmanaged users. |
| 556 // Running the task runner issues the initial fetch. | 558 // Running the task runner issues the initial fetch. |
| 557 FetchPolicy( | 559 FetchPolicy( |
| 558 base::Bind(&base::TestSimpleTaskRunner::RunUntilIdle, task_runner_)); | 560 base::Bind(&base::TestSimpleTaskRunner::RunUntilIdle, task_runner_)); |
| 559 } | 561 } |
| 560 | 562 |
| 561 } // namespace policy | 563 } // namespace policy |
| OLD | NEW |