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 #include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h" | 5 #include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 NotifyMouseLockChange(); | 109 NotifyMouseLockChange(); |
110 } else { | 110 } else { |
111 UnlockMouse(); | 111 UnlockMouse(); |
112 } | 112 } |
113 SetTabWithExclusiveAccess(nullptr); | 113 SetTabWithExclusiveAccess(nullptr); |
114 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 114 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
115 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 115 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
| 119 const char* MouseLockController::HistogramSuffix() { |
| 120 return "MouseLock"; |
| 121 } |
| 122 |
119 bool MouseLockController::HandleUserPressedEscape() { | 123 bool MouseLockController::HandleUserPressedEscape() { |
120 if (IsMouseLocked() || IsMouseLockRequested()) { | 124 if (IsMouseLocked() || IsMouseLockRequested()) { |
121 ExitExclusiveAccessIfNecessary(); | 125 ExitExclusiveAccessIfNecessary(); |
122 return true; | 126 return true; |
123 } | 127 } |
124 | 128 |
125 return false; | 129 return false; |
126 } | 130 } |
127 | 131 |
128 void MouseLockController::ExitExclusiveAccessToPreviousState() { | 132 void MouseLockController::ExitExclusiveAccessToPreviousState() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 tab->GotResponseToLockMouseRequest(false); | 185 tab->GotResponseToLockMouseRequest(false); |
182 SetTabWithExclusiveAccess(nullptr); | 186 SetTabWithExclusiveAccess(nullptr); |
183 NotifyMouseLockChange(); | 187 NotifyMouseLockChange(); |
184 return true; | 188 return true; |
185 } | 189 } |
186 | 190 |
187 return false; | 191 return false; |
188 } | 192 } |
189 | 193 |
190 void MouseLockController::LostMouseLock() { | 194 void MouseLockController::LostMouseLock() { |
| 195 Exiting(); |
191 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 196 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
192 SetTabWithExclusiveAccess(nullptr); | 197 SetTabWithExclusiveAccess(nullptr); |
193 NotifyMouseLockChange(); | 198 NotifyMouseLockChange(); |
194 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 199 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
195 } | 200 } |
196 | 201 |
197 bool MouseLockController::IsMouseLockRequested() const { | 202 bool MouseLockController::IsMouseLockRequested() const { |
198 return mouse_lock_state_ == MOUSELOCK_REQUESTED; | 203 return mouse_lock_state_ == MOUSELOCK_REQUESTED; |
199 } | 204 } |
200 | 205 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return CONTENT_SETTING_ALLOW; | 255 return CONTENT_SETTING_ALLOW; |
251 | 256 |
252 HostContentSettingsMap* settings_map = | 257 HostContentSettingsMap* settings_map = |
253 HostContentSettingsMapFactory::GetForProfile( | 258 HostContentSettingsMapFactory::GetForProfile( |
254 exclusive_access_manager()->context()->GetProfile()); | 259 exclusive_access_manager()->context()->GetProfile()); |
255 ContentSetting setting = settings_map->GetContentSetting( | 260 ContentSetting setting = settings_map->GetContentSetting( |
256 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 261 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
257 | 262 |
258 return setting; | 263 return setting; |
259 } | 264 } |
OLD | NEW |