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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
13 #include "base/prefs/testing_pref_service.h" | 13 #include "base/prefs/testing_pref_service.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.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 "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" | 17 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" |
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
19 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 19 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
20 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 20 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
21 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" | 21 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" |
22 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 22 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
23 #include "chrome/browser/policy/cloud/resource_cache.h" | 23 #include "chrome/browser/policy/cloud/resource_cache.h" |
24 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 24 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
25 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 25 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" |
26 #include "chrome/browser/prefs/browser_prefs.h" | 26 #include "chrome/browser/prefs/browser_prefs.h" |
| 27 #include "chrome/browser/prefs/pref_service_syncable.h" |
27 #include "chrome/browser/signin/token_service.h" | 28 #include "chrome/browser/signin/token_service.h" |
28 #include "chrome/browser/signin/token_service_factory.h" | 29 #include "chrome/browser/signin/token_service_factory.h" |
29 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
30 #include "chrome/test/base/testing_browser_process.h" | 31 #include "chrome/test/base/testing_browser_process.h" |
31 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
32 #include "chrome/test/base/testing_profile_manager.h" | 33 #include "chrome/test/base/testing_profile_manager.h" |
33 #include "content/public/test/test_browser_thread.h" | 34 #include "content/public/test/test_browser_thread.h" |
34 #include "google_apis/gaia/gaia_auth_consumer.h" | 35 #include "google_apis/gaia/gaia_auth_consumer.h" |
35 #include "google_apis/gaia/gaia_urls.h" | 36 #include "google_apis/gaia/gaia_urls.h" |
36 #include "net/url_request/test_url_fetcher_factory.h" | 37 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 profile_(NULL), | 79 profile_(NULL), |
79 signin_profile_(NULL) {} | 80 signin_profile_(NULL) {} |
80 | 81 |
81 virtual void SetUp() OVERRIDE { | 82 virtual void SetUp() OVERRIDE { |
82 // The initialization path that blocks on the initial policy fetch requires | 83 // The initialization path that blocks on the initial policy fetch requires |
83 // a signin Profile to use its URLRequestContext. | 84 // a signin Profile to use its URLRequestContext. |
84 profile_manager_.reset( | 85 profile_manager_.reset( |
85 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 86 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
86 ASSERT_TRUE(profile_manager_->SetUp()); | 87 ASSERT_TRUE(profile_manager_->SetUp()); |
87 profile_ = profile_manager_->CreateTestingProfile( | 88 profile_ = profile_manager_->CreateTestingProfile( |
88 chrome::kInitialProfile, UTF8ToUTF16("testing_profile"), 0); | 89 chrome::kInitialProfile, scoped_ptr<PrefServiceSyncable>(), |
| 90 UTF8ToUTF16("testing_profile"), 0); |
89 signin_profile_ = profile_manager_->CreateTestingProfile("signin_profile"); | 91 signin_profile_ = profile_manager_->CreateTestingProfile("signin_profile"); |
90 signin_profile_->set_incognito(true); | 92 signin_profile_->set_incognito(true); |
91 // Usually the signin Profile and the main Profile are separate, but since | 93 // Usually the signin Profile and the main Profile are separate, but since |
92 // the signin Profile is an OTR Profile then for this test it suffices to | 94 // the signin Profile is an OTR Profile then for this test it suffices to |
93 // attach it to the main Profile. | 95 // attach it to the main Profile. |
94 profile_->SetOffTheRecordProfile(signin_profile_); | 96 profile_->SetOffTheRecordProfile(signin_profile_); |
95 signin_profile_->SetOriginalProfile(profile_); | 97 signin_profile_->SetOriginalProfile(profile_); |
96 signin_profile_->CreateRequestContext(); | 98 signin_profile_->CreateRequestContext(); |
97 ASSERT_EQ(signin_profile_, chromeos::ProfileHelper::GetSigninProfile()); | 99 ASSERT_EQ(signin_profile_, chromeos::ProfileHelper::GetSigninProfile()); |
98 | 100 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 508 |
507 // The refresh scheduler takes care of the initial fetch for unmanaged users. | 509 // The refresh scheduler takes care of the initial fetch for unmanaged users. |
508 // It posts a delayed task with 0ms delay in this case, so spinning the loop | 510 // It posts a delayed task with 0ms delay in this case, so spinning the loop |
509 // issues the initial fetch. | 511 // issues the initial fetch. |
510 base::RunLoop loop; | 512 base::RunLoop loop; |
511 FetchPolicy( | 513 FetchPolicy( |
512 base::Bind(&base::RunLoop::RunUntilIdle, base::Unretained(&loop))); | 514 base::Bind(&base::RunLoop::RunUntilIdle, base::Unretained(&loop))); |
513 } | 515 } |
514 | 516 |
515 } // namespace policy | 517 } // namespace policy |
OLD | NEW |