OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
grt (UTC plus 2)
2016/05/18 15:41:20
nit: no "(c)" in new header (http://www.chromium.o
ananta
2016/05/19 01:57:12
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 #ifndef BASE_WIN_OSK_DISPLAY_MANAGER_H_ | |
grt (UTC plus 2)
2016/05/18 15:41:20
nit: blank line before this
ananta
2016/05/19 01:57:12
Done.
| |
5 #define BASE_WIN_OSK_DISPLAY_MANAGER_H_ | |
6 | |
7 #include "base/base_export.h" | |
8 #include "base/memory/singleton.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "base/observer_list.h" | |
11 | |
12 namespace base { | |
13 namespace win { | |
14 | |
15 // Implemented by classes who wish to get notified about the on screen keyboard | |
16 // becoming visible/hidden. | |
17 class BASE_EXPORT OnScreenKeyboardObserver { | |
18 public: | |
19 virtual void OnKeyboardVisible(const RECT& keyboard_rect) {} | |
sky
2016/05/18 19:54:51
RECT->gfx::Rect for these too. Also, you should ma
ananta
2016/05/19 01:57:12
Done.
| |
20 virtual void OnKeyboardHidden(const RECT& keyboard_rect) {} | |
21 }; | |
22 | |
23 // This class provides functionality to detect when the on screen keyboard | |
24 // is displayed and move the main window up if it is obscured by the keyboard. | |
25 class BASE_EXPORT OnScreenKeyboardDetector { | |
sky
2016/05/18 19:54:51
Is there a reason you need this in base? I would b
ananta
2016/05/19 01:57:12
Done.
| |
26 public: | |
27 OnScreenKeyboardDetector(); | |
28 ~OnScreenKeyboardDetector(); | |
29 | |
30 // Runs a task which detects if the on screen keyboard was displayed. | |
grt (UTC plus 2)
2016/05/18 15:41:20
nit: "Schedules a delayed task that will..." since
ananta
2016/05/19 01:57:12
Done.
| |
31 void DetectKeyboard(HWND main_window); | |
32 | |
33 // Dismisses the on screen keyboard. | |
34 bool DismissKeyboard(); | |
35 | |
36 // Add/Remove keyboard observers. | |
37 // Please note that this class does not track the |observer| destruction. It | |
38 // is upto the classes which set up these observers to remove them when they | |
39 // are destroyed. | |
40 void AddObserver(OnScreenKeyboardObserver* observer); | |
41 void RemoveObserver(OnScreenKeyboardObserver* observer); | |
42 | |
43 private: | |
44 // Executes as a task and detects if the on screen keyboard is displayed. | |
45 // The |check_for_activation| parameter controls whether the function detects | |
46 // whether the keyboard wad displayed or hidden. | |
47 void CheckOSKState(bool check_for_activation); | |
grt (UTC plus 2)
2016/05/18 15:41:20
does this detection run periodically for the entir
ananta
2016/05/19 01:57:12
Done.
| |
48 | |
49 // Notifies observers that the keyboard was displayed. | |
grt (UTC plus 2)
2016/05/18 15:41:20
please also note that a recurring task is started
ananta
2016/05/19 01:57:12
Done.
| |
50 void HandleKeyboardVisible(); | |
51 | |
52 // Notifies observers that the keyboard was hidden. | |
53 void HandleKeyboardHidden(); | |
54 | |
55 // Removes all observers from the list. | |
56 void ClearObservers(); | |
57 | |
58 // The main window which displays the on screen keyboard. | |
59 HWND main_window_; | |
grt (UTC plus 2)
2016/05/18 15:41:20
= nullptr;
ananta
2016/05/19 01:57:12
This is initialized in the ctor.
grt (UTC plus 2)
2016/05/19 03:51:03
with the new C++-11 style, this sort of initializa
ananta
2016/05/19 19:33:37
Done.
| |
60 | |
61 // Tracks if the keyboard was displayed. | |
62 bool osk_visible_notification_received_; | |
grt (UTC plus 2)
2016/05/18 15:41:20
= false;
ananta
2016/05/19 01:57:12
ditto
ananta
2016/05/19 19:33:37
Done.
| |
63 | |
64 // The keyboard dimensions. | |
65 RECT osk_rect_; | |
66 | |
67 base::ObserverList<OnScreenKeyboardObserver, true> observers_; | |
68 | |
69 // Should be the last member in the class. Helps ensure that tasks spawned | |
70 // by this class instance are canceled when it is destroyed. | |
71 base::WeakPtrFactory<OnScreenKeyboardDetector> keyboard_detector_factory_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(OnScreenKeyboardDetector); | |
74 }; | |
75 | |
76 // This class provides functionality to display the on screen keyboard on | |
77 // Windows 8+. It ensures that the content on the page is scrolled if the | |
grt (UTC plus 2)
2016/05/18 15:41:20
how does this do the scrolling? is that the respon
ananta
2016/05/19 01:57:12
Thanks it does not. I started out with a impl whic
| |
78 // keyboard obscures it. | |
79 class BASE_EXPORT OnScreenKeyboardDisplayManager { | |
80 public: | |
81 static OnScreenKeyboardDisplayManager* GetInstance(); | |
82 | |
83 // Functions to display and dismiss the keyboard. | |
84 // The |observer| parameters allow the caller to optionally set up | |
85 // notification observers for detecting when the keyboard is displayed | |
86 // hidden etc. | |
87 bool DisplayVirtualKeyboard(OnScreenKeyboardObserver* observer); | |
88 bool DismissVirtualKeyboard(OnScreenKeyboardObserver* observer); | |
89 | |
90 private: | |
91 OnScreenKeyboardDisplayManager() {} | |
grt (UTC plus 2)
2016/05/18 15:41:20
nit: = default;
ananta
2016/05/19 01:57:12
Please clarify what you mean here.
grt (UTC plus 2)
2016/05/19 03:51:02
Gangam style! uh, i mean C++-11 style:
OnScreenK
sky
2016/05/19 16:05:25
I'm curious here as well as it has come up in othe
grt (UTC plus 2)
2016/05/19 16:53:17
My reason for suggesting it is so that there's jus
ananta
2016/05/19 19:33:37
I left it as is as clang needs the destructor to b
| |
92 | |
93 friend struct base::StaticMemorySingletonTraits< | |
94 OnScreenKeyboardDisplayManager>; | |
95 | |
96 std::unique_ptr<OnScreenKeyboardDetector> keyboard_detector_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(OnScreenKeyboardDisplayManager); | |
99 }; | |
100 | |
101 } // namespace win | |
102 } // namespace base | |
103 | |
104 #endif // BASE_WIN_OSK_DISPLAY_MANAGER_H_ | |
OLD | NEW |