Chromium Code Reviews| 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/exclusive_access/fullscreen_controller.h" | 5 #include "chrome/browser/ui/exclusive_access/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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 ExclusiveAccessContext* exclusive_access_context = | 133 ExclusiveAccessContext* exclusive_access_context = |
| 134 exclusive_access_manager()->context(); | 134 exclusive_access_manager()->context(); |
| 135 | 135 |
| 136 if (!exclusive_access_context->IsFullscreen()) { | 136 if (!exclusive_access_context->IsFullscreen()) { |
| 137 // Normal -> Tab Fullscreen. | 137 // Normal -> Tab Fullscreen. |
| 138 state_prior_to_tab_fullscreen_ = STATE_NORMAL; | 138 state_prior_to_tab_fullscreen_ = STATE_NORMAL; |
| 139 ToggleFullscreenModeInternal(TAB); | 139 ToggleFullscreenModeInternal(TAB); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Browser Fullscreen -> Tab Fullscreen. | |
| 143 if (exclusive_access_context->IsFullscreen()) { | 144 if (exclusive_access_context->IsFullscreen()) { |
| 144 // Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar). | 145 exclusive_access_context->UpdateUIForTabFullscreen(true); |
| 145 exclusive_access_context->UpdateFullscreenWithToolbar(false); | 146 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN; |
| 146 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR; | |
| 147 } else { | |
| 148 // Browser Fullscreen without Toolbar -> Tab Fullscreen. | |
| 149 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR; | |
| 150 } | 147 } |
| 151 | 148 |
| 152 // We need to update the fullscreen exit bubble, e.g., going from browser | 149 // We need to update the fullscreen exit bubble, e.g., going from browser |
| 153 // fullscreen to tab fullscreen will need to show different content. | 150 // fullscreen to tab fullscreen will need to show different content. |
| 154 tab_fullscreen_ = true; | 151 tab_fullscreen_ = true; |
| 155 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 152 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
| 156 | 153 |
| 157 // This is only a change between Browser and Tab fullscreen. We generate | 154 // This is only a change between Browser and Tab fullscreen. We generate |
| 158 // a fullscreen notification now because there is no window change. | 155 // a fullscreen notification now because there is no window change. |
| 159 PostFullscreenChangeNotification(true); | 156 PostFullscreenChangeNotification(true); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 176 | 173 |
| 177 if (!exclusive_access_context->IsFullscreen()) | 174 if (!exclusive_access_context->IsFullscreen()) |
| 178 return; | 175 return; |
| 179 | 176 |
| 180 if (IsFullscreenCausedByTab()) { | 177 if (IsFullscreenCausedByTab()) { |
| 181 // Tab Fullscreen -> Normal. | 178 // Tab Fullscreen -> Normal. |
| 182 ToggleFullscreenModeInternal(TAB); | 179 ToggleFullscreenModeInternal(TAB); |
| 183 return; | 180 return; |
| 184 } | 181 } |
| 185 | 182 |
| 186 // Tab Fullscreen -> Browser Fullscreen (with or without toolbar). | 183 // Tab Fullscreen -> Browser Fullscreen. |
| 187 if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) { | 184 if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN) |
| 188 // Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar. | 185 exclusive_access_context->UpdateUIForTabFullscreen(false); |
| 189 exclusive_access_context->UpdateFullscreenWithToolbar(true); | |
| 190 } | |
| 191 | 186 |
| 192 #if defined(OS_MACOSX) | 187 #if defined(OS_MACOSX) |
| 193 // Clear the bubble URL, which forces the Mac UI to redraw. | 188 // Clear the bubble URL, which forces the Mac UI to redraw. |
| 194 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 189 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
| 195 #endif // defined(OS_MACOSX) | 190 #endif // defined(OS_MACOSX) |
| 196 | 191 |
| 197 // If currently there is a tab in "tab fullscreen" mode and fullscreen | 192 // If currently there is a tab in "tab fullscreen" mode and fullscreen |
| 198 // was not caused by it (i.e., previously it was in "browser fullscreen" | 193 // was not caused by it (i.e., previously it was in "browser fullscreen" |
| 199 // mode), we need to switch back to "browser fullscreen" mode. In this | 194 // mode), we need to switch back to "browser fullscreen" mode. In this |
| 200 // case, all we have to do is notifying the tab that it has exited "tab | 195 // case, all we have to do is notifying the tab that it has exited "tab |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 int bubble_reshow_count) { | 325 int bubble_reshow_count) { |
| 331 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); | 326 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); |
| 332 } | 327 } |
| 333 | 328 |
| 334 void FullscreenController::ToggleFullscreenModeInternal( | 329 void FullscreenController::ToggleFullscreenModeInternal( |
| 335 FullscreenInternalOption option) { | 330 FullscreenInternalOption option) { |
| 336 ExclusiveAccessContext* const exclusive_access_context = | 331 ExclusiveAccessContext* const exclusive_access_context = |
| 337 exclusive_access_manager()->context(); | 332 exclusive_access_manager()->context(); |
| 338 bool enter_fullscreen = !exclusive_access_context->IsFullscreen(); | 333 bool enter_fullscreen = !exclusive_access_context->IsFullscreen(); |
| 339 | 334 |
| 340 #if defined(OS_MACOSX) | |
| 341 // When a Mac user requests a toggle they may be toggling between | |
| 342 // FullscreenWithoutChrome and FullscreenWithToolbar. | |
| 343 // TODO(spqchan): Refactor toolbar related code since most of it should be | |
| 344 // deprecated. | |
| 345 if (exclusive_access_context->IsFullscreen() && | |
| 346 !IsWindowFullscreenForTabOrPending() && | |
| 347 IsExtensionFullscreenOrPending()) { | |
| 348 enter_fullscreen = enter_fullscreen || | |
| 349 exclusive_access_context->IsFullscreen(); | |
| 350 } | |
| 351 #endif | |
|
Nico
2016/06/22 21:35:54
why is this block no longer needed?
spqchan
2016/06/22 22:33:37
This is only used if we're switching between Prese
| |
| 352 | |
| 353 // In kiosk mode, we always want to be fullscreen. When the browser first | 335 // In kiosk mode, we always want to be fullscreen. When the browser first |
| 354 // starts we're not yet fullscreen, so let the initial toggle go through. | 336 // starts we're not yet fullscreen, so let the initial toggle go through. |
| 355 if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen()) | 337 if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen()) |
| 356 return; | 338 return; |
| 357 | 339 |
| 358 #if !defined(OS_MACOSX) | 340 #if !defined(OS_MACOSX) |
| 359 // Do not enter fullscreen mode if disallowed by pref. This prevents the user | 341 // Do not enter fullscreen mode if disallowed by pref. This prevents the user |
| 360 // from manually entering fullscreen mode and also disables kiosk mode on | 342 // from manually entering fullscreen mode and also disables kiosk mode on |
| 361 // desktop platforms. | 343 // desktop platforms. |
| 362 if (enter_fullscreen && | 344 if (enter_fullscreen && |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 return fullscreened_origin_; | 450 return fullscreened_origin_; |
| 469 | 451 |
| 470 return exclusive_access_tab()->GetLastCommittedURL(); | 452 return exclusive_access_tab()->GetLastCommittedURL(); |
| 471 } | 453 } |
| 472 | 454 |
| 473 GURL FullscreenController::GetEmbeddingOrigin() const { | 455 GURL FullscreenController::GetEmbeddingOrigin() const { |
| 474 DCHECK(exclusive_access_tab()); | 456 DCHECK(exclusive_access_tab()); |
| 475 | 457 |
| 476 return exclusive_access_tab()->GetLastCommittedURL(); | 458 return exclusive_access_tab()->GetLastCommittedURL(); |
| 477 } | 459 } |
| OLD | NEW |