OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 virtual void StartDeviceWipe() OVERRIDE {} | 130 virtual void StartDeviceWipe() OVERRIDE {} |
131 virtual void RequestLockScreen() OVERRIDE {} | 131 virtual void RequestLockScreen() OVERRIDE {} |
132 virtual void NotifyLockScreenShown() OVERRIDE {} | 132 virtual void NotifyLockScreenShown() OVERRIDE {} |
133 virtual void RequestUnlockScreen() OVERRIDE {} | 133 virtual void RequestUnlockScreen() OVERRIDE {} |
134 virtual void NotifyLockScreenDismissed() OVERRIDE {} | 134 virtual void NotifyLockScreenDismissed() OVERRIDE {} |
135 virtual void RetrieveDevicePolicy( | 135 virtual void RetrieveDevicePolicy( |
136 const RetrievePolicyCallback& callback) OVERRIDE { | 136 const RetrievePolicyCallback& callback) OVERRIDE { |
137 MessageLoop::current()->PostTask(FROM_HERE, | 137 MessageLoop::current()->PostTask(FROM_HERE, |
138 base::Bind(callback, device_policy_)); | 138 base::Bind(callback, device_policy_)); |
139 } | 139 } |
140 virtual void RetrieveUserPolicy( | 140 virtual void RetrievePolicyForUser( |
| 141 const std::string& username, |
141 const RetrievePolicyCallback& callback) OVERRIDE { | 142 const RetrievePolicyCallback& callback) OVERRIDE { |
142 MessageLoop::current()->PostTask(FROM_HERE, | 143 MessageLoop::current()->PostTask( |
143 base::Bind(callback, user_policy_)); | 144 FROM_HERE, base::Bind(callback, user_policies_[username])); |
144 } | 145 } |
145 virtual void RetrieveDeviceLocalAccountPolicy( | 146 virtual void RetrieveDeviceLocalAccountPolicy( |
146 const std::string& account_id, | 147 const std::string& account_id, |
147 const RetrievePolicyCallback& callback) OVERRIDE { | 148 const RetrievePolicyCallback& callback) OVERRIDE { |
148 MessageLoop::current()->PostTask( | 149 MessageLoop::current()->PostTask( |
149 FROM_HERE, | 150 FROM_HERE, |
150 base::Bind(callback, device_local_account_policy_[account_id])); | 151 base::Bind(callback, device_local_account_policy_[account_id])); |
151 } | 152 } |
152 virtual void StoreDevicePolicy(const std::string& policy_blob, | 153 virtual void StoreDevicePolicy(const std::string& policy_blob, |
153 const StorePolicyCallback& callback) OVERRIDE { | 154 const StorePolicyCallback& callback) OVERRIDE { |
154 device_policy_ = policy_blob; | 155 device_policy_ = policy_blob; |
155 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); | 156 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
156 } | 157 } |
157 virtual void StoreUserPolicy(const std::string& policy_blob, | 158 virtual void StorePolicyForUser( |
158 const StorePolicyCallback& callback) OVERRIDE { | 159 const std::string& username, |
159 user_policy_ = policy_blob; | 160 const std::string& policy_blob, |
| 161 const std::string& policy_key, |
| 162 const StorePolicyCallback& callback) OVERRIDE { |
| 163 user_policies_[username] = policy_blob; |
160 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); | 164 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
161 } | 165 } |
162 virtual void StoreDeviceLocalAccountPolicy( | 166 virtual void StoreDeviceLocalAccountPolicy( |
163 const std::string& account_id, | 167 const std::string& account_id, |
164 const std::string& policy_blob, | 168 const std::string& policy_blob, |
165 const StorePolicyCallback& callback) OVERRIDE { | 169 const StorePolicyCallback& callback) OVERRIDE { |
166 device_local_account_policy_[account_id] = policy_blob; | 170 device_local_account_policy_[account_id] = policy_blob; |
167 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); | 171 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); |
168 } | 172 } |
169 | 173 |
170 const std::string& device_policy() const { | 174 const std::string& device_policy() const { |
171 return device_policy_; | 175 return device_policy_; |
172 } | 176 } |
173 void set_device_policy(const std::string& policy_blob) { | 177 void set_device_policy(const std::string& policy_blob) { |
174 device_policy_ = policy_blob; | 178 device_policy_ = policy_blob; |
175 } | 179 } |
176 | 180 |
177 const std::string& user_policy() const { | 181 const std::string& user_policy(const std::string& username) const { |
178 return user_policy_; | 182 std::map<std::string, std::string>::const_iterator it = |
| 183 user_policies_.find(username); |
| 184 return it == user_policies_.end() ? EmptyString() : it->second; |
179 } | 185 } |
180 void set_user_policy(const std::string& policy_blob) { | 186 void set_user_policy(const std::string& username, |
181 user_policy_ = policy_blob; | 187 const std::string& policy_blob) { |
| 188 user_policies_[username] = policy_blob; |
182 } | 189 } |
183 | 190 |
184 const std::string& device_local_account_policy( | 191 const std::string& device_local_account_policy( |
185 const std::string& account_id) const { | 192 const std::string& account_id) const { |
186 std::map<std::string, std::string>::const_iterator entry = | 193 std::map<std::string, std::string>::const_iterator entry = |
187 device_local_account_policy_.find(account_id); | 194 device_local_account_policy_.find(account_id); |
188 return entry != device_local_account_policy_.end() ? entry->second | 195 return entry != device_local_account_policy_.end() ? entry->second |
189 : EmptyString(); | 196 : EmptyString(); |
190 } | 197 } |
191 void set_device_local_account_policy(const std::string& account_id, | 198 void set_device_local_account_policy(const std::string& account_id, |
192 const std::string& policy_blob) { | 199 const std::string& policy_blob) { |
193 device_local_account_policy_[account_id] = policy_blob; | 200 device_local_account_policy_[account_id] = policy_blob; |
194 } | 201 } |
195 | 202 |
196 private: | 203 private: |
197 std::string device_policy_; | 204 std::string device_policy_; |
198 std::string user_policy_; | 205 std::map<std::string, std::string> user_policies_; |
199 std::map<std::string, std::string> device_local_account_policy_; | 206 std::map<std::string, std::string> device_local_account_policy_; |
200 | 207 |
201 DISALLOW_COPY_AND_ASSIGN(FakeSessionManagerClient); | 208 DISALLOW_COPY_AND_ASSIGN(FakeSessionManagerClient); |
202 }; | 209 }; |
203 | 210 |
204 class FakeCryptohomeClient : public chromeos::CryptohomeClient { | 211 class FakeCryptohomeClient : public chromeos::CryptohomeClient { |
205 public: | 212 public: |
206 using chromeos::CryptohomeClient::AsyncMethodCallback; | 213 using chromeos::CryptohomeClient::AsyncMethodCallback; |
207 using chromeos::CryptohomeClient::AsyncCallStatusHandler; | 214 using chromeos::CryptohomeClient::AsyncCallStatusHandler; |
208 using chromeos::CryptohomeClient::AsyncCallStatusWithDataHandler; | 215 using chromeos::CryptohomeClient::AsyncCallStatusWithDataHandler; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 659 |
653 TabStripModel* tabs = browser->tab_strip_model(); | 660 TabStripModel* tabs = browser->tab_strip_model(); |
654 ASSERT_TRUE(tabs); | 661 ASSERT_TRUE(tabs); |
655 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); | 662 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); |
656 EXPECT_EQ(expected_tab_count, tabs->count()); | 663 EXPECT_EQ(expected_tab_count, tabs->count()); |
657 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) | 664 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) |
658 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); | 665 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); |
659 } | 666 } |
660 | 667 |
661 } // namespace policy | 668 } // namespace policy |
OLD | NEW |