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

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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (!notify_tab_of_fullscreen_exit_)
1633 return;
1634 GetSelectedTabContentsWrapper()->ExitFullscreenMode();
1635 notify_tab_of_fullscreen_exit_ = false;
1636 tab_caused_fullscreen_ = false;
1622 } 1637 }
1623 1638
1624 #if defined(OS_CHROMEOS) 1639 #if defined(OS_CHROMEOS)
1625 void Browser::Search() { 1640 void Browser::Search() {
1626 // If the NTP is showing, close it. 1641 // If the NTP is showing, close it.
1627 const GURL& url = GetSelectedTabContents()->GetURL(); 1642 const GURL& url = GetSelectedTabContents()->GetURL();
1628 if (url.SchemeIs(chrome::kChromeUIScheme) && 1643 if (url.SchemeIs(chrome::kChromeUIScheme) &&
1629 url.host() == chrome::kChromeUINewTabHost) { 1644 url.host() == chrome::kChromeUINewTabHost) {
1630 CloseTab(); 1645 CloseTab();
1631 return; 1646 return;
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, 2894 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED,
2880 Source<TabContents>(contents->tab_contents())); 2895 Source<TabContents>(contents->tab_contents()));
2881 2896
2882 registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, 2897 registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED,
2883 Source<TabContents>(contents->tab_contents())); 2898 Source<TabContents>(contents->tab_contents()));
2884 } 2899 }
2885 2900
2886 void Browser::TabClosingAt(TabStripModel* tab_strip_model, 2901 void Browser::TabClosingAt(TabStripModel* tab_strip_model,
2887 TabContentsWrapper* contents, 2902 TabContentsWrapper* contents,
2888 int index) { 2903 int index) {
2904 if (contents == GetSelectedTabContentsWrapper())
2905 ExitTabbedFullscreenModeIfNecessary();
2889 NotificationService::current()->Notify( 2906 NotificationService::current()->Notify(
2890 content::NOTIFICATION_TAB_CLOSING, 2907 content::NOTIFICATION_TAB_CLOSING,
2891 Source<NavigationController>(&contents->controller()), 2908 Source<NavigationController>(&contents->controller()),
2892 NotificationService::NoDetails()); 2909 NotificationService::NoDetails());
2893 2910
2894 // Sever the TabContents' connection back to us. 2911 // Sever the TabContents' connection back to us.
2895 SetAsDelegate(contents, NULL); 2912 SetAsDelegate(contents, NULL);
2896 } 2913 }
2897 2914
2898 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { 2915 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
2899 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); 2916 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH);
2900 } 2917 }
2901 2918
2902 void Browser::TabDeactivated(TabContentsWrapper* contents) { 2919 void Browser::TabDeactivated(TabContentsWrapper* contents) {
2920 ExitTabbedFullscreenModeIfNecessary();
2903 if (instant()) 2921 if (instant())
2904 instant()->DestroyPreviewContents(); 2922 instant()->DestroyPreviewContents();
2905 2923
2906 // Save what the user's currently typing, so it can be restored when we 2924 // Save what the user's currently typing, so it can be restored when we
2907 // switch back to this tab. 2925 // switch back to this tab.
2908 window_->GetLocationBar()->SaveStateToContents(contents->tab_contents()); 2926 window_->GetLocationBar()->SaveStateToContents(contents->tab_contents());
2909 } 2927 }
2910 2928
2911 void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, 2929 void Browser::ActiveTabChanged(TabContentsWrapper* old_contents,
2912 TabContentsWrapper* new_contents, 2930 TabContentsWrapper* new_contents,
2913 int index, 2931 int index,
2914 bool user_gesture) { 2932 bool user_gesture) {
2933 ExitTabbedFullscreenModeIfNecessary();
2915 // On some platforms we want to automatically reload tabs that are 2934 // On some platforms we want to automatically reload tabs that are
2916 // killed when the user selects them. 2935 // killed when the user selects them.
2917 if (user_gesture && new_contents->tab_contents()->crashed_status() == 2936 if (user_gesture && new_contents->tab_contents()->crashed_status() ==
2918 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { 2937 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
2919 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 2938 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
2920 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { 2939 if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) {
2921 Reload(CURRENT_TAB); 2940 Reload(CURRENT_TAB);
2922 return; 2941 return;
2923 } 2942 }
2924 } 2943 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 3135
3117 if (source) { 3136 if (source) {
3118 NotificationService::current()->Notify( 3137 NotificationService::current()->Notify(
3119 content::NOTIFICATION_TAB_ADDED, 3138 content::NOTIFICATION_TAB_ADDED,
3120 Source<TabContentsDelegate>(source->delegate()), 3139 Source<TabContentsDelegate>(source->delegate()),
3121 Details<TabContents>(source)); 3140 Details<TabContents>(source));
3122 } 3141 }
3123 } 3142 }
3124 3143
3125 void Browser::ActivateContents(TabContents* contents) { 3144 void Browser::ActivateContents(TabContents* contents) {
3145 int activating_index =
3146 tab_handler_->GetTabStripModel()->GetWrapperIndex(contents);
3147 int active_index = tab_handler_->GetTabStripModel()->active_index();
Peter Kasting 2011/08/16 18:04:43 Nit: This variable seems unused? In fact this who
koz (OOO until 15th September) 2011/08/17 03:47:05 Done.
3148
3126 tab_handler_->GetTabStripModel()->ActivateTabAt( 3149 tab_handler_->GetTabStripModel()->ActivateTabAt(
3127 tab_handler_->GetTabStripModel()->GetWrapperIndex(contents), false); 3150 activating_index, false);
3128 window_->Activate(); 3151 window_->Activate();
3129 } 3152 }
3130 3153
3131 void Browser::DeactivateContents(TabContents* contents) { 3154 void Browser::DeactivateContents(TabContents* contents) {
3132 window_->Deactivate(); 3155 window_->Deactivate();
3133 } 3156 }
3134 3157
3135 void Browser::LoadingStateChanged(TabContents* source) { 3158 void Browser::LoadingStateChanged(TabContents* source) {
3136 window_->UpdateLoadingAnimations( 3159 window_->UpdateLoadingAnimations(
3137 tab_handler_->GetTabStripModel()->TabsAreLoading()); 3160 tab_handler_->GetTabStripModel()->TabsAreLoading());
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 3493
3471 void Browser::DidNavigateToPendingEntry(TabContents* tab) { 3494 void Browser::DidNavigateToPendingEntry(TabContents* tab) {
3472 if (tab == GetSelectedTabContents()) 3495 if (tab == GetSelectedTabContents())
3473 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); 3496 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
3474 } 3497 }
3475 3498
3476 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { 3499 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() {
3477 return GetJavaScriptDialogCreatorInstance(); 3500 return GetJavaScriptDialogCreatorInstance();
3478 } 3501 }
3479 3502
3503 void Browser::ToggleFullscreenModeForTab(TabContents* tab,
3504 bool enter_fullscreen) {
3505 if (tab != GetSelectedTabContents())
3506 return;
3507 if (enter_fullscreen)
3508 EnterFullscreenModeForTab(tab);
Peter Kasting 2011/08/16 18:04:43 I don't think this is a win over your previous pat
koz (OOO until 15th September) 2011/08/17 03:47:05 I think this is clearer because each function is e
3509 else
3510 ExitFullscreenModeForTab(tab);
3511 }
3512
3513 void Browser::EnterFullscreenModeForTab(TabContents* tab) {
3514 notify_tab_of_fullscreen_exit_ = true;
3515 if (!window_->IsFullscreen()) {
3516 tab_caused_fullscreen_ = true;
3517 ToggleFullscreenMode();
3518 }
3519 }
3520
3521 void Browser::ExitFullscreenModeForTab(TabContents* tab) {
3522 notify_tab_of_fullscreen_exit_ = false;
3523 if (tab_caused_fullscreen_)
3524 ToggleFullscreenMode();
3525 }
3526
3527 void Browser::ExitTabbedFullscreenModeIfNecessary() {
3528 if (tab_caused_fullscreen_)
3529 ToggleFullscreenMode();
3530 else
3531 NotifyTabOfFullscreenExitIfNecessary();
3532 }
3533
3480 /////////////////////////////////////////////////////////////////////////////// 3534 ///////////////////////////////////////////////////////////////////////////////
3481 // Browser, TabContentsWrapperDelegate implementation: 3535 // Browser, TabContentsWrapperDelegate implementation:
3482 3536
3483 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3537 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3484 int32 page_id) { 3538 int32 page_id) {
3485 if (GetSelectedTabContentsWrapper() != source) 3539 if (GetSelectedTabContentsWrapper() != source)
3486 return; 3540 return;
3487 3541
3488 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3542 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3489 if (!entry || (entry->page_id() != page_id)) 3543 if (!entry || (entry->page_id() != page_id))
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4782 window_->BookmarkBarStateChanged(animate_type); 4836 window_->BookmarkBarStateChanged(animate_type);
4783 } 4837 }
4784 4838
4785 void Browser::ShowSyncSetup() { 4839 void Browser::ShowSyncSetup() {
4786 ProfileSyncService* service = profile()->GetProfileSyncService(); 4840 ProfileSyncService* service = profile()->GetProfileSyncService();
4787 if (service->HasSyncSetupCompleted()) 4841 if (service->HasSyncSetupCompleted())
4788 ShowOptionsTab(chrome::kSyncSetupSubPage); 4842 ShowOptionsTab(chrome::kSyncSetupSubPage);
4789 else 4843 else
4790 profile()->GetProfileSyncService()->ShowLoginDialog(); 4844 profile()->GetProfileSyncService()->ShowLoginDialog();
4791 } 4845 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698