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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (mouse_lock && !IsMouseLocked()) { | 136 if (mouse_lock && !IsMouseLocked()) { |
137 DCHECK(IsMouseLockRequested()); | 137 DCHECK(IsMouseLockRequested()); |
138 | 138 |
139 HostContentSettingsMap* settings_map = | 139 HostContentSettingsMap* settings_map = |
140 profile()->GetHostContentSettingsMap(); | 140 profile()->GetHostContentSettingsMap(); |
141 | 141 |
142 GURL url = GetExclusiveAccessBubbleURL(); | 142 GURL url = GetExclusiveAccessBubbleURL(); |
143 ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url); | 143 ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url); |
144 | 144 |
145 // TODO(markusheintz): We should allow patterns for all possible URLs here. | 145 // TODO(markusheintz): We should allow patterns for all possible URLs here. |
146 if (pattern.IsValid()) { | 146 // |
| 147 // Do not store preference on file:// URLs, they don't have a clean |
| 148 // origin policy. |
| 149 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
| 150 if (!url.SchemeIsFile() && pattern.IsValid()) { |
147 settings_map->SetContentSetting(pattern, | 151 settings_map->SetContentSetting(pattern, |
148 ContentSettingsPattern::Wildcard(), | 152 ContentSettingsPattern::Wildcard(), |
149 CONTENT_SETTINGS_TYPE_MOUSELOCK, | 153 CONTENT_SETTINGS_TYPE_MOUSELOCK, |
150 std::string(), CONTENT_SETTING_ALLOW); | 154 std::string(), CONTENT_SETTING_ALLOW); |
151 } | 155 } |
152 | 156 |
153 WebContents* tab = exclusive_access_tab(); | 157 WebContents* tab = exclusive_access_tab(); |
154 if (tab && tab->GotResponseToLockMouseRequest(true)) { | 158 if (tab && tab->GotResponseToLockMouseRequest(true)) { |
155 mouse_lock_state_ = MOUSELOCK_ACCEPTED; | 159 mouse_lock_state_ = MOUSELOCK_ACCEPTED; |
156 } else { | 160 } else { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 RenderViewHost* const rvh = exclusive_access_tab()->GetRenderViewHost(); | 219 RenderViewHost* const rvh = exclusive_access_tab()->GetRenderViewHost(); |
216 if (rvh) | 220 if (rvh) |
217 mouse_lock_view = rvh->GetView(); | 221 mouse_lock_view = rvh->GetView(); |
218 } | 222 } |
219 | 223 |
220 if (mouse_lock_view) | 224 if (mouse_lock_view) |
221 mouse_lock_view->UnlockMouse(); | 225 mouse_lock_view->UnlockMouse(); |
222 } | 226 } |
223 | 227 |
224 ContentSetting MouseLockController::GetMouseLockSetting(const GURL& url) const { | 228 ContentSetting MouseLockController::GetMouseLockSetting(const GURL& url) const { |
| 229 // Always ask on file:// URLs, since we can't meaningfully make the |
| 230 // decision stick for a particular origin. |
| 231 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
| 232 if (url.SchemeIsFile()) |
| 233 return CONTENT_SETTING_ASK; |
| 234 |
225 if (exclusive_access_manager() | 235 if (exclusive_access_manager() |
226 ->fullscreen_controller() | 236 ->fullscreen_controller() |
227 ->IsPrivilegedFullscreenForTab() || | 237 ->IsPrivilegedFullscreenForTab()) |
228 url.SchemeIsFile()) | |
229 return CONTENT_SETTING_ALLOW; | 238 return CONTENT_SETTING_ALLOW; |
230 | 239 |
231 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); | 240 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); |
232 return settings_map->GetContentSetting( | 241 return settings_map->GetContentSetting( |
233 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 242 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
234 } | 243 } |
OLD | NEW |