Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_test_helper.cc

Issue 2890433002: Revert "Abandon user sign in when policy is retrieved before session started." (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/settings/device_settings_test_helper.h" 5 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 10 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
11 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 11 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
12 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 12 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" 13 #include "chrome/browser/chromeos/profiles/profile_helper.h"
14 #include "chrome/browser/chromeos/settings/device_settings_service.h" 14 #include "chrome/browser/chromeos/settings/device_settings_service.h"
15 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "chromeos/cryptohome/cryptohome_parameters.h" 17 #include "chromeos/cryptohome/cryptohome_parameters.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 18 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "components/ownership/mock_owner_key_util.h" 19 #include "components/ownership/mock_owner_key_util.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 22
23 using RetrievePolicyResponseType =
24 chromeos::DeviceSettingsTestHelper::RetrievePolicyResponseType;
25
26 namespace chromeos { 23 namespace chromeos {
27 24
28 DeviceSettingsTestHelper::DeviceSettingsTestHelper() {} 25 DeviceSettingsTestHelper::DeviceSettingsTestHelper() {}
29 26
30 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {} 27 DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {}
31 28
32 void DeviceSettingsTestHelper::FlushStore() { 29 void DeviceSettingsTestHelper::FlushStore() {
33 std::vector<StorePolicyCallback> callbacks; 30 std::vector<StorePolicyCallback> callbacks;
34 callbacks.swap(device_policy_.store_callbacks_); 31 callbacks.swap(device_policy_.store_callbacks_);
35 for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin()); 32 for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin());
(...skipping 11 matching lines...) Expand all
47 cb->Run(device_local_account_state->second.store_result_); 44 cb->Run(device_local_account_state->second.store_result_);
48 } 45 }
49 } 46 }
50 } 47 }
51 48
52 void DeviceSettingsTestHelper::FlushRetrieve() { 49 void DeviceSettingsTestHelper::FlushRetrieve() {
53 std::vector<RetrievePolicyCallback> callbacks; 50 std::vector<RetrievePolicyCallback> callbacks;
54 callbacks.swap(device_policy_.retrieve_callbacks_); 51 callbacks.swap(device_policy_.retrieve_callbacks_);
55 for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin()); 52 for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin());
56 cb != callbacks.end(); ++cb) { 53 cb != callbacks.end(); ++cb) {
57 cb->Run(device_policy_.policy_blob_, RetrievePolicyResponseType::SUCCESS); 54 cb->Run(device_policy_.policy_blob_);
58 } 55 }
59 56
60 std::map<std::string, PolicyState>::iterator device_local_account_state; 57 std::map<std::string, PolicyState>::iterator device_local_account_state;
61 for (device_local_account_state = device_local_account_policy_.begin(); 58 for (device_local_account_state = device_local_account_policy_.begin();
62 device_local_account_state != device_local_account_policy_.end(); 59 device_local_account_state != device_local_account_policy_.end();
63 ++device_local_account_state) { 60 ++device_local_account_state) {
64 std::vector<RetrievePolicyCallback> callbacks; 61 std::vector<RetrievePolicyCallback> callbacks;
65 callbacks.swap(device_local_account_state->second.retrieve_callbacks_); 62 callbacks.swap(device_local_account_state->second.retrieve_callbacks_);
66 for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin()); 63 for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin());
67 cb != callbacks.end(); ++cb) { 64 cb != callbacks.end(); ++cb) {
68 cb->Run(device_local_account_state->second.policy_blob_, 65 cb->Run(device_local_account_state->second.policy_blob_);
69 RetrievePolicyResponseType::SUCCESS);
70 } 66 }
71 } 67 }
72 } 68 }
73 69
74 void DeviceSettingsTestHelper::Flush() { 70 void DeviceSettingsTestHelper::Flush() {
75 do { 71 do {
76 content::RunAllBlockingPoolTasksUntilIdle(); 72 content::RunAllBlockingPoolTasksUntilIdle();
77 FlushStore(); 73 FlushStore();
78 content::RunAllBlockingPoolTasksUntilIdle(); 74 content::RunAllBlockingPoolTasksUntilIdle();
79 FlushRetrieve(); 75 FlushRetrieve();
(...skipping 14 matching lines...) Expand all
94 } 90 }
95 91
96 return false; 92 return false;
97 } 93 }
98 94
99 void DeviceSettingsTestHelper::RetrieveDevicePolicy( 95 void DeviceSettingsTestHelper::RetrieveDevicePolicy(
100 const RetrievePolicyCallback& callback) { 96 const RetrievePolicyCallback& callback) {
101 device_policy_.retrieve_callbacks_.push_back(callback); 97 device_policy_.retrieve_callbacks_.push_back(callback);
102 } 98 }
103 99
104 RetrievePolicyResponseType 100 std::string DeviceSettingsTestHelper::BlockingRetrieveDevicePolicy() {
105 DeviceSettingsTestHelper::BlockingRetrieveDevicePolicy( 101 return device_policy_.policy_blob_;
106 std::string* policy_out) {
107 *policy_out = device_policy_.policy_blob_;
108 return RetrievePolicyResponseType::SUCCESS;
109 } 102 }
110 103
111 void DeviceSettingsTestHelper::RetrieveDeviceLocalAccountPolicy( 104 void DeviceSettingsTestHelper::RetrieveDeviceLocalAccountPolicy(
112 const std::string& account_id, 105 const std::string& account_id,
113 const RetrievePolicyCallback& callback) { 106 const RetrievePolicyCallback& callback) {
114 device_local_account_policy_[account_id].retrieve_callbacks_.push_back( 107 device_local_account_policy_[account_id].retrieve_callbacks_.push_back(
115 callback); 108 callback);
116 } 109 }
117 110
118 RetrievePolicyResponseType 111 std::string DeviceSettingsTestHelper::BlockingRetrieveDeviceLocalAccountPolicy(
119 DeviceSettingsTestHelper::BlockingRetrieveDeviceLocalAccountPolicy( 112 const std::string& account_id) {
120 const std::string& account_id, 113 return "";
121 std::string* policy_out) {
122 *policy_out = "";
123 return RetrievePolicyResponseType::SUCCESS;
124 } 114 }
125 115
126 void DeviceSettingsTestHelper::StoreDevicePolicy( 116 void DeviceSettingsTestHelper::StoreDevicePolicy(
127 const std::string& policy_blob, 117 const std::string& policy_blob,
128 const StorePolicyCallback& callback) { 118 const StorePolicyCallback& callback) {
129 device_policy_.policy_blob_ = policy_blob; 119 device_policy_.policy_blob_ = policy_blob;
130 device_policy_.store_callbacks_.push_back(callback); 120 device_policy_.store_callbacks_.push_back(callback);
131 } 121 }
132 122
133 void DeviceSettingsTestHelper::StoreDeviceLocalAccountPolicy( 123 void DeviceSettingsTestHelper::StoreDeviceLocalAccountPolicy(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const_cast<user_manager::User*>(user)); 210 const_cast<user_manager::User*>(user));
221 } 211 }
222 OwnerSettingsServiceChromeOS* service = 212 OwnerSettingsServiceChromeOS* service =
223 OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile_.get()); 213 OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile_.get());
224 CHECK(service); 214 CHECK(service);
225 if (tpm_is_ready) 215 if (tpm_is_ready)
226 service->OnTPMTokenReady(true /* token is enabled */); 216 service->OnTPMTokenReady(true /* token is enabled */);
227 } 217 }
228 218
229 } // namespace chromeos 219 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698