OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_controller.h" | 5 #include "chrome/browser/ui/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 "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 bool FullscreenController::IsFullscreenForTab() const { | 38 bool FullscreenController::IsFullscreenForTab() const { |
39 return fullscreened_tab_ != NULL; | 39 return fullscreened_tab_ != NULL; |
40 } | 40 } |
41 | 41 |
42 bool FullscreenController::IsFullscreenForTab(const WebContents* tab) const { | 42 bool FullscreenController::IsFullscreenForTab(const WebContents* tab) const { |
43 const TabContentsWrapper* wrapper = | 43 const TabContentsWrapper* wrapper = |
44 TabContentsWrapper::GetCurrentWrapperForContents(tab); | 44 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
45 if (!wrapper || (wrapper != fullscreened_tab_)) | 45 if (!wrapper || (wrapper != fullscreened_tab_)) |
46 return false; | 46 return false; |
47 DCHECK(tab == browser_->GetSelectedTabContents()); | 47 DCHECK(tab == browser_->GetSelectedWebContents()); |
48 DCHECK(window_->IsFullscreen()); | 48 DCHECK(window_->IsFullscreen()); |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 void FullscreenController::RequestToLockMouse(WebContents* tab) { | 52 void FullscreenController::RequestToLockMouse(WebContents* tab) { |
53 // Mouse Lock is only permitted when browser is in tab fullscreen. | 53 // Mouse Lock is only permitted when browser is in tab fullscreen. |
54 if (!IsFullscreenForTab(tab)) { | 54 if (!IsFullscreenForTab(tab)) { |
55 tab->GotResponseToLockMouseRequest(false); | 55 tab->GotResponseToLockMouseRequest(false); |
56 return; | 56 return; |
57 } | 57 } |
(...skipping 20 matching lines...) Expand all Loading... |
78 mouse_lock_state_ = MOUSELOCK_REQUESTED; | 78 mouse_lock_state_ = MOUSELOCK_REQUESTED; |
79 break; | 79 break; |
80 default: | 80 default: |
81 NOTREACHED(); | 81 NOTREACHED(); |
82 } | 82 } |
83 UpdateFullscreenExitBubbleContent(); | 83 UpdateFullscreenExitBubbleContent(); |
84 } | 84 } |
85 | 85 |
86 void FullscreenController::ToggleFullscreenModeForTab(WebContents* tab, | 86 void FullscreenController::ToggleFullscreenModeForTab(WebContents* tab, |
87 bool enter_fullscreen) { | 87 bool enter_fullscreen) { |
88 if (tab != browser_->GetSelectedTabContents()) | 88 if (tab != browser_->GetSelectedWebContents()) |
89 return; | 89 return; |
90 | 90 |
91 bool in_browser_or_tab_fullscreen_mode; | 91 bool in_browser_or_tab_fullscreen_mode; |
92 #if defined(OS_MACOSX) | 92 #if defined(OS_MACOSX) |
93 in_browser_or_tab_fullscreen_mode = window_->InPresentationMode(); | 93 in_browser_or_tab_fullscreen_mode = window_->InPresentationMode(); |
94 #else | 94 #else |
95 in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); | 95 in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); |
96 #endif | 96 #endif |
97 | 97 |
98 if (enter_fullscreen) { | 98 if (enter_fullscreen) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 #if defined(OS_MACOSX) | 137 #if defined(OS_MACOSX) |
138 void FullscreenController::TogglePresentationMode(bool for_tab) { | 138 void FullscreenController::TogglePresentationMode(bool for_tab) { |
139 bool entering_fullscreen = !window_->InPresentationMode(); | 139 bool entering_fullscreen = !window_->InPresentationMode(); |
140 GURL url; | 140 GURL url; |
141 if (for_tab) { | 141 if (for_tab) { |
142 url = browser_->GetSelectedTabContents()->GetURL(); | 142 url = browser_->GetSelectedWebContents()->GetURL(); |
143 tab_fullscreen_accepted_ = entering_fullscreen && | 143 tab_fullscreen_accepted_ = entering_fullscreen && |
144 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 144 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; |
145 } | 145 } |
146 if (entering_fullscreen) | 146 if (entering_fullscreen) |
147 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); | 147 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); |
148 else | 148 else |
149 window_->ExitPresentationMode(); | 149 window_->ExitPresentationMode(); |
150 WindowFullscreenStateChanged(); | 150 WindowFullscreenStateChanged(); |
151 } | 151 } |
152 #endif | 152 #endif |
153 | 153 |
154 // TODO(koz): Change |for_tab| to an enum. | 154 // TODO(koz): Change |for_tab| to an enum. |
155 void FullscreenController::ToggleFullscreenMode(bool for_tab) { | 155 void FullscreenController::ToggleFullscreenMode(bool for_tab) { |
156 bool entering_fullscreen = !window_->IsFullscreen(); | 156 bool entering_fullscreen = !window_->IsFullscreen(); |
157 | 157 |
158 #if !defined(OS_MACOSX) | 158 #if !defined(OS_MACOSX) |
159 // In kiosk mode, we always want to be fullscreen. When the browser first | 159 // In kiosk mode, we always want to be fullscreen. When the browser first |
160 // starts we're not yet fullscreen, so let the initial toggle go through. | 160 // starts we're not yet fullscreen, so let the initial toggle go through. |
161 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && | 161 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && |
162 window_->IsFullscreen()) | 162 window_->IsFullscreen()) |
163 return; | 163 return; |
164 #endif | 164 #endif |
165 | 165 |
166 GURL url; | 166 GURL url; |
167 if (for_tab) { | 167 if (for_tab) { |
168 url = browser_->GetSelectedTabContents()->GetURL(); | 168 url = browser_->GetSelectedWebContents()->GetURL(); |
169 tab_fullscreen_accepted_ = entering_fullscreen && | 169 tab_fullscreen_accepted_ = entering_fullscreen && |
170 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 170 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; |
171 } else { | 171 } else { |
172 content::RecordAction(UserMetricsAction("ToggleFullscreen")); | 172 content::RecordAction(UserMetricsAction("ToggleFullscreen")); |
173 } | 173 } |
174 if (entering_fullscreen) | 174 if (entering_fullscreen) |
175 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); | 175 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); |
176 else | 176 else |
177 window_->ExitFullscreen(); | 177 window_->ExitFullscreen(); |
178 | 178 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 ContentSetting | 350 ContentSetting |
351 FullscreenController::GetMouseLockSetting(const GURL& url) const { | 351 FullscreenController::GetMouseLockSetting(const GURL& url) const { |
352 if (url.SchemeIsFile()) | 352 if (url.SchemeIsFile()) |
353 return CONTENT_SETTING_ALLOW; | 353 return CONTENT_SETTING_ALLOW; |
354 | 354 |
355 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 355 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
356 return settings_map->GetContentSetting(url, url, | 356 return settings_map->GetContentSetting(url, url, |
357 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 357 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
358 } | 358 } |
OLD | NEW |