Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 7461059: Fullscreen JS API implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 notify_tab_of_fullscreen_exit_(false),
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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 } 1486 }
1485 1487
1486 void Browser::CloseWindow() { 1488 void Browser::CloseWindow() {
1487 UserMetrics::RecordAction(UserMetricsAction("CloseWindow")); 1489 UserMetrics::RecordAction(UserMetricsAction("CloseWindow"));
1488 window_->Close(); 1490 window_->Close();
1489 } 1491 }
1490 1492
1491 void Browser::NewTab() { 1493 void Browser::NewTab() {
1492 UserMetrics::RecordAction(UserMetricsAction("NewTab")); 1494 UserMetrics::RecordAction(UserMetricsAction("NewTab"));
1493 1495
1496 ExitTabbedFullscreenMode();
1497
1494 if (is_type_tabbed()) { 1498 if (is_type_tabbed()) {
1495 AddBlankTab(true); 1499 AddBlankTab(true);
1496 GetSelectedTabContentsWrapper()->view()->RestoreFocus(); 1500 GetSelectedTabContentsWrapper()->view()->RestoreFocus();
1497 } else { 1501 } else {
1498 Browser* b = GetOrCreateTabbedBrowser(profile_); 1502 Browser* b = GetOrCreateTabbedBrowser(profile_);
1499 b->AddBlankTab(true); 1503 b->AddBlankTab(true);
1500 b->window()->Show(); 1504 b->window()->Show();
1501 // The call to AddBlankTab above did not set the focus to the tab as its 1505 // The call to AddBlankTab above did not set the focus to the tab as its
1502 // window was not active, so we have to do it explicitly. 1506 // window was not active, so we have to do it explicitly.
1503 // See http://crbug.com/6380. 1507 // See http://crbug.com/6380.
1504 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus(); 1508 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus();
1505 } 1509 }
1506 } 1510 }
1507 1511
1508 void Browser::CloseTab() { 1512 void Browser::CloseTab() {
1509 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator")); 1513 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
1510 if (CanCloseTab()) 1514 if (CanCloseTab())
1511 tab_handler_->GetTabStripModel()->CloseSelectedTabs(); 1515 tab_handler_->GetTabStripModel()->CloseSelectedTabs();
1516 ExitTabbedFullscreenMode();
1512 } 1517 }
1513 1518
1514 void Browser::SelectNextTab() { 1519 void Browser::SelectNextTab() {
1515 UserMetrics::RecordAction(UserMetricsAction("SelectNextTab")); 1520 UserMetrics::RecordAction(UserMetricsAction("SelectNextTab"));
1521 ExitTabbedFullscreenMode();
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 ExitTabbedFullscreenMode();
Ben Goodger (Google) 2011/08/15 22:37:12 For all of these... these aren't the only ways tha
koz (OOO until 15th September) 2011/08/16 07:06:55 Done.
1521 tab_handler_->GetTabStripModel()->SelectPreviousTab(); 1528 tab_handler_->GetTabStripModel()->SelectPreviousTab();
1522 } 1529 }
1523 1530
1524 void Browser::OpenTabpose() { 1531 void Browser::OpenTabpose() {
1525 #if defined(OS_MACOSX) 1532 #if defined(OS_MACOSX)
1526 if (!CommandLine::ForCurrentProcess()->HasSwitch( 1533 if (!CommandLine::ForCurrentProcess()->HasSwitch(
1527 switches::kEnableExposeForTabs)) { 1534 switches::kEnableExposeForTabs)) {
1528 return; 1535 return;
1529 } 1536 }
1530 1537
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); 1598 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"));
1592 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); 1599 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index();
1593 TabContentsWrapper* contents = 1600 TabContentsWrapper* contents =
1594 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); 1601 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index);
1595 Browser* browser = Browser::Create(profile_); 1602 Browser* browser = Browser::Create(profile_);
1596 browser->tabstrip_model()->AppendTabContents(contents, true); 1603 browser->tabstrip_model()->AppendTabContents(contents, true);
1597 browser->window()->Show(); 1604 browser->window()->Show();
1598 } 1605 }
1599 1606
1600 void Browser::ToggleFullscreenMode() { 1607 void Browser::ToggleFullscreenMode() {
1608 bool entering_fullscreen = !window_->IsFullscreen();
1609
1601 #if !defined(OS_MACOSX) 1610 #if !defined(OS_MACOSX)
1602 // In kiosk mode, we always want to be fullscreen. When the browser first 1611 // 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. 1612 // starts we're not yet fullscreen, so let the initial toggle go through.
1604 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && 1613 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) &&
1605 window_->IsFullscreen()) 1614 window_->IsFullscreen())
1606 return; 1615 return;
1607 #endif 1616 #endif
1608 1617
1609 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); 1618 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"));
1610 window_->SetFullscreen(!window_->IsFullscreen()); 1619 window_->SetFullscreen(entering_fullscreen);
1611 1620
1612 // Once the window has become fullscreen it'll call back to 1621 // Once the window has become fullscreen it'll call back to
1613 // WindowFullscreenStateChanged(). We don't do this immediately as 1622 // WindowFullscreenStateChanged(). We don't do this immediately as
1614 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the 1623 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the
1615 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 1624 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
1616 1625
1617 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates 1626 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates
1618 // the necessary state of the frame. 1627 // the necessary state of the frame.
1619 #if defined(OS_MACOSX) 1628 #if defined(OS_MACOSX)
1620 WindowFullscreenStateChanged(); 1629 WindowFullscreenStateChanged();
1621 #endif 1630 #endif
1631
1632 if (!entering_fullscreen)
1633 NotifyTabOfFullscreenExit();
1634 }
1635
1636 void Browser::NotifyTabOfFullscreenExit() {
1637 if (!notify_tab_of_fullscreen_exit_)
Ben Goodger (Google) 2011/08/15 22:37:12 Would be nice for the logic of this function to li
koz (OOO until 15th September) 2011/08/16 07:06:55 Done.
1638 return;
1639 TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper();
1640 RenderViewHost* host = tab_contents->render_view_host();
1641 host->Send(new ViewMsg_ExitFullscreen(host->routing_id()));
1642 notify_tab_of_fullscreen_exit_ = false;
1643 tab_caused_fullscreen_ = false;
1622 } 1644 }
1623 1645
1624 #if defined(OS_CHROMEOS) 1646 #if defined(OS_CHROMEOS)
1625 void Browser::Search() { 1647 void Browser::Search() {
1626 // If the NTP is showing, close it. 1648 // If the NTP is showing, close it.
1627 const GURL& url = GetSelectedTabContents()->GetURL(); 1649 const GURL& url = GetSelectedTabContents()->GetURL();
1628 if (url.SchemeIs(chrome::kChromeUIScheme) && 1650 if (url.SchemeIs(chrome::kChromeUIScheme) &&
1629 url.host() == chrome::kChromeUINewTabHost) { 1651 url.host() == chrome::kChromeUINewTabHost) {
1630 CloseTab(); 1652 CloseTab();
1631 return; 1653 return;
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 3138
3117 if (source) { 3139 if (source) {
3118 NotificationService::current()->Notify( 3140 NotificationService::current()->Notify(
3119 content::NOTIFICATION_TAB_ADDED, 3141 content::NOTIFICATION_TAB_ADDED,
3120 Source<TabContentsDelegate>(source->delegate()), 3142 Source<TabContentsDelegate>(source->delegate()),
3121 Details<TabContents>(source)); 3143 Details<TabContents>(source));
3122 } 3144 }
3123 } 3145 }
3124 3146
3125 void Browser::ActivateContents(TabContents* contents) { 3147 void Browser::ActivateContents(TabContents* contents) {
3148 int activating_index =
3149 tab_handler_->GetTabStripModel()->GetWrapperIndex(contents);
3150 int active_index = tab_handler_->GetTabStripModel()->active_index();
3151
3152 if (activating_index != active_index) {
3153 ExitTabbedFullscreenMode();
3154 }
3126 tab_handler_->GetTabStripModel()->ActivateTabAt( 3155 tab_handler_->GetTabStripModel()->ActivateTabAt(
3127 tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false); 3156 activating_index, false);
3128 window_->Activate(); 3157 window_->Activate();
3129 } 3158 }
3130 3159
3131 void Browser::DeactivateContents(TabContents* contents) { 3160 void Browser::DeactivateContents(TabContents* contents) {
3132 window_->Deactivate(); 3161 window_->Deactivate();
3133 } 3162 }
3134 3163
3135 void Browser::LoadingStateChanged(TabContents* source) { 3164 void Browser::LoadingStateChanged(TabContents* source) {
3136 window_->UpdateLoadingAnimations( 3165 window_->UpdateLoadingAnimations(
3137 tab_handler_->GetTabStripModel()->TabsAreLoading()); 3166 tab_handler_->GetTabStripModel()->TabsAreLoading());
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 3499
3471 void Browser::DidNavigateToPendingEntry(TabContents* tab) { 3500 void Browser::DidNavigateToPendingEntry(TabContents* tab) {
3472 if (tab == GetSelectedTabContents()) 3501 if (tab == GetSelectedTabContents())
3473 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); 3502 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
3474 } 3503 }
3475 3504
3476 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { 3505 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() {
3477 return GetJavaScriptDialogCreatorInstance(); 3506 return GetJavaScriptDialogCreatorInstance();
3478 } 3507 }
3479 3508
3509 void Browser::ToggleFullscreenModeForRVH(TabContents* tab,
3510 bool enter_fullscreen) {
3511 if (tab != GetSelectedTabContents())
3512 return;
3513 if (enter_fullscreen) {
Ben Goodger (Google) 2011/08/15 22:37:12 These toggling functions make my brain hurt. Give
Peter Kasting 2011/08/15 22:42:54 BTW Ben, that's how things originally were, and I
Peter Kasting 2011/08/15 22:42:54 Nit: Shorter: notify_tab_of_fullscreen_exit_ =
koz (OOO until 15th September) 2011/08/16 07:06:55 This is shorter, but I feel it is less semantic. M
3514 notify_tab_of_fullscreen_exit_ = true;
3515 if (!window_->IsFullscreen()) {
3516 tab_caused_fullscreen_ = true;
3517 ToggleFullscreenMode();
3518 }
3519 } else {
3520 notify_tab_of_fullscreen_exit_ = false;
3521 if (tab_caused_fullscreen_)
3522 ToggleFullscreenMode();
3523 }
3524 }
3525
3526 void Browser::ExitTabbedFullscreenMode() {
3527 if (tab_caused_fullscreen_)
3528 ToggleFullscreenMode();
3529 else
3530 NotifyTabOfFullscreenExit();
3531 }
3532
3480 /////////////////////////////////////////////////////////////////////////////// 3533 ///////////////////////////////////////////////////////////////////////////////
3481 // Browser, TabContentsWrapperDelegate implementation: 3534 // Browser, TabContentsWrapperDelegate implementation:
3482 3535
3483 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3536 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3484 int32 page_id) { 3537 int32 page_id) {
3485 if (GetSelectedTabContentsWrapper() != source) 3538 if (GetSelectedTabContentsWrapper() != source)
3486 return; 3539 return;
3487 3540
3488 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3541 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3489 if (!entry || (entry->page_id() != page_id)) 3542 if (!entry || (entry->page_id() != page_id))
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4782 window_->BookmarkBarStateChanged(animate_type); 4835 window_->BookmarkBarStateChanged(animate_type);
4783 } 4836 }
4784 4837
4785 void Browser::ShowSyncSetup() { 4838 void Browser::ShowSyncSetup() {
4786 ProfileSyncService* service = profile()->GetProfileSyncService(); 4839 ProfileSyncService* service = profile()->GetProfileSyncService();
4787 if (service->HasSyncSetupCompleted()) 4840 if (service->HasSyncSetupCompleted())
4788 ShowOptionsTab(chrome::kSyncSetupSubPage); 4841 ShowOptionsTab(chrome::kSyncSetupSubPage);
4789 else 4842 else
4790 profile()->GetProfileSyncService()->ShowLoginDialog(); 4843 profile()->GetProfileSyncService()->ShowLoginDialog();
4791 } 4844 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698