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

Side by Side Diff: third_party/WebKit/Source/modules/keyboard_lock/NavigatorKeyboardLock.h

Issue 2805763004: [System-Keyboard-Lock] Forward navigator functions to RenderFrameHost (Closed)
Patch Set: Sync latest changes Created 3 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2017 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 NavigatorKeyboardLock_h
6 #define NavigatorKeyboardLock_h
7
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "core/frame/Navigator.h"
10 #include "platform/Supplementable.h"
11 #include "platform/heap/Handle.h"
12 #include "platform/heap/Member.h"
13 #include "platform/wtf/Forward.h"
14 #include "public/platform/modules/keyboard_lock/keyboard_lock.mojom-blink.h"
15
16 namespace blink {
17
18 class ScriptPromiseResolver;
19
20 // The supplement of Navigator to process navigator.requestKeyLock() and
21 // navigator.cancelKeyLock() web APIs. This class forwards both requests
22 // directly to the browser process through mojo.
23 class NavigatorKeyboardLock final
24 : public GarbageCollectedFinalized<NavigatorKeyboardLock>,
25 public Supplement<Navigator> {
26 USING_GARBAGE_COLLECTED_MIXIN(NavigatorKeyboardLock);
27
28 public:
29 // Requests to receive a set of key codes
30 // (https://w3c.github.io/uievents/#dom-keyboardevent-code) in string format.
31 // The Promise will be rejected if the user or browser do not allow the web
32 // page to use this API. Otherwise, web page should expect to receive the key
33 // presses once the Promise has been resolved. This API does best effort to
34 // deliver the key codes: due to the platform restrictions, some keys or key
35 // combinations may not be able to receive or intercept by the user agent.
36 // - Making two requests concurrently without waiting for one Promise to
37 // finish is disallowed, the second Promise will be rejected immediately.
38 // - Making a second request after the Promise of the first one has finished
39 // is allowed; the second request will overwrite the key codes reserved.
40 // - Passing in an empty keyCodes array will reserve all keys.
41 static ScriptPromise requestKeyLock(ScriptState*,
42 Navigator&,
43 const Vector<String>&);
44
45 // Removes all reserved keys. This function is also asynchronized, the web
46 // page may still receive reserved keys after this function has finished. Once
47 // the web page is closed, the user agent implicitly executes this API.
48 static void cancelKeyLock(Navigator&);
49
50 DECLARE_TRACE();
51
52 private:
53 explicit NavigatorKeyboardLock(Navigator&);
54 static const char* SupplementName();
55
56 static NavigatorKeyboardLock& From(Navigator&);
57
58 ScriptPromise requestKeyLock(ScriptState*, const Vector<String>&);
59 void cancelKeyLock();
60
61 // Ensures the |service_| is correctly initialized. In case of the |service_|
62 // cannot be initialized, this function returns false.
63 bool EnsureServiceConnected();
64
65 void LockRequestFinished(bool, const String&);
66
67 mojom::blink::KeyboardLockServicePtr service_;
68 Member<ScriptPromiseResolver> request_keylock_resolver_;
69 };
70
71 } // namespace blink
72
73 #endif // NavigatorKeyboardLock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698