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_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 "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" |
11 #include "chrome/browser/download/download_shelf.h" | 11 #include "chrome/browser/download/download_shelf.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "content/public/browser/navigation_details.h" | 20 #include "content/public/browser/navigation_details.h" |
20 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 bool FullscreenController::IsFullscreenForTabOrPending() const { | 66 bool FullscreenController::IsFullscreenForTabOrPending() const { |
66 return fullscreened_tab_ != NULL; | 67 return fullscreened_tab_ != NULL; |
67 } | 68 } |
68 | 69 |
69 bool FullscreenController::IsFullscreenForTabOrPending( | 70 bool FullscreenController::IsFullscreenForTabOrPending( |
70 const WebContents* web_contents) const { | 71 const WebContents* web_contents) const { |
71 const TabContents* tab_contents = | 72 const TabContents* tab_contents = |
72 TabContents::FromWebContents(web_contents); | 73 TabContents::FromWebContents(web_contents); |
73 if (!tab_contents || (tab_contents != fullscreened_tab_)) | 74 if (!tab_contents || (tab_contents != fullscreened_tab_)) |
74 return false; | 75 return false; |
75 DCHECK(web_contents == browser_->GetActiveWebContents()); | 76 DCHECK(web_contents == chrome::GetActiveWebContents(browser_)); |
76 return true; | 77 return true; |
77 } | 78 } |
78 | 79 |
79 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
80 bool FullscreenController::IsInMetroSnapMode() { | 81 bool FullscreenController::IsInMetroSnapMode() { |
81 return window_->IsInMetroSnapMode(); | 82 return window_->IsInMetroSnapMode(); |
82 } | 83 } |
83 #endif | 84 #endif |
84 | 85 |
85 bool FullscreenController::IsMouseLockRequested() const { | 86 bool FullscreenController::IsMouseLockRequested() const { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 mouse_lock_state_ = MOUSELOCK_REQUESTED; | 147 mouse_lock_state_ = MOUSELOCK_REQUESTED; |
147 break; | 148 break; |
148 default: | 149 default: |
149 NOTREACHED(); | 150 NOTREACHED(); |
150 } | 151 } |
151 UpdateFullscreenExitBubbleContent(); | 152 UpdateFullscreenExitBubbleContent(); |
152 } | 153 } |
153 | 154 |
154 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, | 155 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, |
155 bool enter_fullscreen) { | 156 bool enter_fullscreen) { |
156 if (web_contents != browser_->GetActiveWebContents()) | 157 if (web_contents != chrome::GetActiveWebContents(browser_)) |
157 return; | 158 return; |
158 | 159 |
159 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
160 // For now, avoid breaking when initiating full screen tab mode while in | 161 // For now, avoid breaking when initiating full screen tab mode while in |
161 // a metro snap. | 162 // a metro snap. |
162 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen | 163 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen |
163 // modes with metro snap. | 164 // modes with metro snap. |
164 if (IsInMetroSnapMode()) | 165 if (IsInMetroSnapMode()) |
165 return; | 166 return; |
166 #endif | 167 #endif |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 523 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
523 return settings_map->GetContentSetting(url, url, | 524 return settings_map->GetContentSetting(url, url, |
524 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 525 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
525 } | 526 } |
526 | 527 |
527 #if defined(OS_MACOSX) | 528 #if defined(OS_MACOSX) |
528 void FullscreenController::TogglePresentationModeInternal(bool for_tab) { | 529 void FullscreenController::TogglePresentationModeInternal(bool for_tab) { |
529 toggled_into_fullscreen_ = !window_->InPresentationMode(); | 530 toggled_into_fullscreen_ = !window_->InPresentationMode(); |
530 GURL url; | 531 GURL url; |
531 if (for_tab) { | 532 if (for_tab) { |
532 url = browser_->GetActiveWebContents()->GetURL(); | 533 url = chrome::GetActiveWebContents(browser_)->GetURL(); |
533 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && | 534 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && |
534 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 535 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; |
535 } | 536 } |
536 if (toggled_into_fullscreen_) | 537 if (toggled_into_fullscreen_) |
537 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); | 538 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); |
538 else | 539 else |
539 window_->ExitPresentationMode(); | 540 window_->ExitPresentationMode(); |
540 UpdateFullscreenExitBubbleContent(); | 541 UpdateFullscreenExitBubbleContent(); |
541 | 542 |
542 // WindowFullscreenStateChanged will be called by BrowserWindowController | 543 // WindowFullscreenStateChanged will be called by BrowserWindowController |
(...skipping 12 matching lines...) Expand all Loading... |
555 toggled_into_fullscreen_ = !window_->IsFullscreen(); | 556 toggled_into_fullscreen_ = !window_->IsFullscreen(); |
556 | 557 |
557 // In kiosk mode, we always want to be fullscreen. When the browser first | 558 // In kiosk mode, we always want to be fullscreen. When the browser first |
558 // starts we're not yet fullscreen, so let the initial toggle go through. | 559 // starts we're not yet fullscreen, so let the initial toggle go through. |
559 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && | 560 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && |
560 !toggled_into_fullscreen_) | 561 !toggled_into_fullscreen_) |
561 return; | 562 return; |
562 | 563 |
563 GURL url; | 564 GURL url; |
564 if (for_tab) { | 565 if (for_tab) { |
565 url = browser_->GetActiveWebContents()->GetURL(); | 566 url = chrome::GetActiveWebContents(browser_)->GetURL(); |
566 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && | 567 tab_fullscreen_accepted_ = toggled_into_fullscreen_ && |
567 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; | 568 GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW; |
568 } else { | 569 } else { |
569 if (!extension_caused_fullscreen_.is_empty()) | 570 if (!extension_caused_fullscreen_.is_empty()) |
570 url = extension_caused_fullscreen_; | 571 url = extension_caused_fullscreen_; |
571 content::RecordAction(UserMetricsAction("ToggleFullscreen")); | 572 content::RecordAction(UserMetricsAction("ToggleFullscreen")); |
572 } | 573 } |
573 if (toggled_into_fullscreen_) { | 574 if (toggled_into_fullscreen_) { |
574 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); | 575 window_->EnterFullscreen(url, GetFullscreenExitBubbleType()); |
575 } else { | 576 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
586 | 587 |
587 void FullscreenController::SetFullscreenedTab(TabContents* tab) { | 588 void FullscreenController::SetFullscreenedTab(TabContents* tab) { |
588 fullscreened_tab_ = tab; | 589 fullscreened_tab_ = tab; |
589 UpdateNotificationRegistrations(); | 590 UpdateNotificationRegistrations(); |
590 } | 591 } |
591 | 592 |
592 void FullscreenController::SetMouseLockTab(TabContents* tab) { | 593 void FullscreenController::SetMouseLockTab(TabContents* tab) { |
593 mouse_lock_tab_ = tab; | 594 mouse_lock_tab_ = tab; |
594 UpdateNotificationRegistrations(); | 595 UpdateNotificationRegistrations(); |
595 } | 596 } |
OLD | NEW |