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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1502 // window was not active, so we have to do it explicitly. | 1502 // window was not active, so we have to do it explicitly. |
1503 // See http://crbug.com/6380. | 1503 // See http://crbug.com/6380. |
1504 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus(); | 1504 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus(); |
1505 } | 1505 } |
1506 } | 1506 } |
1507 | 1507 |
1508 void Browser::CloseTab() { | 1508 void Browser::CloseTab() { |
1509 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator")); | 1509 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator")); |
1510 if (CanCloseTab()) | 1510 if (CanCloseTab()) |
1511 tab_handler_->GetTabStripModel()->CloseSelectedTabs(); | 1511 tab_handler_->GetTabStripModel()->CloseSelectedTabs(); |
1512 if (fullscreen_for_tab_) { | |
Peter Kasting
2011/08/11 17:53:38
Nit: No need for {} (3 places)
koz (OOO until 15th September)
2011/08/15 05:50:27
Done.
| |
1513 ToggleFullscreenMode(); | |
1514 } | |
1512 } | 1515 } |
1513 | 1516 |
1514 void Browser::SelectNextTab() { | 1517 void Browser::SelectNextTab() { |
1515 UserMetrics::RecordAction(UserMetricsAction("SelectNextTab")); | 1518 UserMetrics::RecordAction(UserMetricsAction("SelectNextTab")); |
1519 if (fullscreen_for_tab_) { | |
1520 ToggleFullscreenMode(); | |
1521 } | |
1516 tab_handler_->GetTabStripModel()->SelectNextTab(); | 1522 tab_handler_->GetTabStripModel()->SelectNextTab(); |
1517 } | 1523 } |
1518 | 1524 |
1519 void Browser::SelectPreviousTab() { | 1525 void Browser::SelectPreviousTab() { |
1520 UserMetrics::RecordAction(UserMetricsAction("SelectPrevTab")); | 1526 UserMetrics::RecordAction(UserMetricsAction("SelectPrevTab")); |
1527 if (fullscreen_for_tab_) { | |
1528 ToggleFullscreenMode(); | |
1529 } | |
1521 tab_handler_->GetTabStripModel()->SelectPreviousTab(); | 1530 tab_handler_->GetTabStripModel()->SelectPreviousTab(); |
1522 } | 1531 } |
1523 | 1532 |
1524 void Browser::OpenTabpose() { | 1533 void Browser::OpenTabpose() { |
1525 #if defined(OS_MACOSX) | 1534 #if defined(OS_MACOSX) |
1526 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1535 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1527 switches::kEnableExposeForTabs)) { | 1536 switches::kEnableExposeForTabs)) { |
1528 return; | 1537 return; |
1529 } | 1538 } |
1530 | 1539 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); | 1600 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); |
1592 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); | 1601 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); |
1593 TabContentsWrapper* contents = | 1602 TabContentsWrapper* contents = |
1594 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); | 1603 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); |
1595 Browser* browser = Browser::Create(profile_); | 1604 Browser* browser = Browser::Create(profile_); |
1596 browser->tabstrip_model()->AppendTabContents(contents, true); | 1605 browser->tabstrip_model()->AppendTabContents(contents, true); |
1597 browser->window()->Show(); | 1606 browser->window()->Show(); |
1598 } | 1607 } |
1599 | 1608 |
1600 void Browser::ToggleFullscreenMode() { | 1609 void Browser::ToggleFullscreenMode() { |
1610 bool entering_fullscreen = !window_->IsFullscreen(); | |
1611 | |
1601 #if !defined(OS_MACOSX) | 1612 #if !defined(OS_MACOSX) |
1602 // In kiosk mode, we always want to be fullscreen. When the browser first | 1613 // 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. | 1614 // starts we're not yet fullscreen, so let the initial toggle go through. |
1604 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && | 1615 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && |
1605 window_->IsFullscreen()) | 1616 window_->IsFullscreen()) |
1606 return; | 1617 return; |
1607 #endif | 1618 #endif |
1608 | 1619 |
1609 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); | 1620 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); |
1610 window_->SetFullscreen(!window_->IsFullscreen()); | 1621 window_->SetFullscreen(entering_fullscreen); |
1611 | 1622 |
1612 // Once the window has become fullscreen it'll call back to | 1623 // Once the window has become fullscreen it'll call back to |
1613 // WindowFullscreenStateChanged(). We don't do this immediately as | 1624 // WindowFullscreenStateChanged(). We don't do this immediately as |
1614 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the | 1625 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the |
1615 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 1626 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
1616 | 1627 |
1617 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates | 1628 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates |
1618 // the necessary state of the frame. | 1629 // the necessary state of the frame. |
1619 #if defined(OS_MACOSX) | 1630 #if defined(OS_MACOSX) |
1620 WindowFullscreenStateChanged(); | 1631 WindowFullscreenStateChanged(); |
1621 #endif | 1632 #endif |
1633 | |
1634 if (fullscreen_for_tab_ && !entering_fullscreen) { | |
1635 TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper(); | |
1636 RenderViewHost* host = tab_contents->render_view_host(); | |
1637 host->Send(new ViewMsg_ExitFullscreen(host->routing_id())); | |
1638 fullscreen_for_tab_ = false; | |
1639 } | |
1622 } | 1640 } |
1623 | 1641 |
1624 #if defined(OS_CHROMEOS) | 1642 #if defined(OS_CHROMEOS) |
1625 void Browser::Search() { | 1643 void Browser::Search() { |
1626 // If the NTP is showing, close it. | 1644 // If the NTP is showing, close it. |
1627 const GURL& url = GetSelectedTabContents()->GetURL(); | 1645 const GURL& url = GetSelectedTabContents()->GetURL(); |
1628 if (url.SchemeIs(chrome::kChromeUIScheme) && | 1646 if (url.SchemeIs(chrome::kChromeUIScheme) && |
1629 url.host() == chrome::kChromeUINewTabHost) { | 1647 url.host() == chrome::kChromeUINewTabHost) { |
1630 CloseTab(); | 1648 CloseTab(); |
1631 return; | 1649 return; |
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3116 | 3134 |
3117 if (source) { | 3135 if (source) { |
3118 NotificationService::current()->Notify( | 3136 NotificationService::current()->Notify( |
3119 content::NOTIFICATION_TAB_ADDED, | 3137 content::NOTIFICATION_TAB_ADDED, |
3120 Source<TabContentsDelegate>(source->delegate()), | 3138 Source<TabContentsDelegate>(source->delegate()), |
3121 Details<TabContents>(source)); | 3139 Details<TabContents>(source)); |
3122 } | 3140 } |
3123 } | 3141 } |
3124 | 3142 |
3125 void Browser::ActivateContents(TabContents* contents) { | 3143 void Browser::ActivateContents(TabContents* contents) { |
3144 int activating_index = | |
3145 tab_handler_->GetTabStripModel()->GetWrapperIndex(contents); | |
3146 int active_index = tab_handler_->GetTabStripModel()->active_index(); | |
3147 | |
3148 if (fullscreen_for_tab_ && activating_index != active_index) { | |
3149 ToggleFullscreenMode(); | |
3150 } | |
3126 tab_handler_->GetTabStripModel()->ActivateTabAt( | 3151 tab_handler_->GetTabStripModel()->ActivateTabAt( |
3127 tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false); | 3152 activating_index, false); |
3128 window_->Activate(); | 3153 window_->Activate(); |
3129 } | 3154 } |
3130 | 3155 |
3131 void Browser::DeactivateContents(TabContents* contents) { | 3156 void Browser::DeactivateContents(TabContents* contents) { |
3132 window_->Deactivate(); | 3157 window_->Deactivate(); |
3133 } | 3158 } |
3134 | 3159 |
3135 void Browser::LoadingStateChanged(TabContents* source) { | 3160 void Browser::LoadingStateChanged(TabContents* source) { |
3136 window_->UpdateLoadingAnimations( | 3161 window_->UpdateLoadingAnimations( |
3137 tab_handler_->GetTabStripModel()->TabsAreLoading()); | 3162 tab_handler_->GetTabStripModel()->TabsAreLoading()); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3470 | 3495 |
3471 void Browser::DidNavigateToPendingEntry(TabContents* tab) { | 3496 void Browser::DidNavigateToPendingEntry(TabContents* tab) { |
3472 if (tab == GetSelectedTabContents()) | 3497 if (tab == GetSelectedTabContents()) |
3473 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 3498 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
3474 } | 3499 } |
3475 | 3500 |
3476 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { | 3501 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { |
3477 return GetJavaScriptDialogCreatorInstance(); | 3502 return GetJavaScriptDialogCreatorInstance(); |
3478 } | 3503 } |
3479 | 3504 |
3505 void Browser::EnterFullscreenModeForCurrentTab() { | |
3506 fullscreen_for_tab_ = true; | |
Peter Kasting
2011/08/11 17:53:38
It seems like a mistake to set this variable befor
koz (OOO until 15th September)
2011/08/15 05:50:27
I've changed the behaviour here so that instead of
| |
3507 if (window_->IsFullscreen()) | |
3508 return; | |
3509 ToggleFullscreenMode(); | |
3510 } | |
3511 | |
3512 void Browser::ExitFullscreenMode() { | |
3513 fullscreen_for_tab_ = false; | |
3514 if (!window_->IsFullscreen()) | |
3515 return; | |
3516 ToggleFullscreenMode(); | |
3517 } | |
3518 | |
3480 /////////////////////////////////////////////////////////////////////////////// | 3519 /////////////////////////////////////////////////////////////////////////////// |
3481 // Browser, TabContentsWrapperDelegate implementation: | 3520 // Browser, TabContentsWrapperDelegate implementation: |
3482 | 3521 |
3483 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, | 3522 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, |
3484 int32 page_id) { | 3523 int32 page_id) { |
3485 if (GetSelectedTabContentsWrapper() != source) | 3524 if (GetSelectedTabContentsWrapper() != source) |
3486 return; | 3525 return; |
3487 | 3526 |
3488 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); | 3527 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); |
3489 if (!entry || (entry->page_id() != page_id)) | 3528 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); | 4821 window_->BookmarkBarStateChanged(animate_type); |
4783 } | 4822 } |
4784 | 4823 |
4785 void Browser::ShowSyncSetup() { | 4824 void Browser::ShowSyncSetup() { |
4786 ProfileSyncService* service = profile()->GetProfileSyncService(); | 4825 ProfileSyncService* service = profile()->GetProfileSyncService(); |
4787 if (service->HasSyncSetupCompleted()) | 4826 if (service->HasSyncSetupCompleted()) |
4788 ShowOptionsTab(chrome::kSyncSetupSubPage); | 4827 ShowOptionsTab(chrome::kSyncSetupSubPage); |
4789 else | 4828 else |
4790 profile()->GetProfileSyncService()->ShowLoginDialog(); | 4829 profile()->GetProfileSyncService()->ShowLoginDialog(); |
4791 } | 4830 } |
OLD | NEW |