| 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( |
| 145 exclusive_access_context->UpdateFullscreenWithToolbar(false); | 146 ExclusiveAccessContext::STATE_ENTER_TAB_FULLSCREEN); |
| 146 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR; | 147 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN; |
| 147 } else { | |
| 148 // Browser Fullscreen without Toolbar -> Tab Fullscreen. | |
| 149 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR; | |
| 150 } | 148 } |
| 151 | 149 |
| 152 // We need to update the fullscreen exit bubble, e.g., going from browser | 150 // We need to update the fullscreen exit bubble, e.g., going from browser |
| 153 // fullscreen to tab fullscreen will need to show different content. | 151 // fullscreen to tab fullscreen will need to show different content. |
| 154 tab_fullscreen_ = true; | 152 tab_fullscreen_ = true; |
| 155 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 153 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
| 156 | 154 |
| 157 // This is only a change between Browser and Tab fullscreen. We generate | 155 // This is only a change between Browser and Tab fullscreen. We generate |
| 158 // a fullscreen notification now because there is no window change. | 156 // a fullscreen notification now because there is no window change. |
| 159 PostFullscreenChangeNotification(true); | 157 PostFullscreenChangeNotification(true); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 176 | 174 |
| 177 if (!exclusive_access_context->IsFullscreen()) | 175 if (!exclusive_access_context->IsFullscreen()) |
| 178 return; | 176 return; |
| 179 | 177 |
| 180 if (IsFullscreenCausedByTab()) { | 178 if (IsFullscreenCausedByTab()) { |
| 181 // Tab Fullscreen -> Normal. | 179 // Tab Fullscreen -> Normal. |
| 182 ToggleFullscreenModeInternal(TAB); | 180 ToggleFullscreenModeInternal(TAB); |
| 183 return; | 181 return; |
| 184 } | 182 } |
| 185 | 183 |
| 186 // Tab Fullscreen -> Browser Fullscreen (with or without toolbar). | 184 // Tab Fullscreen -> Browser Fullscreen. |
| 187 if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) { | 185 if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN) |
| 188 // Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar. | 186 exclusive_access_context->UpdateUIForTabFullscreen( |
| 189 exclusive_access_context->UpdateFullscreenWithToolbar(true); | 187 ExclusiveAccessContext::STATE_EXIT_TAB_FULLSCREEN); |
| 190 } | |
| 191 | 188 |
| 192 #if defined(OS_MACOSX) | 189 #if defined(OS_MACOSX) |
| 193 // Clear the bubble URL, which forces the Mac UI to redraw. | 190 // Clear the bubble URL, which forces the Mac UI to redraw. |
| 194 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 191 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
| 195 #endif // defined(OS_MACOSX) | 192 #endif // defined(OS_MACOSX) |
| 196 | 193 |
| 197 // If currently there is a tab in "tab fullscreen" mode and fullscreen | 194 // 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" | 195 // 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 | 196 // 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 | 197 // 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) { | 327 int bubble_reshow_count) { |
| 331 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); | 328 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); |
| 332 } | 329 } |
| 333 | 330 |
| 334 void FullscreenController::ToggleFullscreenModeInternal( | 331 void FullscreenController::ToggleFullscreenModeInternal( |
| 335 FullscreenInternalOption option) { | 332 FullscreenInternalOption option) { |
| 336 ExclusiveAccessContext* const exclusive_access_context = | 333 ExclusiveAccessContext* const exclusive_access_context = |
| 337 exclusive_access_manager()->context(); | 334 exclusive_access_manager()->context(); |
| 338 bool enter_fullscreen = !exclusive_access_context->IsFullscreen(); | 335 bool enter_fullscreen = !exclusive_access_context->IsFullscreen(); |
| 339 | 336 |
| 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 | |
| 352 | |
| 353 // In kiosk mode, we always want to be fullscreen. When the browser first | 337 // 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. | 338 // starts we're not yet fullscreen, so let the initial toggle go through. |
| 355 if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen()) | 339 if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen()) |
| 356 return; | 340 return; |
| 357 | 341 |
| 358 #if !defined(OS_MACOSX) | 342 #if !defined(OS_MACOSX) |
| 359 // Do not enter fullscreen mode if disallowed by pref. This prevents the user | 343 // 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 | 344 // from manually entering fullscreen mode and also disables kiosk mode on |
| 361 // desktop platforms. | 345 // desktop platforms. |
| 362 if (enter_fullscreen && | 346 if (enter_fullscreen && |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 return fullscreened_origin_; | 452 return fullscreened_origin_; |
| 469 | 453 |
| 470 return exclusive_access_tab()->GetLastCommittedURL(); | 454 return exclusive_access_tab()->GetLastCommittedURL(); |
| 471 } | 455 } |
| 472 | 456 |
| 473 GURL FullscreenController::GetEmbeddingOrigin() const { | 457 GURL FullscreenController::GetEmbeddingOrigin() const { |
| 474 DCHECK(exclusive_access_tab()); | 458 DCHECK(exclusive_access_tab()); |
| 475 | 459 |
| 476 return exclusive_access_tab()->GetLastCommittedURL(); | 460 return exclusive_access_tab()->GetLastCommittedURL(); |
| 477 } | 461 } |
| OLD | NEW |