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/fullscreen/fullscreen_controller.h" | 5 #include "chrome/browser/ui/fullscreen/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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
77 // For now, avoid breaking when initiating full screen tab mode while in | 77 // For now, avoid breaking when initiating full screen tab mode while in |
78 // a metro snap. | 78 // a metro snap. |
79 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen | 79 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen |
80 // modes with metro snap. | 80 // modes with metro snap. |
81 if (IsInMetroSnapMode()) | 81 if (IsInMetroSnapMode()) |
82 return; | 82 return; |
83 #endif | 83 #endif |
84 | 84 |
85 bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); | 85 bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); |
86 #if defined(OS_MACOSX) | |
87 in_browser_or_tab_fullscreen_mode |= window_->InPresentationMode(); | |
88 #endif | |
89 | 86 |
90 if (enter_fullscreen) { | 87 if (enter_fullscreen) { |
91 SetFullscreenedTab(web_contents); | 88 SetFullscreenedTab(web_contents); |
92 if (!in_browser_or_tab_fullscreen_mode) { | 89 if (!in_browser_or_tab_fullscreen_mode) { |
93 tab_caused_fullscreen_ = true; | 90 tab_caused_fullscreen_ = true; |
94 #if defined(OS_MACOSX) | 91 #if defined(OS_MACOSX) |
95 TogglePresentationModeInternal(true); | 92 TogglePresentationModeInternal(true); |
96 #else | 93 #else |
97 ToggleFullscreenModeInternal(true); | 94 ToggleFullscreenModeInternal(true); |
98 #endif | 95 #endif |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean | 242 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean |
246 // up tab fullscreen related state. | 243 // up tab fullscreen related state. |
247 NotifyTabOfExitIfNecessary(); | 244 NotifyTabOfExitIfNecessary(); |
248 } | 245 } |
249 } | 246 } |
250 | 247 |
251 void FullscreenController::WindowFullscreenStateChanged() { | 248 void FullscreenController::WindowFullscreenStateChanged() { |
252 reentrant_window_state_change_call_check_ = true; | 249 reentrant_window_state_change_call_check_ = true; |
253 | 250 |
254 bool exiting_fullscreen = !window_->IsFullscreen(); | 251 bool exiting_fullscreen = !window_->IsFullscreen(); |
255 #if defined(OS_MACOSX) | 252 |
256 exiting_fullscreen &= !window_->InPresentationMode(); | |
257 #endif | |
258 PostFullscreenChangeNotification(!exiting_fullscreen); | 253 PostFullscreenChangeNotification(!exiting_fullscreen); |
259 if (exiting_fullscreen) | 254 if (exiting_fullscreen) |
260 NotifyTabOfExitIfNecessary(); | 255 NotifyTabOfExitIfNecessary(); |
261 if (exiting_fullscreen) | 256 if (exiting_fullscreen) |
262 window_->GetDownloadShelf()->Unhide(); | 257 window_->GetDownloadShelf()->Unhide(); |
263 else | 258 else |
264 window_->GetDownloadShelf()->Hide(); | 259 window_->GetDownloadShelf()->Hide(); |
265 } | 260 } |
266 | 261 |
267 bool FullscreenController::HandleUserPressedEscape() { | 262 bool FullscreenController::HandleUserPressedEscape() { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 489 |
495 // TODO(koz): Change |for_tab| to an enum. | 490 // TODO(koz): Change |for_tab| to an enum. |
496 void FullscreenController::ToggleFullscreenModeInternal(bool for_tab) { | 491 void FullscreenController::ToggleFullscreenModeInternal(bool for_tab) { |
497 #if defined(OS_WIN) | 492 #if defined(OS_WIN) |
498 // When in Metro snap mode, toggling in and out of fullscreen is prevented. | 493 // When in Metro snap mode, toggling in and out of fullscreen is prevented. |
499 if (IsInMetroSnapMode()) | 494 if (IsInMetroSnapMode()) |
500 return; | 495 return; |
501 #endif | 496 #endif |
502 | 497 |
503 toggled_into_fullscreen_ = !window_->IsFullscreen(); | 498 toggled_into_fullscreen_ = !window_->IsFullscreen(); |
499 #if defined(OS_MACOSX) | |
500 // When a Mac user requests a toggle they may be transitioning from | |
501 // FullscreenWithoutChrome to FullscreenWithChrome. | |
502 if (!IsFullscreenForTabOrPending()) | |
503 toggled_into_fullscreen_ |= window_->IsFullscreenWithoutChrome(); | |
504 #endif | |
504 | 505 |
505 // In kiosk mode, we always want to be fullscreen. When the browser first | 506 // In kiosk mode, we always want to be fullscreen. When the browser first |
506 // starts we're not yet fullscreen, so let the initial toggle go through. | 507 // starts we're not yet fullscreen, so let the initial toggle go through. |
507 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && | 508 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && |
508 !toggled_into_fullscreen_) | 509 !toggled_into_fullscreen_) |
509 return; | 510 return; |
510 | 511 |
511 GURL url; | 512 GURL url; |
512 if (for_tab) { | 513 if (for_tab) { |
513 url = chrome::GetActiveWebContents(browser_)->GetURL(); | 514 url = chrome::GetActiveWebContents(browser_)->GetURL(); |
514 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && | 515 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && |
515 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 516 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; |
516 } else { | 517 } else { |
517 if (!extension_caused_fullscreen_.is_empty()) | 518 if (!extension_caused_fullscreen_.is_empty()) |
518 url = extension_caused_fullscreen_; | 519 url = extension_caused_fullscreen_; |
519 content::RecordAction(UserMetricsAction("ToggleFullscreen")); | 520 content::RecordAction(UserMetricsAction("ToggleFullscreen")); |
520 } | 521 } |
521 if (toggled_into_fullscreen_) { | 522 if (toggled_into_fullscreen_) { |
523 #if defined(OS_MACOSX) | |
524 window_->EnterFullscreenWithChrome(url, GetFullscreenExitBubbleType()); | |
Robert Sesek
2013/01/18 19:41:35
This should probably just be EnterFullscreen so th
scheib
2013/01/23 18:13:37
I'd like to keep it explicit here that we are goin
| |
525 #else | |
522 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); | 526 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); |
527 #endif | |
523 } else { | 528 } else { |
524 #if defined(OS_MACOSX) | 529 #if defined(OS_MACOSX) |
525 // Mac windows report a state change instantly, and so we must also clear | 530 // Mac windows report a state change instantly, and so we must also clear |
526 // tab_caused_fullscreen_ to match them else other logic using | 531 // tab_caused_fullscreen_ to match them else other logic using |
527 // tab_caused_fullscreen_ will be incorrect. | 532 // tab_caused_fullscreen_ will be incorrect. |
528 NotifyTabOfExitIfNecessary(); | 533 NotifyTabOfExitIfNecessary(); |
529 | |
530 if (window_->InPresentationMode() && !for_tab) | |
531 window_->ExitPresentationMode(); | |
532 else | |
533 #endif | 534 #endif |
534 window_->ExitFullscreen(); | 535 window_->ExitFullscreen(); |
535 extension_caused_fullscreen_ = GURL(); | 536 extension_caused_fullscreen_ = GURL(); |
536 } | 537 } |
537 UpdateFullscreenExitBubbleContent(); | 538 UpdateFullscreenExitBubbleContent(); |
538 | 539 |
539 // Once the window has become fullscreen it'll call back to | 540 // Once the window has become fullscreen it'll call back to |
540 // WindowFullscreenStateChanged(). We don't do this immediately as | 541 // WindowFullscreenStateChanged(). We don't do this immediately as |
541 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let | 542 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let |
542 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 543 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
543 } | 544 } |
544 | 545 |
545 #if defined(OS_MACOSX) | 546 #if defined(OS_MACOSX) |
546 void FullscreenController::TogglePresentationModeInternal(bool for_tab) { | 547 void FullscreenController::TogglePresentationModeInternal(bool for_tab) { |
547 toggled_into_fullscreen_ = !window_->InPresentationMode(); | 548 toggled_into_fullscreen_ = !window_->IsFullscreenWithoutChrome(); |
548 GURL url; | 549 GURL url; |
549 if (for_tab) { | 550 if (for_tab) { |
550 url = chrome::GetActiveWebContents(browser_)->GetURL(); | 551 url = chrome::GetActiveWebContents(browser_)->GetURL(); |
551 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && | 552 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && |
552 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 553 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; |
553 } | 554 } |
554 if (!window_->InPresentationMode()) { | 555 if (!window_->IsFullscreenWithoutChrome()) { |
555 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); | 556 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); |
556 } else { | 557 } else { |
557 window_->ExitFullscreen(); | 558 window_->ExitFullscreen(); |
558 | 559 |
559 // Mac windows report a state change instantly, and so we must also clear | 560 // Mac windows report a state change instantly, and so we must also clear |
560 // tab_caused_fullscreen_ to match them else other logic using | 561 // tab_caused_fullscreen_ to match them else other logic using |
561 // tab_caused_fullscreen_ will be incorrect. | 562 // tab_caused_fullscreen_ will be incorrect. |
562 NotifyTabOfExitIfNecessary(); | 563 NotifyTabOfExitIfNecessary(); |
563 } | 564 } |
564 UpdateFullscreenExitBubbleContent(); | 565 UpdateFullscreenExitBubbleContent(); |
565 | 566 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 | 613 |
613 ContentSetting | 614 ContentSetting |
614 FullscreenController::GetMouseLockSetting(const GURL& url) const { | 615 FullscreenController::GetMouseLockSetting(const GURL& url) const { |
615 if (url.SchemeIsFile()) | 616 if (url.SchemeIsFile()) |
616 return CONTENT_SETTING_ALLOW; | 617 return CONTENT_SETTING_ALLOW; |
617 | 618 |
618 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 619 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
619 return settings_map->GetContentSetting(url, url, | 620 return settings_map->GetContentSetting(url, url, |
620 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 621 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
621 } | 622 } |
OLD | NEW |