| 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" |
| 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
| 12 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 12 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 14 #include "components/content_settings/core/browser/host_content_settings_map.h" | 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/render_widget_host.h" | 17 #include "content/public/browser/render_widget_host.h" |
| 18 #include "content/public/browser/render_widget_host_view.h" | 18 #include "content/public/browser/render_widget_host_view.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 | 20 |
| 21 using content::RenderViewHost; | 21 using content::RenderViewHost; |
| 22 using content::WebContents; | 22 using content::WebContents; |
| 23 | 23 |
| 24 MouseLockController::MouseLockController(ExclusiveAccessManager* manager) | 24 MouseLockController::MouseLockController(ExclusiveAccessManager* manager) |
| 25 : ExclusiveAccessControllerBase(manager), | 25 : ExclusiveAccessControllerBase(manager), |
| 26 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) { | 26 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED), |
| 27 } | 27 fake_mouse_lock_for_test_(false) {} |
| 28 | 28 |
| 29 MouseLockController::~MouseLockController() { | 29 MouseLockController::~MouseLockController() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool MouseLockController::IsMouseLocked() const { | 32 bool MouseLockController::IsMouseLocked() const { |
| 33 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || | 33 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || |
| 34 mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY; | 34 mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY; |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool MouseLockController::IsMouseLockSilentlyAccepted() const { | 37 bool MouseLockController::IsMouseLockSilentlyAccepted() const { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 case CONTENT_SETTING_ALLOW: | 63 case CONTENT_SETTING_ALLOW: |
| 64 // If bubble already displaying buttons we must not lock the mouse yet, | 64 // If bubble already displaying buttons we must not lock the mouse yet, |
| 65 // or it would prevent pressing those buttons. Instead, merge the request. | 65 // or it would prevent pressing those buttons. Instead, merge the request. |
| 66 if (!exclusive_access_manager() | 66 if (!exclusive_access_manager() |
| 67 ->fullscreen_controller() | 67 ->fullscreen_controller() |
| 68 ->IsPrivilegedFullscreenForTab() && | 68 ->IsPrivilegedFullscreenForTab() && |
| 69 exclusive_access_bubble::ShowButtonsForType(bubble_type)) { | 69 exclusive_access_bubble::ShowButtonsForType(bubble_type)) { |
| 70 mouse_lock_state_ = MOUSELOCK_REQUESTED; | 70 mouse_lock_state_ = MOUSELOCK_REQUESTED; |
| 71 } else { | 71 } else { |
| 72 // Lock mouse. | 72 // Lock mouse. |
| 73 if (web_contents->GotResponseToLockMouseRequest(true)) { | 73 if (fake_mouse_lock_for_test_ || |
| 74 web_contents->GotResponseToLockMouseRequest(true)) { |
| 74 if (last_unlocked_by_target) { | 75 if (last_unlocked_by_target) { |
| 75 mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY; | 76 mouse_lock_state_ = MOUSELOCK_ACCEPTED_SILENTLY; |
| 76 } else { | 77 } else { |
| 77 mouse_lock_state_ = MOUSELOCK_ACCEPTED; | 78 mouse_lock_state_ = MOUSELOCK_ACCEPTED; |
| 78 } | 79 } |
| 79 } else { | 80 } else { |
| 80 SetTabWithExclusiveAccess(nullptr); | 81 SetTabWithExclusiveAccess(nullptr); |
| 81 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 82 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
| 82 } | 83 } |
| 83 } | 84 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 HostContentSettingsMapFactory::GetForProfile( | 251 HostContentSettingsMapFactory::GetForProfile( |
| 251 exclusive_access_manager()->context()->GetProfile()); | 252 exclusive_access_manager()->context()->GetProfile()); |
| 252 ContentSetting setting = settings_map->GetContentSetting( | 253 ContentSetting setting = settings_map->GetContentSetting( |
| 253 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 254 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
| 254 | 255 |
| 255 if (simplified_ui && setting == CONTENT_SETTING_ASK) | 256 if (simplified_ui && setting == CONTENT_SETTING_ASK) |
| 256 return CONTENT_SETTING_ALLOW; | 257 return CONTENT_SETTING_ALLOW; |
| 257 | 258 |
| 258 return setting; | 259 return setting; |
| 259 } | 260 } |
| OLD | NEW |