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

Side by Side Diff: content/browser/keyboard_lock/keyboard_lock_service_impl.cc

Issue 2879033002: Keyboard Lock Host implementation
Patch Set: Remove useless files Created 3 years, 4 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/keyboard_lock/keyboard_lock_service_impl.h" 5 #include "content/browser/keyboard_lock/keyboard_lock_service_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h"
11 #include "base/location.h"
12 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "components/keyboard_lock/keyboard_lock_host.h"
15 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/render_frame_host.h" 16 #include "content/public/browser/render_frame_host.h"
12 17
13 namespace content { 18 namespace content {
14 19
15 KeyboardLockServiceImpl::KeyboardLockServiceImpl() = default; 20 KeyboardLockServiceImpl::KeyboardLockServiceImpl(
21 RenderFrameHost* render_frame_host)
22 : web_contents_(WebContents::FromRenderFrameHost(render_frame_host)) {
23 DCHECK(web_contents_);
24 }
16 25
17 KeyboardLockServiceImpl::~KeyboardLockServiceImpl() = default; 26 KeyboardLockServiceImpl::~KeyboardLockServiceImpl() = default;
18 27
19 // static 28 // static
20 void KeyboardLockServiceImpl::CreateMojoService( 29 void KeyboardLockServiceImpl::CreateMojoService(
30 RenderFrameHost* render_frame_host,
21 blink::mojom::KeyboardLockServiceRequest request) { 31 blink::mojom::KeyboardLockServiceRequest request) {
22 mojo::MakeStrongBinding( 32 mojo::MakeStrongBinding(
23 base::MakeUnique<KeyboardLockServiceImpl>(), 33 base::MakeUnique<KeyboardLockServiceImpl>(render_frame_host),
24 std::move(request)); 34 std::move(request));
25 } 35 }
26 36
27 void KeyboardLockServiceImpl::RequestKeyboardLock( 37 void KeyboardLockServiceImpl::RequestKeyboardLock(
28 const std::vector<std::string>& key_codes, 38 const std::vector<std::string>& key_codes,
29 RequestKeyboardLockCallback callback) { 39 RequestKeyboardLockCallback callback) {
30 // TODO(zijiehe): Implementation required. 40 keyboard_lock::KeyboardLockHost* host =
31 std::move(callback).Run(blink::mojom::KeyboardLockRequestResult::SUCCESS); 41 keyboard_lock::KeyboardLockHost::Find(web_contents_);
42 if (!host) {
43 // This should not happen in production.
44 std::move(callback).Run(blink::mojom::KeyboardLockRequestResult::SUCCESS);
45 return;
46 }
47
48 host->SetReservedKeyCodes(web_contents_, key_codes,
49 base::Bind([](RequestKeyboardLockCallback&& callback, bool result) {
50 std::move(callback).Run(
51 blink::mojom::KeyboardLockRequestResult::SUCCESS);
52 },
53 base::Passed(std::move(callback))));
32 } 54 }
33 55
34 void KeyboardLockServiceImpl::CancelKeyboardLock() { 56 void KeyboardLockServiceImpl::CancelKeyboardLock() {
35 // TODO(zijiehe): Implementation required. 57 keyboard_lock::KeyboardLockHost* host =
58 keyboard_lock::KeyboardLockHost::Find(web_contents_);
59 if (!host) {
60 // This should not happen in production.
61 return;
62 }
63 host->ClearReservedKeys(web_contents_, base::Callback<void(bool)>());
36 } 64 }
37 65
38 } // namespace content 66 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/keyboard_lock/keyboard_lock_service_impl.h ('k') | content/public/browser/web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698