OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h" | 9 #include "chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h" |
10 #include "components/content_settings/core/common/content_settings.h" | 10 #include "components/content_settings/core/common/content_settings.h" |
11 | 11 |
12 // This class implements mouselock behavior. | 12 // This class implements mouselock behavior. |
13 class MouseLockController : public ExclusiveAccessControllerBase { | 13 class MouseLockController : public ExclusiveAccessControllerBase { |
14 public: | 14 public: |
15 explicit MouseLockController(ExclusiveAccessManager* manager); | 15 explicit MouseLockController(ExclusiveAccessManager* manager); |
16 ~MouseLockController() override; | 16 ~MouseLockController() override; |
17 | 17 |
18 bool IsMouseLocked() const; | 18 bool IsMouseLocked() const; |
19 bool IsMouseLockSilentlyAccepted() const; | 19 bool IsMouseLockedSilently() const; |
20 bool IsMouseLockRequested() const; | |
21 | 20 |
22 void RequestToLockMouse(content::WebContents* web_contents, | 21 void RequestToLockMouse(content::WebContents* web_contents, |
23 bool user_gesture, | 22 bool user_gesture, |
24 bool last_unlocked_by_target); | 23 bool last_unlocked_by_target); |
25 | 24 |
26 // Override from ExclusiveAccessControllerBase | 25 // Override from ExclusiveAccessControllerBase |
27 bool HandleUserPressedEscape() override; | 26 bool HandleUserPressedEscape() override; |
28 | 27 |
29 void ExitExclusiveAccessToPreviousState() override; | 28 void ExitExclusiveAccessToPreviousState() override; |
30 bool OnAcceptExclusiveAccessPermission() override; | |
31 bool OnDenyExclusiveAccessPermission() override; | |
32 | 29 |
33 // Called by Browser::LostMouseLock. | 30 // Called by Browser::LostMouseLock. |
34 void LostMouseLock(); | 31 void LostMouseLock(); |
35 | 32 |
36 void UnlockMouse(); | 33 void UnlockMouse(); |
37 | 34 |
38 // If true, does not call into the WebContents to lock the mouse. Just assumes | 35 // If true, does not call into the WebContents to lock the mouse. Just assumes |
39 // that it works. This may be necessary when calling | 36 // that it works. This may be necessary when calling |
40 // Browser::RequestToLockMouse in tests, because the proper signal will not | 37 // Browser::RequestToLockMouse in tests, because the proper signal will not |
41 // have been passed to the RenderViewHost. | 38 // have been passed to the RenderViewHost. |
42 void set_fake_mouse_lock_for_test(bool value) { | 39 void set_fake_mouse_lock_for_test(bool value) { |
43 fake_mouse_lock_for_test_ = value; | 40 fake_mouse_lock_for_test_ = value; |
44 } | 41 } |
45 | 42 |
46 private: | 43 private: |
47 enum MouseLockState { | 44 enum MouseLockState { |
48 MOUSELOCK_NOT_REQUESTED, | 45 MOUSELOCK_UNLOCKED, |
49 // The page requests to lock the mouse and the user hasn't responded to the | 46 // Mouse has been locked. |
50 // request. | 47 MOUSELOCK_LOCKED, |
51 MOUSELOCK_REQUESTED, | 48 // Mouse has been locked silently, with no notification to user. |
52 // Mouse lock has been allowed by the user. | 49 MOUSELOCK_LOCKED_SILENTLY |
53 MOUSELOCK_ACCEPTED, | |
54 // Mouse lock has been silently accepted, no notification to user. | |
55 MOUSELOCK_ACCEPTED_SILENTLY | |
56 }; | 50 }; |
57 | 51 |
58 void NotifyMouseLockChange(); | 52 void NotifyMouseLockChange(); |
59 | 53 |
60 void ExitExclusiveAccessIfNecessary() override; | 54 void ExitExclusiveAccessIfNecessary() override; |
61 void NotifyTabExclusiveAccessLost() override; | 55 void NotifyTabExclusiveAccessLost() override; |
62 void RecordBubbleReshowsHistogram(int bubble_reshow_count) override; | 56 void RecordBubbleReshowsHistogram(int bubble_reshow_count) override; |
63 | 57 |
64 ContentSetting GetMouseLockSetting(const GURL& url) const; | |
65 | |
66 MouseLockState mouse_lock_state_; | 58 MouseLockState mouse_lock_state_; |
67 | 59 |
68 bool fake_mouse_lock_for_test_; | 60 bool fake_mouse_lock_for_test_; |
69 | 61 |
70 DISALLOW_COPY_AND_ASSIGN(MouseLockController); | 62 DISALLOW_COPY_AND_ASSIGN(MouseLockController); |
71 }; | 63 }; |
72 | 64 |
73 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_ | 65 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_ |
OLD | NEW |