Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / screenlock_private / screenlock_private_api.h
blob7e284b0950d36944c344471174691b3ef9740811
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
8 #include <string>
10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "components/proximity_auth/screenlock_bridge.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_event_histogram_value.h"
15 namespace extensions {
17 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction {
18 public:
19 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
20 SCREENLOCKPRIVATE_GETLOCKED)
21 ScreenlockPrivateGetLockedFunction();
22 bool RunAsync() override;
24 private:
25 ~ScreenlockPrivateGetLockedFunction() override;
26 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction);
29 class ScreenlockPrivateSetLockedFunction : public ChromeAsyncExtensionFunction {
30 public:
31 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
32 SCREENLOCKPRIVATE_SETLOCKED)
33 ScreenlockPrivateSetLockedFunction();
34 bool RunAsync() override;
36 private:
37 ~ScreenlockPrivateSetLockedFunction() override;
38 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction);
41 class ScreenlockPrivateAcceptAuthAttemptFunction
42 : public ChromeSyncExtensionFunction {
43 public:
44 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt",
45 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT)
46 ScreenlockPrivateAcceptAuthAttemptFunction();
47 bool RunSync() override;
49 private:
50 ~ScreenlockPrivateAcceptAuthAttemptFunction() override;
51 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction);
54 class ScreenlockPrivateEventRouter
55 : public BrowserContextKeyedAPI,
56 public proximity_auth::ScreenlockBridge::Observer {
57 public:
58 explicit ScreenlockPrivateEventRouter(content::BrowserContext* context);
59 ~ScreenlockPrivateEventRouter() override;
61 bool OnAuthAttempted(
62 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
63 const std::string& value);
65 // BrowserContextKeyedAPI
66 static BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>*
67 GetFactoryInstance();
68 void Shutdown() override;
70 // proximity_auth::ScreenlockBridge::Observer
71 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
72 screen_type) override;
73 void OnScreenDidUnlock(
74 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
75 override;
76 void OnFocusedUserChanged(const std::string& user_id) override;
78 private:
79 friend class BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>;
81 // BrowserContextKeyedAPI
82 static const char* service_name() {
83 return "ScreenlockPrivateEventRouter";
85 static const bool kServiceIsNULLWhileTesting = true;
86 static const bool kServiceRedirectedInIncognito = true;
88 void DispatchEvent(events::HistogramValue histogram_value,
89 const std::string& event_name,
90 base::Value* arg);
92 content::BrowserContext* browser_context_;
93 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter);
96 } // namespace extensions
98 #endif // CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_