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 "base/metrics/histogram_macros.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 12 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
12 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 13 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 14 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
14 #include "components/content_settings/core/browser/host_content_settings_map.h" | 15 #include "components/content_settings/core/browser/host_content_settings_map.h" |
15 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
16 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/render_widget_host.h" | 18 #include "content/public/browser/render_widget_host.h" |
18 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 | 21 |
21 using content::RenderViewHost; | 22 using content::RenderViewHost; |
22 using content::WebContents; | 23 using content::WebContents; |
23 | 24 |
| 25 namespace { |
| 26 |
| 27 const char kBubbleReshowsHistogramName[] = |
| 28 "ExclusiveAccess.BubbleReshowsPerSession.MouseLock"; |
| 29 |
| 30 } // namespace |
| 31 |
24 MouseLockController::MouseLockController(ExclusiveAccessManager* manager) | 32 MouseLockController::MouseLockController(ExclusiveAccessManager* manager) |
25 : ExclusiveAccessControllerBase(manager), | 33 : ExclusiveAccessControllerBase(manager), |
26 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED), | 34 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED), |
27 fake_mouse_lock_for_test_(false) {} | 35 fake_mouse_lock_for_test_(false) {} |
28 | 36 |
29 MouseLockController::~MouseLockController() { | 37 MouseLockController::~MouseLockController() { |
30 } | 38 } |
31 | 39 |
32 bool MouseLockController::IsMouseLocked() const { | 40 bool MouseLockController::IsMouseLocked() const { |
33 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || | 41 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 NotifyMouseLockChange(); | 117 NotifyMouseLockChange(); |
110 } else { | 118 } else { |
111 UnlockMouse(); | 119 UnlockMouse(); |
112 } | 120 } |
113 SetTabWithExclusiveAccess(nullptr); | 121 SetTabWithExclusiveAccess(nullptr); |
114 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 122 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
115 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 123 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
116 } | 124 } |
117 } | 125 } |
118 | 126 |
| 127 void MouseLockController::RecordBubbleReshowsHistogram( |
| 128 int bubble_reshow_count) { |
| 129 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); |
| 130 } |
| 131 |
119 bool MouseLockController::HandleUserPressedEscape() { | 132 bool MouseLockController::HandleUserPressedEscape() { |
120 if (IsMouseLocked() || IsMouseLockRequested()) { | 133 if (IsMouseLocked() || IsMouseLockRequested()) { |
121 ExitExclusiveAccessIfNecessary(); | 134 ExitExclusiveAccessIfNecessary(); |
122 return true; | 135 return true; |
123 } | 136 } |
124 | 137 |
125 return false; | 138 return false; |
126 } | 139 } |
127 | 140 |
128 void MouseLockController::ExitExclusiveAccessToPreviousState() { | 141 void MouseLockController::ExitExclusiveAccessToPreviousState() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 tab->GotResponseToLockMouseRequest(false); | 194 tab->GotResponseToLockMouseRequest(false); |
182 SetTabWithExclusiveAccess(nullptr); | 195 SetTabWithExclusiveAccess(nullptr); |
183 NotifyMouseLockChange(); | 196 NotifyMouseLockChange(); |
184 return true; | 197 return true; |
185 } | 198 } |
186 | 199 |
187 return false; | 200 return false; |
188 } | 201 } |
189 | 202 |
190 void MouseLockController::LostMouseLock() { | 203 void MouseLockController::LostMouseLock() { |
| 204 RecordExitingUMA(); |
191 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 205 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
192 SetTabWithExclusiveAccess(nullptr); | 206 SetTabWithExclusiveAccess(nullptr); |
193 NotifyMouseLockChange(); | 207 NotifyMouseLockChange(); |
194 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 208 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
195 } | 209 } |
196 | 210 |
197 bool MouseLockController::IsMouseLockRequested() const { | 211 bool MouseLockController::IsMouseLockRequested() const { |
198 return mouse_lock_state_ == MOUSELOCK_REQUESTED; | 212 return mouse_lock_state_ == MOUSELOCK_REQUESTED; |
199 } | 213 } |
200 | 214 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return CONTENT_SETTING_ALLOW; | 264 return CONTENT_SETTING_ALLOW; |
251 | 265 |
252 HostContentSettingsMap* settings_map = | 266 HostContentSettingsMap* settings_map = |
253 HostContentSettingsMapFactory::GetForProfile( | 267 HostContentSettingsMapFactory::GetForProfile( |
254 exclusive_access_manager()->context()->GetProfile()); | 268 exclusive_access_manager()->context()->GetProfile()); |
255 ContentSetting setting = settings_map->GetContentSetting( | 269 ContentSetting setting = settings_map->GetContentSetting( |
256 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 270 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
257 | 271 |
258 return setting; | 272 return setting; |
259 } | 273 } |
OLD | NEW |