Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: chrome/browser/ui/exclusive_access/mouse_lock_controller.cc

Issue 877413004: Refactor away the Browser* dependency in exclusive_access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove Browser* dependency from ExclusiveAccess* in Cocoa. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 ->exclusive_access_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 if (pattern.IsValid()) { 149 if (pattern.IsValid()) {
147 settings_map->SetContentSetting(pattern, 150 settings_map->SetContentSetting(pattern,
148 ContentSettingsPattern::Wildcard(), 151 ContentSettingsPattern::Wildcard(),
149 CONTENT_SETTINGS_TYPE_MOUSELOCK, 152 CONTENT_SETTINGS_TYPE_MOUSELOCK,
150 std::string(), CONTENT_SETTING_ALLOW); 153 std::string(), CONTENT_SETTING_ALLOW);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 mouse_lock_view->UnlockMouse(); 224 mouse_lock_view->UnlockMouse();
222 } 225 }
223 226
224 ContentSetting MouseLockController::GetMouseLockSetting(const GURL& url) const { 227 ContentSetting MouseLockController::GetMouseLockSetting(const GURL& url) const {
225 if (exclusive_access_manager() 228 if (exclusive_access_manager()
226 ->fullscreen_controller() 229 ->fullscreen_controller()
227 ->IsPrivilegedFullscreenForTab() || 230 ->IsPrivilegedFullscreenForTab() ||
228 url.SchemeIsFile()) 231 url.SchemeIsFile())
229 return CONTENT_SETTING_ALLOW; 232 return CONTENT_SETTING_ALLOW;
230 233
231 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); 234 HostContentSettingsMap* settings_map = exclusive_access_manager()
235 ->exclusive_access_context()
236 ->GetProfile()
237 ->GetHostContentSettingsMap();
232 return settings_map->GetContentSetting( 238 return settings_map->GetContentSetting(
233 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); 239 url, url, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string());
234 } 240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698