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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_
8 #include "chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h"
9 #include "components/content_settings/core/common/content_settings.h"
11 // This class implements mouselock behavior.
12 class MouseLockController
: public ExclusiveAccessControllerBase
{
14 explicit MouseLockController(ExclusiveAccessManager
* manager
);
15 ~MouseLockController() override
;
17 bool IsMouseLocked() const;
18 bool IsMouseLockSilentlyAccepted() const;
19 bool IsMouseLockRequested() const;
21 void RequestToLockMouse(content::WebContents
* web_contents
,
23 bool last_unlocked_by_target
);
25 // Override from ExclusiveAccessControllerBase
26 bool HandleUserPressedEscape() override
;
28 void ExitExclusiveAccessToPreviousState() override
;
29 bool OnAcceptExclusiveAccessPermission() override
;
30 bool OnDenyExclusiveAccessPermission() override
;
32 // Called by Browser::LostMouseLock.
39 MOUSELOCK_NOT_REQUESTED
,
40 // The page requests to lock the mouse and the user hasn't responded to the
43 // Mouse lock has been allowed by the user.
45 // Mouse lock has been silently accepted, no notification to user.
46 MOUSELOCK_ACCEPTED_SILENTLY
49 void NotifyMouseLockChange();
51 void ExitExclusiveAccessIfNecessary() override
;
52 void NotifyTabExclusiveAccessLost() override
;
54 ContentSetting
GetMouseLockSetting(const GURL
& url
) const;
56 MouseLockState mouse_lock_state_
;
58 DISALLOW_COPY_AND_ASSIGN(MouseLockController
);
61 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_MOUSE_LOCK_CONTROLLER_H_