Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / dbus / screen_lock_service_provider.h
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 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_SCREEN_LOCK_SERVICE_PROVIDER_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_SCREEN_LOCK_SERVICE_PROVIDER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h"
15 #include "dbus/exported_object.h"
16
17 namespace dbus {
18 class MethodCall;
19 }
20
21 namespace chromeos {
22
23 // This class exports a "LockScreen" D-Bus methods that the session manager
24 // calls to instruct Chrome to lock the screen.
25 class ScreenLockServiceProvider
26     : public CrosDBusService::ServiceProviderInterface {
27  public:
28   ScreenLockServiceProvider();
29   virtual ~ScreenLockServiceProvider();
30
31   // CrosDBusService::ServiceProviderInterface overrides:
32   virtual void Start(
33       scoped_refptr<dbus::ExportedObject> exported_object) OVERRIDE;
34
35  private:
36   // Called from ExportedObject when a handler is exported as a D-Bus
37   // method or failed to be exported.
38   void OnExported(const std::string& interface_name,
39                   const std::string& method_name,
40                   bool success);
41
42   // Called on UI thread in response to D-Bus requests.
43   void LockScreen(dbus::MethodCall* method_call,
44                   dbus::ExportedObject::ResponseSender response_sender);
45
46   // Keep this last so that all weak pointers will be invalidated at the
47   // beginning of destruction.
48   base::WeakPtrFactory<ScreenLockServiceProvider> weak_ptr_factory_;
49
50   DISALLOW_COPY_AND_ASSIGN(ScreenLockServiceProvider);
51 };
52
53 }  // namespace chromeos
54
55 #endif  // CHROME_BROWSER_CHROMEOS_DBUS_SCREEN_LOCK_SERVICE_PROVIDER_H_