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

Side by Side Diff: content/browser/renderer_host/input/input_device_change_observer.cc

Issue 2690323002: Make Interaction Media Features MQ dynamic on Windows. (Closed)
Patch Set: Nit fix 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 #include "content/browser/renderer_host/input/input_device_change_observer.h"
6 #include "base/trace_event/trace_event.h"
7 #include "content/public/common/web_preferences.h"
8
9 #if defined(OS_WIN)
10 #include "ui/events/devices/input_device_observer_win.h"
11 #endif
12
13 namespace content {
14
15 InputDeviceChangeObserver::InputDeviceChangeObserver(RenderViewHost* rvh) {
16 render_view_host_ = rvh;
17 #if defined(OS_WIN)
18 ui::InputDeviceObserverWin::GetInstance()->AddObserver(this);
19 #endif
20 }
21
22 InputDeviceChangeObserver::~InputDeviceChangeObserver() {
23 #if defined(OS_WIN)
24 ui::InputDeviceObserverWin::GetInstance()->RemoveObserver(this);
25 #endif
26 render_view_host_ = nullptr;
27 }
28
29 void InputDeviceChangeObserver::OnTouchscreenDeviceConfigurationChanged() {
30 NotifyRenderViewHost();
31 }
32
33 void InputDeviceChangeObserver::OnKeyboardDeviceConfigurationChanged() {
34 NotifyRenderViewHost();
35 }
36
37 void InputDeviceChangeObserver::OnMouseDeviceConfigurationChanged() {
38 NotifyRenderViewHost();
39 }
40
41 void InputDeviceChangeObserver::OnTouchpadDeviceConfigurationChanged() {
42 NotifyRenderViewHost();
43 }
44
45 void InputDeviceChangeObserver::NotifyRenderViewHost() {
46 WebPreferences prefs = render_view_host_->GetWebkitPreferences();
47 int available_pointer_types, available_hover_types;
48 std::tie(available_pointer_types, available_hover_types) =
49 ui::GetAvailablePointerAndHoverTypes();
50 bool input_device_changed =
51 prefs.available_pointer_types != available_pointer_types ||
52 prefs.available_hover_types != available_hover_types;
53
54 if (input_device_changed) {
55 TRACE_EVENT0("input", "InputDeviceChangeObserver::NotifyRendererViewHost");
56 render_view_host_->OnWebkitPreferencesChanged();
57 }
58 }
59
60 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698