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

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: Resolve review comments Created 3 years, 8 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://www.w3.org/TR/uievents/#interface-keyboardevent) in string format.
foolip 2017/04/18 05:10:57 /TR/ links are usually stale snapshots, link to ht
Hzj_jie 2017/04/19 00:45:55 Done.
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.
foolip 2017/04/18 05:10:57 https://garykac.github.io/system-keyboard-lock/#re
Hzj_jie 2017/04/19 00:45:55 Yes, I have updated the idl file to include all th
40 // - Passing in an empty keyCodes array will reserve all keys.
41 static ScriptPromise requestKeyLock(ScriptState*,
42 Navigator&,
43 const Vector<String>&);
44
45 // Equals to execute navigator.requestKeyLock([]);
46 static ScriptPromise requestKeyLock(ScriptState*, Navigator&);
foolip 2017/04/18 05:10:57 You should be able to remove this if the IDL has [
Hzj_jie 2017/04/19 00:45:55 Done.
47
48 // Removes all reserved keys. This function is also asynchronized, the web
49 // page may still receive reserved keys after this function has finished. Once
50 // the web page is closed, the user agent implictly executes this API.
51 static void cancelKeyLock(Navigator&);
52
53 DECLARE_TRACE();
54
55 private:
56 explicit NavigatorKeyboardLock(Navigator&);
57 static const char* SupplementName();
58
59 static NavigatorKeyboardLock& From(Navigator&);
60
61 ScriptPromise requestKeyLock(ScriptState*, const Vector<String>&);
62 void cancelKeyLock();
63
64 // Ensures the |service_| is correctly initialized. In case of the |service_|
65 // cannot be initialized, this function returns false, and returns error
66 // message through the |error_message| if it's not a nullptr.
67 bool EnsureServiceConnected(String* error_message);
68
69 void LockRequestFinished(bool, const String&);
70
71 mojom::blink::KeyboardLockServicePtr service_;
72 Member<ScriptPromiseResolver> request_keylock_resolver_;
73 };
74
75 } // namespace blink
76
77 #endif // NavigatorKeyboardLock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698