Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / dbus / screen_lock_service_provider.cc
blob761c01838f6cfdb32b2120ca957e01741fd151ef
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.
5 #include "chrome/browser/chromeos/dbus/screen_lock_service_provider.h"
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"
15 namespace chromeos {
17 ScreenLockServiceProvider::ScreenLockServiceProvider()
18 : weak_ptr_factory_(this) {
21 ScreenLockServiceProvider::~ScreenLockServiceProvider() {}
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()));
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;
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));
52 } // namespace chromeos