• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/chromeos/dbus/screen_lock_service_provider.h"
6 
7 #include "ash/shell.h"
8 #include "ash/wm/lock_state_controller.h"
9 #include "base/bind.h"
10 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
11 #include "dbus/bus.h"
12 #include "dbus/message.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h"
14 
15 namespace chromeos {
16 
ScreenLockServiceProvider()17 ScreenLockServiceProvider::ScreenLockServiceProvider()
18     : weak_ptr_factory_(this) {
19 }
20 
~ScreenLockServiceProvider()21 ScreenLockServiceProvider::~ScreenLockServiceProvider() {}
22 
Start(scoped_refptr<dbus::ExportedObject> exported_object)23 void ScreenLockServiceProvider::Start(
24     scoped_refptr<dbus::ExportedObject> exported_object) {
25   exported_object->ExportMethod(
26       kLibCrosServiceInterface,
27       kLockScreen,
28       base::Bind(&ScreenLockServiceProvider::LockScreen,
29                  weak_ptr_factory_.GetWeakPtr()),
30       base::Bind(&ScreenLockServiceProvider::OnExported,
31                  weak_ptr_factory_.GetWeakPtr()));
32 }
33 
OnExported(const std::string & interface_name,const std::string & method_name,bool success)34 void ScreenLockServiceProvider::OnExported(const std::string& interface_name,
35                                            const std::string& method_name,
36                                            bool success) {
37   if (!success) {
38     LOG(ERROR) << "Failed to export " << interface_name << "."
39                << method_name;
40   }
41 }
42 
LockScreen(dbus::MethodCall * method_call,dbus::ExportedObject::ResponseSender response_sender)43 void ScreenLockServiceProvider::LockScreen(
44     dbus::MethodCall* method_call,
45     dbus::ExportedObject::ResponseSender response_sender) {
46   // Please add any additional logic to ScreenLocker::HandleLockScreenRequest()
47   // instead of placing it here.
48   ScreenLocker::HandleLockScreenRequest();
49   response_sender.Run(dbus::Response::FromMethodCall(method_call));
50 }
51 
52 }  // namespace chromeos
53