| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/fullscreen/fullscreen_controller.h" | 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || | 163 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || |
| 164 mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY; | 164 mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY; |
| 165 } | 165 } |
| 166 | 166 |
| 167 void FullscreenController::RequestToLockMouse(WebContents* web_contents, | 167 void FullscreenController::RequestToLockMouse(WebContents* web_contents, |
| 168 bool user_gesture, | 168 bool user_gesture, |
| 169 bool last_unlocked_by_target) { | 169 bool last_unlocked_by_target) { |
| 170 DCHECK(!IsMouseLocked()); | 170 DCHECK(!IsMouseLocked()); |
| 171 NotifyMouseLockChange(); | 171 NotifyMouseLockChange(); |
| 172 | 172 |
| 173 // Check for command line switch disabling mouse lock when not tab fullscreen. | |
| 174 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 175 switches::kDisableNonFullscreenMouseLock) && | |
| 176 !IsFullscreenForTabOrPending(web_contents)) { | |
| 177 web_contents->GotResponseToLockMouseRequest(false); | |
| 178 return; | |
| 179 } | |
| 180 | |
| 181 // Must have a user gesture to prevent misbehaving sites from constantly | 173 // Must have a user gesture to prevent misbehaving sites from constantly |
| 182 // re-locking the mouse. Exceptions are when the page has unlocked | 174 // re-locking the mouse. Exceptions are when the page has unlocked |
| 183 // (i.e. not the user), or if we're in tab fullscreen (user gesture required | 175 // (i.e. not the user), or if we're in tab fullscreen (user gesture required |
| 184 // for that) | 176 // for that) |
| 185 if (!last_unlocked_by_target && !user_gesture && | 177 if (!last_unlocked_by_target && !user_gesture && |
| 186 !IsFullscreenForTabOrPending(web_contents)) { | 178 !IsFullscreenForTabOrPending(web_contents)) { |
| 187 web_contents->GotResponseToLockMouseRequest(false); | 179 web_contents->GotResponseToLockMouseRequest(false); |
| 188 return; | 180 return; |
| 189 } | 181 } |
| 190 SetMouseLockTab(TabContents::FromWebContents(web_contents)); | 182 SetMouseLockTab(TabContents::FromWebContents(web_contents)); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 585 |
| 594 ContentSetting | 586 ContentSetting |
| 595 FullscreenController::GetMouseLockSetting(const GURL& url) const { | 587 FullscreenController::GetMouseLockSetting(const GURL& url) const { |
| 596 if (url.SchemeIsFile()) | 588 if (url.SchemeIsFile()) |
| 597 return CONTENT_SETTING_ALLOW; | 589 return CONTENT_SETTING_ALLOW; |
| 598 | 590 |
| 599 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 591 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
| 600 return settings_map->GetContentSetting(url, url, | 592 return settings_map->GetContentSetting(url, url, |
| 601 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 593 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
| 602 } | 594 } |
| OLD | NEW |