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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 cancel_download_confirmation_state_(NOT_PROMPTED), | 243 cancel_download_confirmation_state_(NOT_PROMPTED), |
244 maximized_state_(MAXIMIZED_STATE_DEFAULT), | 244 maximized_state_(MAXIMIZED_STATE_DEFAULT), |
245 method_factory_(this), | 245 method_factory_(this), |
246 block_command_execution_(false), | 246 block_command_execution_(false), |
247 last_blocked_command_id_(-1), | 247 last_blocked_command_id_(-1), |
248 last_blocked_command_disposition_(CURRENT_TAB), | 248 last_blocked_command_disposition_(CURRENT_TAB), |
249 pending_web_app_action_(NONE), | 249 pending_web_app_action_(NONE), |
250 ALLOW_THIS_IN_INITIALIZER_LIST( | 250 ALLOW_THIS_IN_INITIALIZER_LIST( |
251 tab_restore_service_delegate_( | 251 tab_restore_service_delegate_( |
252 new BrowserTabRestoreServiceDelegate(this))), | 252 new BrowserTabRestoreServiceDelegate(this))), |
253 bookmark_bar_state_(BookmarkBar::HIDDEN) { | 253 bookmark_bar_state_(BookmarkBar::HIDDEN), |
254 fullscreened_tab_(NULL), | |
255 tab_caused_fullscreen_(false) { | |
254 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, | 256 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, |
255 NotificationService::AllSources()); | 257 NotificationService::AllSources()); |
256 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 258 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
257 NotificationService::AllSources()); | 259 NotificationService::AllSources()); |
258 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 260 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
259 NotificationService::AllSources()); | 261 NotificationService::AllSources()); |
260 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 262 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
261 NotificationService::AllSources()); | 263 NotificationService::AllSources()); |
262 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 264 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
263 NotificationService::AllSources()); | 265 NotificationService::AllSources()); |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); | 1593 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); |
1592 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); | 1594 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); |
1593 TabContentsWrapper* contents = | 1595 TabContentsWrapper* contents = |
1594 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); | 1596 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); |
1595 Browser* browser = Browser::Create(profile_); | 1597 Browser* browser = Browser::Create(profile_); |
1596 browser->tabstrip_model()->AppendTabContents(contents, true); | 1598 browser->tabstrip_model()->AppendTabContents(contents, true); |
1597 browser->window()->Show(); | 1599 browser->window()->Show(); |
1598 } | 1600 } |
1599 | 1601 |
1600 void Browser::ToggleFullscreenMode() { | 1602 void Browser::ToggleFullscreenMode() { |
1603 bool entering_fullscreen = !window_->IsFullscreen(); | |
1604 | |
1601 #if !defined(OS_MACOSX) | 1605 #if !defined(OS_MACOSX) |
1602 // In kiosk mode, we always want to be fullscreen. When the browser first | 1606 // In kiosk mode, we always want to be fullscreen. When the browser first |
1603 // starts we're not yet fullscreen, so let the initial toggle go through. | 1607 // starts we're not yet fullscreen, so let the initial toggle go through. |
1604 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && | 1608 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && |
1605 window_->IsFullscreen()) | 1609 window_->IsFullscreen()) |
1606 return; | 1610 return; |
1607 #endif | 1611 #endif |
1608 | 1612 |
1609 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); | 1613 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); |
1610 window_->SetFullscreen(!window_->IsFullscreen()); | 1614 window_->SetFullscreen(entering_fullscreen); |
1611 | 1615 |
1612 // Once the window has become fullscreen it'll call back to | 1616 // Once the window has become fullscreen it'll call back to |
1613 // WindowFullscreenStateChanged(). We don't do this immediately as | 1617 // WindowFullscreenStateChanged(). We don't do this immediately as |
1614 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the | 1618 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the |
1615 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 1619 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
1616 | 1620 |
1617 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates | 1621 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates |
1618 // the necessary state of the frame. | 1622 // the necessary state of the frame. |
1619 #if defined(OS_MACOSX) | 1623 #if defined(OS_MACOSX) |
1620 WindowFullscreenStateChanged(); | 1624 WindowFullscreenStateChanged(); |
1621 #endif | 1625 #endif |
1626 | |
1627 if (!entering_fullscreen) | |
1628 NotifyTabOfFullscreenExitIfNecessary(); | |
1629 } | |
1630 | |
1631 void Browser::NotifyTabOfFullscreenExitIfNecessary() { | |
1632 if (fullscreened_tab_) | |
1633 fullscreened_tab_->ExitFullscreenMode(); | |
1634 fullscreened_tab_ = NULL; | |
1635 tab_caused_fullscreen_ = false; | |
1622 } | 1636 } |
1623 | 1637 |
1624 #if defined(OS_CHROMEOS) | 1638 #if defined(OS_CHROMEOS) |
1625 void Browser::Search() { | 1639 void Browser::Search() { |
1626 // If the NTP is showing, close it. | 1640 // If the NTP is showing, close it. |
1627 const GURL& url = GetSelectedTabContents()->GetURL(); | 1641 const GURL& url = GetSelectedTabContents()->GetURL(); |
1628 if (url.SchemeIs(chrome::kChromeUIScheme) && | 1642 if (url.SchemeIs(chrome::kChromeUIScheme) && |
1629 url.host() == chrome::kChromeUINewTabHost) { | 1643 url.host() == chrome::kChromeUINewTabHost) { |
1630 CloseTab(); | 1644 CloseTab(); |
1631 return; | 1645 return; |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2905 | 2919 |
2906 // Save what the user's currently typing, so it can be restored when we | 2920 // Save what the user's currently typing, so it can be restored when we |
2907 // switch back to this tab. | 2921 // switch back to this tab. |
2908 window_->GetLocationBar()->SaveStateToContents(contents->tab_contents()); | 2922 window_->GetLocationBar()->SaveStateToContents(contents->tab_contents()); |
2909 } | 2923 } |
2910 | 2924 |
2911 void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, | 2925 void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, |
2912 TabContentsWrapper* new_contents, | 2926 TabContentsWrapper* new_contents, |
2913 int index, | 2927 int index, |
2914 bool user_gesture) { | 2928 bool user_gesture) { |
2929 ExitTabbedFullscreenModeIfNecessary(); | |
Peter Kasting
2011/08/18 00:48:51
I wonder if it would be better to move this into T
| |
2915 // On some platforms we want to automatically reload tabs that are | 2930 // On some platforms we want to automatically reload tabs that are |
2916 // killed when the user selects them. | 2931 // killed when the user selects them. |
2917 if (user_gesture && new_contents->tab_contents()->crashed_status() == | 2932 if (user_gesture && new_contents->tab_contents()->crashed_status() == |
2918 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 2933 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
2919 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 2934 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
2920 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { | 2935 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { |
2921 Reload(CURRENT_TAB); | 2936 Reload(CURRENT_TAB); |
2922 return; | 2937 return; |
2923 } | 2938 } |
2924 } | 2939 } |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3470 | 3485 |
3471 void Browser::DidNavigateToPendingEntry(TabContents* tab) { | 3486 void Browser::DidNavigateToPendingEntry(TabContents* tab) { |
3472 if (tab == GetSelectedTabContents()) | 3487 if (tab == GetSelectedTabContents()) |
3473 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 3488 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
3474 } | 3489 } |
3475 | 3490 |
3476 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { | 3491 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { |
3477 return GetJavaScriptDialogCreatorInstance(); | 3492 return GetJavaScriptDialogCreatorInstance(); |
3478 } | 3493 } |
3479 | 3494 |
3495 void Browser::ToggleFullscreenModeForTab(TabContents* tab, | |
3496 bool enter_fullscreen) { | |
3497 if (tab != GetSelectedTabContents()) | |
3498 return; | |
3499 fullscreened_tab_ = enter_fullscreen ? | |
3500 TabContentsWrapper::GetCurrentWrapperForContents(tab) : NULL; | |
3501 if (enter_fullscreen && !window_->IsFullscreen()) | |
3502 tab_caused_fullscreen_ = true; | |
3503 if (tab_caused_fullscreen_) | |
3504 ToggleFullscreenMode(); | |
3505 } | |
3506 | |
3507 void Browser::ExitTabbedFullscreenModeIfNecessary() { | |
3508 if (tab_caused_fullscreen_) | |
3509 ToggleFullscreenMode(); | |
3510 else | |
3511 NotifyTabOfFullscreenExitIfNecessary(); | |
3512 } | |
3513 | |
3480 /////////////////////////////////////////////////////////////////////////////// | 3514 /////////////////////////////////////////////////////////////////////////////// |
3481 // Browser, TabContentsWrapperDelegate implementation: | 3515 // Browser, TabContentsWrapperDelegate implementation: |
3482 | 3516 |
3483 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, | 3517 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, |
3484 int32 page_id) { | 3518 int32 page_id) { |
3485 if (GetSelectedTabContentsWrapper() != source) | 3519 if (GetSelectedTabContentsWrapper() != source) |
3486 return; | 3520 return; |
3487 | 3521 |
3488 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); | 3522 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); |
3489 if (!entry || (entry->page_id() != page_id)) | 3523 if (!entry || (entry->page_id() != page_id)) |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4782 window_->BookmarkBarStateChanged(animate_type); | 4816 window_->BookmarkBarStateChanged(animate_type); |
4783 } | 4817 } |
4784 | 4818 |
4785 void Browser::ShowSyncSetup() { | 4819 void Browser::ShowSyncSetup() { |
4786 ProfileSyncService* service = profile()->GetProfileSyncService(); | 4820 ProfileSyncService* service = profile()->GetProfileSyncService(); |
4787 if (service->HasSyncSetupCompleted()) | 4821 if (service->HasSyncSetupCompleted()) |
4788 ShowOptionsTab(chrome::kSyncSetupSubPage); | 4822 ShowOptionsTab(chrome::kSyncSetupSubPage); |
4789 else | 4823 else |
4790 profile()->GetProfileSyncService()->ShowLoginDialog(); | 4824 profile()->GetProfileSyncService()->ShowLoginDialog(); |
4791 } | 4825 } |
OLD | NEW |