forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[System-Keyboard-Lock] Forward navigator functions to RenderFrameHost
This change forwards navigator.requestKeyLock() and navigator.cancelKeyLock() functions to the RenderFrameHostImpl. System-Keyboard-Lock is a feature to detect the key presses which usually cannot be received by the browser, and send them to the web page. It contains various components to achieve the goal. This change is one of them, which receives JavaScript (or Web Platform API in the design doc) function calls and forwards them into RenderFrameHost. For detail, please refer to the design doc at, https://docs.google.com/document/d/1T9gJHYdA1VGZ6QHQeOu0hOacWWWJ7yNEt1VDbLju4bs/edit#heading=h.cgwemqs2j4ta W3C Working Draft: https://garykac.github.io/system-keyboard-lock/ Intent to implement: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/9pauQUAvrcw/lfbG7eunCAAJ BUG=680809 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2805763004 Cr-Commit-Position: refs/heads/master@{#468158}
- Loading branch information
zijiehe
authored and
Commit bot
committed
Apr 28, 2017
1 parent
56fc9d6
commit 6016778
Showing
25 changed files
with
444 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
content/browser/keyboard_lock/keyboard_lock_service_impl.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "content/browser/keyboard_lock/keyboard_lock_service_impl.h" | ||
|
||
#include <memory> | ||
#include <utility> | ||
|
||
#include "base/memory/ptr_util.h" | ||
#include "content/public/browser/render_frame_host.h" | ||
|
||
namespace content { | ||
|
||
KeyboardLockServiceImpl::KeyboardLockServiceImpl() = default; | ||
|
||
KeyboardLockServiceImpl::~KeyboardLockServiceImpl() = default; | ||
|
||
// static | ||
void KeyboardLockServiceImpl::CreateMojoService( | ||
blink::mojom::KeyboardLockServiceRequest request) { | ||
mojo::MakeStrongBinding( | ||
base::MakeUnique<KeyboardLockServiceImpl>(), | ||
std::move(request)); | ||
} | ||
|
||
void KeyboardLockServiceImpl::RequestKeyLock( | ||
const std::vector<std::string>& key_codes, | ||
const RequestKeyLockCallback& callback) { | ||
// TODO(zijiehe): Implementation required. | ||
callback.Run(true, std::string()); | ||
} | ||
|
||
void KeyboardLockServiceImpl::CancelKeyLock() { | ||
// TODO(zijiehe): Implementation required. | ||
} | ||
|
||
} // namespace content |
29 changes: 29 additions & 0 deletions
29
content/browser/keyboard_lock/keyboard_lock_service_impl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "content/common/content_export.h" | ||
#include "mojo/public/cpp/bindings/strong_binding.h" | ||
#include "third_party/WebKit/public/platform/modules/keyboard_lock/keyboard_lock.mojom.h" | ||
|
||
namespace content { | ||
|
||
class CONTENT_EXPORT KeyboardLockServiceImpl | ||
: public NON_EXPORTED_BASE(blink::mojom::KeyboardLockService) { | ||
public: | ||
KeyboardLockServiceImpl(); | ||
~KeyboardLockServiceImpl() override; | ||
|
||
static void CreateMojoService( | ||
blink::mojom::KeyboardLockServiceRequest request); | ||
|
||
// blink::mojom::KeyboardLockService implementations. | ||
void RequestKeyLock(const std::vector<std::string>& key_codes, | ||
const RequestKeyLockCallback& callback) override; | ||
void CancelKeyLock() override; | ||
}; | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idlharness.https-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This is a testharness.js-based test. | ||
FAIL Navigator interface: operation requestKeyLock(sequence) assert_throws: calling operation with this = null didn't throw TypeError function "function () { | ||
fn.apply(obj, args); | ||
}" did not throw | ||
PASS Navigator interface: operation cancelKeyLock() | ||
PASS Navigator must be primary interface of navigator | ||
PASS Stringification of navigator | ||
PASS Navigator interface: navigator must inherit property "requestKeyLock" with the proper type (0) | ||
PASS Navigator interface: calling requestKeyLock(sequence) on navigator with too few arguments must throw TypeError | ||
PASS Navigator interface: navigator must inherit property "cancelKeyLock" with the proper type (1) | ||
Harness: the test ran to completion. | ||
|
41 changes: 41 additions & 0 deletions
41
third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/idlharness.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Keyboard Lock IDL tests</title> | ||
<link rel="help" href="https://github.com/w3c/keyboard-lock"/> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/WebIDLParser.js"></script> | ||
<script src="/resources/idlharness.js"></script> | ||
</head> | ||
<body> | ||
<pre id="untested_idl" style="display: none"> | ||
interface Navigator { | ||
}; | ||
</pre> | ||
<!-- | ||
The reason of the failure of requestKeyLock test looks like a code defect in | ||
idlharness.js. media-capabilities/idlharness.html is also impacted by this | ||
issue. See https://codereview.chromium.org/2805763004/#ps620001, which | ||
includes a potential fix. | ||
TODO(zijiehe): Submit the fix. | ||
--> | ||
<pre id="idl" style="display: none"> | ||
partial interface Navigator { | ||
[SecureContext] Promise<void> requestKeyLock(optional sequence<DOMString> keyCodes = []); | ||
[SecureContext] void cancelKeyLock(); | ||
}; | ||
</pre> | ||
<script> | ||
var idl_array = new IdlArray(); | ||
idl_array.add_untested_idls( | ||
document.getElementById("untested_idl").textContent); | ||
idl_array.add_idls(document.getElementById("idl").textContent); | ||
idl_array.add_objects({ | ||
Navigator: ["navigator"] | ||
}); | ||
idl_array.test(); | ||
</script> | ||
<div id="log"></div> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
third_party/WebKit/LayoutTests/external/wpt/keyboard-lock/navigator-cancelKeyLock.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
test(() => { | ||
assert_equals(navigator.cancelKeyLock(), | ||
undefined); | ||
}, 'Keyboard Lock cancelKeyLock'); | ||
|
||
</script> |
15 changes: 15 additions & 0 deletions
15
...ests/external/wpt/keyboard-lock/navigator-requestKeyLock-two-parallel-requests.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test((t) => { | ||
const p1 = navigator.requestKeyLock(['a', 'b']); | ||
const p2 = navigator.requestKeyLock(['c', 'd']); | ||
return promise_rejects(t, null, p2, | ||
'requestKeyLock() should only be ' + | ||
'executed if another request has finished.'); | ||
}, 'Keyboard Lock requestKeyLock twice in parallel'); | ||
|
||
</script> |
14 changes: 14 additions & 0 deletions
14
...ts/external/wpt/keyboard-lock/navigator-requestKeyLock-two-sequential-requests.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(() => { | ||
return navigator.requestKeyLock(['a', 'b']) | ||
.then(() => { | ||
return navigator.requestKeyLock(['c', 'd']); | ||
}); | ||
}, 'Keyboard Lock requestKeyLock twice sequentially'); | ||
|
||
</script> |
13 changes: 13 additions & 0 deletions
13
...d_party/WebKit/LayoutTests/external/wpt/keyboard-lock/navigator-requestKeyLock.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(() => { | ||
const p = navigator.requestKeyLock(['a', 'b']); | ||
assert_true(p instanceof Promise); | ||
return p; | ||
}, 'Keyboard Lock requestKeyLock'); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2017 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//third_party/WebKit/Source/modules/modules.gni") | ||
|
||
blink_modules_sources("keyboard_lock") { | ||
sources = [ | ||
"NavigatorKeyboardLock.cpp", | ||
"NavigatorKeyboardLock.h", | ||
] | ||
} |
Oops, something went wrong.