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

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

Issue 16770002: Restart Chrome if per session flags have been specified on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 (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 "chromeos/dbus/session_manager_client.h" 5 #include "chromeos/dbus/session_manager_client.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 const std::string& account_name, 264 const std::string& account_name,
265 const std::string& policy_blob, 265 const std::string& policy_blob,
266 const StorePolicyCallback& callback) OVERRIDE { 266 const StorePolicyCallback& callback) OVERRIDE {
267 CallStorePolicyByUsername( 267 CallStorePolicyByUsername(
268 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy, 268 login_manager::kSessionManagerStoreDeviceLocalAccountPolicy,
269 account_name, 269 account_name,
270 policy_blob, 270 policy_blob,
271 callback); 271 callback);
272 } 272 }
273 273
274 virtual void SetFlagsForUser(const std::string& username,
275 const std::vector<std::string>& flags) OVERRIDE {
276 CallSetFlagsByUsername(login_manager::kSessionManagerSetFlagsForUser,
Mattias Nissler (ping if slow) 2013/06/12 14:53:03 You can just inline CallSetFlagsByUsername, the fu
pastarmovj 2013/06/12 16:19:33 Done.
277 username,
278 flags);
279 }
280
274 private: 281 private:
275 // Makes a method call to the session manager with no arguments and no 282 // Makes a method call to the session manager with no arguments and no
276 // response. 283 // response.
277 void SimpleMethodCallToSessionManager(const std::string& method_name) { 284 void SimpleMethodCallToSessionManager(const std::string& method_name) {
278 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, 285 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
279 method_name); 286 method_name);
280 session_manager_proxy_->CallMethod( 287 session_manager_proxy_->CallMethod(
281 &method_call, 288 &method_call,
282 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 289 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
283 dbus::ObjectProxy::EmptyResponseCallback()); 290 dbus::ObjectProxy::EmptyResponseCallback());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 session_manager_proxy_->CallMethod( 322 session_manager_proxy_->CallMethod(
316 &method_call, 323 &method_call,
317 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 324 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
318 base::Bind( 325 base::Bind(
319 &SessionManagerClientImpl::OnStorePolicy, 326 &SessionManagerClientImpl::OnStorePolicy,
320 weak_ptr_factory_.GetWeakPtr(), 327 weak_ptr_factory_.GetWeakPtr(),
321 method_name, 328 method_name,
322 callback)); 329 callback));
323 } 330 }
324 331
332 void CallSetFlagsByUsername(const std::string& method_name,
333 const std::string& username,
334 const std::vector<std::string>& flags) {
335 dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
336 method_name);
337 dbus::MessageWriter writer(&method_call);
338 writer.AppendString(username);
339 writer.AppendArrayOfStrings(flags);
340 session_manager_proxy_->CallMethod(
341 &method_call,
342 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
343 dbus::ObjectProxy::EmptyResponseCallback());
344 }
345
325 // Called when kSessionManagerRestartJob method is complete. 346 // Called when kSessionManagerRestartJob method is complete.
326 void OnRestartJob(dbus::Response* response) { 347 void OnRestartJob(dbus::Response* response) {
327 LOG_IF(ERROR, !response) 348 LOG_IF(ERROR, !response)
328 << "Failed to call " 349 << "Failed to call "
329 << login_manager::kSessionManagerRestartJob; 350 << login_manager::kSessionManagerRestartJob;
330 } 351 }
331 352
332 // Called when kSessionManagerStartSession method is complete. 353 // Called when kSessionManagerStartSession method is complete.
333 void OnStartSession(dbus::Response* response) { 354 void OnStartSession(dbus::Response* response) {
334 LOG_IF(ERROR, !response) 355 LOG_IF(ERROR, !response)
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 base::Bind(callback, true), 611 base::Bind(callback, true),
591 false); 612 false);
592 } 613 }
593 virtual void StoreDeviceLocalAccountPolicy( 614 virtual void StoreDeviceLocalAccountPolicy(
594 const std::string& account_name, 615 const std::string& account_name,
595 const std::string& policy_blob, 616 const std::string& policy_blob,
596 const StorePolicyCallback& callback) OVERRIDE { 617 const StorePolicyCallback& callback) OVERRIDE {
597 user_policies_[account_name] = policy_blob; 618 user_policies_[account_name] = policy_blob;
598 callback.Run(true); 619 callback.Run(true);
599 } 620 }
621 virtual void SetFlagsForUser(const std::string& username,
622 const std::vector<std::string>& flags) OVERRIDE {
623 }
600 624
601 static void StoreFileInBackground(const base::FilePath& path, 625 static void StoreFileInBackground(const base::FilePath& path,
602 const std::string& data) { 626 const std::string& data) {
603 const int size = static_cast<int>(data.size()); 627 const int size = static_cast<int>(data.size());
604 if (!file_util::CreateDirectory(path.DirName()) || 628 if (!file_util::CreateDirectory(path.DirName()) ||
605 file_util::WriteFile(path, data.data(), size) != size) { 629 file_util::WriteFile(path, data.data(), size) != size) {
606 LOG(WARNING) << "Failed to write policy key to " << path.value(); 630 LOG(WARNING) << "Failed to write policy key to " << path.value();
607 } 631 }
608 } 632 }
609 633
(...skipping 14 matching lines...) Expand all
624 SessionManagerClient* SessionManagerClient::Create( 648 SessionManagerClient* SessionManagerClient::Create(
625 DBusClientImplementationType type, 649 DBusClientImplementationType type,
626 dbus::Bus* bus) { 650 dbus::Bus* bus) {
627 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 651 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
628 return new SessionManagerClientImpl(bus); 652 return new SessionManagerClientImpl(bus);
629 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 653 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
630 return new SessionManagerClientStubImpl(); 654 return new SessionManagerClientStubImpl();
631 } 655 }
632 656
633 } // namespace chromeos 657 } // namespace chromeos
OLDNEW
« chromeos/dbus/session_manager_client.h ('K') | « chromeos/dbus/session_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698