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/exclusive_access_context.h" |
| 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
11 #include "components/content_settings/core/browser/host_content_settings_map.h" | 13 #include "components/content_settings/core/browser/host_content_settings_map.h" |
12 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
13 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/render_widget_host_view.h" | 16 #include "content/public/browser/render_widget_host_view.h" |
15 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
16 | 18 |
17 using content::RenderViewHost; | 19 using content::RenderViewHost; |
18 using content::WebContents; | 20 using content::WebContents; |
19 | 21 |
20 MouseLockController::MouseLockController(ExclusiveAccessManager* manager, | 22 MouseLockController::MouseLockController(ExclusiveAccessManager* manager) |
21 Browser* browser) | 23 : ExclusiveAccessControllerBase(manager), |
22 : ExclusiveAccessControllerBase(manager, browser), | |
23 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) { | 24 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) { |
24 } | 25 } |
25 | 26 |
26 MouseLockController::~MouseLockController() { | 27 MouseLockController::~MouseLockController() { |
27 } | 28 } |
28 | 29 |
29 bool MouseLockController::IsMouseLocked() const { | 30 bool MouseLockController::IsMouseLocked() const { |
30 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || | 31 return mouse_lock_state_ == MOUSELOCK_ACCEPTED || |
31 mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY; | 32 mouse_lock_state_ == MOUSELOCK_ACCEPTED_SILENTLY; |
32 } | 33 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ExclusiveAccessBubbleType bubble_type = | 130 ExclusiveAccessBubbleType bubble_type = |
130 exclusive_access_manager()->GetExclusiveAccessExitBubbleType(); | 131 exclusive_access_manager()->GetExclusiveAccessExitBubbleType(); |
131 bool mouse_lock = false; | 132 bool mouse_lock = false; |
132 exclusive_access_bubble::PermissionRequestedByType(bubble_type, nullptr, | 133 exclusive_access_bubble::PermissionRequestedByType(bubble_type, nullptr, |
133 &mouse_lock); | 134 &mouse_lock); |
134 DCHECK(!(mouse_lock && IsMouseLocked())); | 135 DCHECK(!(mouse_lock && IsMouseLocked())); |
135 | 136 |
136 if (mouse_lock && !IsMouseLocked()) { | 137 if (mouse_lock && !IsMouseLocked()) { |
137 DCHECK(IsMouseLockRequested()); | 138 DCHECK(IsMouseLockRequested()); |
138 | 139 |
139 HostContentSettingsMap* settings_map = | 140 HostContentSettingsMap* settings_map = exclusive_access_manager() |
140 profile()->GetHostContentSettingsMap(); | 141 ->context() |
| 142 ->GetProfile() |
| 143 ->GetHostContentSettingsMap(); |
141 | 144 |
142 GURL url = GetExclusiveAccessBubbleURL(); | 145 GURL url = GetExclusiveAccessBubbleURL(); |
143 ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url); | 146 ContentSettingsPattern pattern = ContentSettingsPattern::FromURL(url); |
144 | 147 |
145 // TODO(markusheintz): We should allow patterns for all possible URLs here. | 148 // TODO(markusheintz): We should allow patterns for all possible URLs here. |
146 // | 149 // |
147 // Do not store preference on file:// URLs, they don't have a clean | 150 // Do not store preference on file:// URLs, they don't have a clean |
148 // origin policy. | 151 // origin policy. |
149 // TODO(estark): Revisit this when crbug.com/455882 is fixed. | 152 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
150 if (!url.SchemeIsFile() && pattern.IsValid()) { | 153 if (!url.SchemeIsFile() && pattern.IsValid()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // decision stick for a particular origin. | 233 // decision stick for a particular origin. |
231 // TODO(estark): Revisit this when crbug.com/455882 is fixed. | 234 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
232 if (url.SchemeIsFile()) | 235 if (url.SchemeIsFile()) |
233 return CONTENT_SETTING_ASK; | 236 return CONTENT_SETTING_ASK; |
234 | 237 |
235 if (exclusive_access_manager() | 238 if (exclusive_access_manager() |
236 ->fullscreen_controller() | 239 ->fullscreen_controller() |
237 ->IsPrivilegedFullscreenForTab()) | 240 ->IsPrivilegedFullscreenForTab()) |
238 return CONTENT_SETTING_ALLOW; | 241 return CONTENT_SETTING_ALLOW; |
239 | 242 |
240 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); | 243 HostContentSettingsMap* settings_map = exclusive_access_manager() |
| 244 ->context() |
| 245 ->GetProfile() |
| 246 ->GetHostContentSettingsMap(); |
241 return settings_map->GetContentSetting( | 247 return settings_map->GetContentSetting( |
242 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 248 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
243 } | 249 } |
OLD | NEW |