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

Side by Side Diff: chromeos/dbus/fake_session_manager_client.cc

Issue 14761012: Updated SessionManagerClient to use the multi-profile user policy calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added TODO Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chromeos/dbus/fake_session_manager_client.h" 5 #include "chromeos/dbus/fake_session_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void FakeSessionManagerClient::NotifyLockScreenDismissed() { 68 void FakeSessionManagerClient::NotifyLockScreenDismissed() {
69 notify_lock_screen_dismissed_call_count_++; 69 notify_lock_screen_dismissed_call_count_++;
70 } 70 }
71 71
72 void FakeSessionManagerClient::RetrieveDevicePolicy( 72 void FakeSessionManagerClient::RetrieveDevicePolicy(
73 const RetrievePolicyCallback& callback) { 73 const RetrievePolicyCallback& callback) {
74 MessageLoop::current()->PostTask(FROM_HERE, 74 MessageLoop::current()->PostTask(FROM_HERE,
75 base::Bind(callback, device_policy_)); 75 base::Bind(callback, device_policy_));
76 } 76 }
77 77
78 void FakeSessionManagerClient::RetrieveUserPolicy( 78 void FakeSessionManagerClient::RetrievePolicyForUser(
79 const std::string& username,
79 const RetrievePolicyCallback& callback) { 80 const RetrievePolicyCallback& callback) {
80 MessageLoop::current()->PostTask(FROM_HERE, 81 MessageLoop::current()->PostTask(
81 base::Bind(callback, user_policy_)); 82 FROM_HERE, base::Bind(callback, user_policies_[username]));
82 } 83 }
83 84
84 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy( 85 void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy(
85 const std::string& account_id, 86 const std::string& account_id,
86 const RetrievePolicyCallback& callback) { 87 const RetrievePolicyCallback& callback) {
87 MessageLoop::current()->PostTask( 88 MessageLoop::current()->PostTask(
88 FROM_HERE, 89 FROM_HERE,
89 base::Bind(callback, device_local_account_policy_[account_id])); 90 base::Bind(callback, device_local_account_policy_[account_id]));
90 } 91 }
91 92
92 void FakeSessionManagerClient::StoreDevicePolicy( 93 void FakeSessionManagerClient::StoreDevicePolicy(
93 const std::string& policy_blob, 94 const std::string& policy_blob,
94 const StorePolicyCallback& callback) { 95 const StorePolicyCallback& callback) {
95 device_policy_ = policy_blob; 96 device_policy_ = policy_blob;
96 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); 97 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
97 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true)); 98 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(true));
98 } 99 }
99 100
100 void FakeSessionManagerClient::StoreUserPolicy( 101 void FakeSessionManagerClient::StorePolicyForUser(
102 const std::string& username,
101 const std::string& policy_blob, 103 const std::string& policy_blob,
104 const std::string& policy_key,
102 const StorePolicyCallback& callback) { 105 const StorePolicyCallback& callback) {
103 user_policy_ = policy_blob; 106 user_policies_[username] = policy_blob;
104 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); 107 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
105 } 108 }
106 109
107 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy( 110 void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy(
108 const std::string& account_id, 111 const std::string& account_id,
109 const std::string& policy_blob, 112 const std::string& policy_blob,
110 const StorePolicyCallback& callback) { 113 const StorePolicyCallback& callback) {
111 device_local_account_policy_[account_id] = policy_blob; 114 device_local_account_policy_[account_id] = policy_blob;
112 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); 115 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true));
113 } 116 }
114 117
115 const std::string& FakeSessionManagerClient::device_policy() const { 118 const std::string& FakeSessionManagerClient::device_policy() const {
116 return device_policy_; 119 return device_policy_;
117 } 120 }
118 121
119 void FakeSessionManagerClient::set_device_policy( 122 void FakeSessionManagerClient::set_device_policy(
120 const std::string& policy_blob) { 123 const std::string& policy_blob) {
121 device_policy_ = policy_blob; 124 device_policy_ = policy_blob;
122 } 125 }
123 126
124 const std::string& FakeSessionManagerClient::user_policy() const { 127 const std::string& FakeSessionManagerClient::user_policy(
125 return user_policy_; 128 const std::string& username) const {
129 std::map<std::string, std::string>::const_iterator it =
130 user_policies_.find(username);
131 return it == user_policies_.end() ? EmptyString() : it->second;
126 } 132 }
127 133
128 void FakeSessionManagerClient::set_user_policy(const std::string& policy_blob) { 134 void FakeSessionManagerClient::set_user_policy(const std::string& username,
129 user_policy_ = policy_blob; 135 const std::string& policy_blob) {
136 user_policies_[username] = policy_blob;
130 } 137 }
131 138
132 const std::string& FakeSessionManagerClient::device_local_account_policy( 139 const std::string& FakeSessionManagerClient::device_local_account_policy(
133 const std::string& account_id) const { 140 const std::string& account_id) const {
134 std::map<std::string, std::string>::const_iterator entry = 141 std::map<std::string, std::string>::const_iterator entry =
135 device_local_account_policy_.find(account_id); 142 device_local_account_policy_.find(account_id);
136 return entry != device_local_account_policy_.end() ? entry->second 143 return entry != device_local_account_policy_.end() ? entry->second
137 : EmptyString(); 144 : EmptyString();
138 } 145 }
139 146
140 void FakeSessionManagerClient::set_device_local_account_policy( 147 void FakeSessionManagerClient::set_device_local_account_policy(
141 const std::string& account_id, 148 const std::string& account_id,
142 const std::string& policy_blob) { 149 const std::string& policy_blob) {
143 device_local_account_policy_[account_id] = policy_blob; 150 device_local_account_policy_[account_id] = policy_blob;
144 } 151 }
145 152
146 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) { 153 void FakeSessionManagerClient::OnPropertyChangeComplete(bool success) {
147 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success)); 154 FOR_EACH_OBSERVER(Observer, observers_, PropertyChangeComplete(success));
148 } 155 }
149 156
150 } // namespace chromeos 157 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_session_manager_client.h ('k') | chromeos/dbus/mock_session_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698