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

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: rebase Created 9 years, 3 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/browser_browsertest.cc » ('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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 block_command_execution_(false), 255 block_command_execution_(false),
256 last_blocked_command_id_(-1), 256 last_blocked_command_id_(-1),
257 last_blocked_command_disposition_(CURRENT_TAB), 257 last_blocked_command_disposition_(CURRENT_TAB),
258 pending_web_app_action_(NONE), 258 pending_web_app_action_(NONE),
259 ALLOW_THIS_IN_INITIALIZER_LIST( 259 ALLOW_THIS_IN_INITIALIZER_LIST(
260 tab_restore_service_delegate_( 260 tab_restore_service_delegate_(
261 new BrowserTabRestoreServiceDelegate(this))), 261 new BrowserTabRestoreServiceDelegate(this))),
262 ALLOW_THIS_IN_INITIALIZER_LIST( 262 ALLOW_THIS_IN_INITIALIZER_LIST(
263 synced_window_delegate_( 263 synced_window_delegate_(
264 new BrowserSyncedWindowDelegate(this))), 264 new BrowserSyncedWindowDelegate(this))),
265 bookmark_bar_state_(BookmarkBar::HIDDEN) { 265 bookmark_bar_state_(BookmarkBar::HIDDEN),
266 fullscreened_tab_(NULL),
267 tab_caused_fullscreen_(false) {
266 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, 268 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
267 NotificationService::AllSources()); 269 NotificationService::AllSources());
268 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 270 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
269 NotificationService::AllSources()); 271 NotificationService::AllSources());
270 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 272 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
271 NotificationService::AllSources()); 273 NotificationService::AllSources());
272 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 274 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
273 NotificationService::AllSources()); 275 NotificationService::AllSources());
274 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 276 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
275 NotificationService::AllSources()); 277 NotificationService::AllSources());
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 local_params.disposition = CURRENT_TAB; 1277 local_params.disposition = CURRENT_TAB;
1276 } 1278 }
1277 } 1279 }
1278 1280
1279 browser::Navigate(&local_params); 1281 browser::Navigate(&local_params);
1280 } 1282 }
1281 1283
1282 void Browser::WindowFullscreenStateChanged() { 1284 void Browser::WindowFullscreenStateChanged() {
1283 UpdateCommandsForFullscreenMode(window_->IsFullscreen()); 1285 UpdateCommandsForFullscreenMode(window_->IsFullscreen());
1284 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); 1286 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN);
1287 MessageLoop::current()->PostTask(
1288 FROM_HERE, method_factory_.NewRunnableMethod(
1289 &Browser::NotifyFullscreenChange));
1290 }
1291
1292 void Browser::NotifyFullscreenChange() {
1293 NotificationService::current()->Notify(
1294 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
1295 Source<Browser>(this),
1296 NotificationService::NoDetails());
1285 } 1297 }
1286 1298
1287 /////////////////////////////////////////////////////////////////////////////// 1299 ///////////////////////////////////////////////////////////////////////////////
1288 // Browser, Assorted browser commands: 1300 // Browser, Assorted browser commands:
1289 1301
1290 TabContents* Browser::GetOrCloneTabForDisposition( 1302 TabContents* Browser::GetOrCloneTabForDisposition(
1291 WindowOpenDisposition disposition) { 1303 WindowOpenDisposition disposition) {
1292 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); 1304 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
1293 switch (disposition) { 1305 switch (disposition) {
1294 case NEW_FOREGROUND_TAB: 1306 case NEW_FOREGROUND_TAB:
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); 1635 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"));
1624 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); 1636 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index();
1625 TabContentsWrapper* contents = 1637 TabContentsWrapper* contents =
1626 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); 1638 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index);
1627 Browser* browser = Browser::Create(profile_); 1639 Browser* browser = Browser::Create(profile_);
1628 browser->tabstrip_model()->AppendTabContents(contents, true); 1640 browser->tabstrip_model()->AppendTabContents(contents, true);
1629 browser->window()->Show(); 1641 browser->window()->Show();
1630 } 1642 }
1631 1643
1632 void Browser::ToggleFullscreenMode() { 1644 void Browser::ToggleFullscreenMode() {
1645 bool entering_fullscreen = !window_->IsFullscreen();
1646
1633 #if !defined(OS_MACOSX) 1647 #if !defined(OS_MACOSX)
1634 // In kiosk mode, we always want to be fullscreen. When the browser first 1648 // In kiosk mode, we always want to be fullscreen. When the browser first
1635 // starts we're not yet fullscreen, so let the initial toggle go through. 1649 // starts we're not yet fullscreen, so let the initial toggle go through.
1636 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && 1650 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) &&
1637 window_->IsFullscreen()) 1651 window_->IsFullscreen())
1638 return; 1652 return;
1639 #endif 1653 #endif
1640 1654
1641 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); 1655 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"));
1642 window_->SetFullscreen(!window_->IsFullscreen()); 1656 window_->SetFullscreen(entering_fullscreen);
1643 1657
1644 // Once the window has become fullscreen it'll call back to 1658 // Once the window has become fullscreen it'll call back to
1645 // WindowFullscreenStateChanged(). We don't do this immediately as 1659 // WindowFullscreenStateChanged(). We don't do this immediately as
1646 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the 1660 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the
1647 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 1661 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
1648 1662
1649 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates 1663 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates
1650 // the necessary state of the frame. 1664 // the necessary state of the frame.
1651 #if defined(OS_MACOSX) 1665 #if defined(OS_MACOSX)
1652 WindowFullscreenStateChanged(); 1666 WindowFullscreenStateChanged();
1653 #endif 1667 #endif
1668
1669 if (!entering_fullscreen)
1670 NotifyTabOfFullscreenExitIfNecessary();
1671 }
1672
1673 void Browser::NotifyTabOfFullscreenExitIfNecessary() {
1674 if (fullscreened_tab_)
1675 fullscreened_tab_->ExitFullscreenMode();
1676 fullscreened_tab_ = NULL;
1677 tab_caused_fullscreen_ = false;
1654 } 1678 }
1655 1679
1656 #if defined(OS_MACOSX) 1680 #if defined(OS_MACOSX)
1657 void Browser::TogglePresentationMode() { 1681 void Browser::TogglePresentationMode() {
1658 window_->SetPresentationMode(!window_->InPresentationMode()); 1682 window_->SetPresentationMode(!window_->InPresentationMode());
1659 WindowFullscreenStateChanged(); 1683 WindowFullscreenStateChanged();
1660 } 1684 }
1661 #endif 1685 #endif
1662 1686
1663 #if defined(OS_CHROMEOS) 1687 #if defined(OS_CHROMEOS)
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2989 3013
2990 // Sever the TabContents' connection back to us. 3014 // Sever the TabContents' connection back to us.
2991 SetAsDelegate(contents, NULL); 3015 SetAsDelegate(contents, NULL);
2992 } 3016 }
2993 3017
2994 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { 3018 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
2995 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); 3019 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH);
2996 } 3020 }
2997 3021
2998 void Browser::TabDeactivated(TabContentsWrapper* contents) { 3022 void Browser::TabDeactivated(TabContentsWrapper* contents) {
3023 if (contents == fullscreened_tab_)
3024 ExitTabbedFullscreenModeIfNecessary();
2999 if (instant()) 3025 if (instant())
3000 instant()->DestroyPreviewContents(); 3026 instant()->DestroyPreviewContents();
3001 3027
3002 // Save what the user's currently typing, so it can be restored when we 3028 // Save what the user's currently typing, so it can be restored when we
3003 // switch back to this tab. 3029 // switch back to this tab.
3004 window_->GetLocationBar()->SaveStateToContents(contents->tab_contents()); 3030 window_->GetLocationBar()->SaveStateToContents(contents->tab_contents());
3005 } 3031 }
3006 3032
3007 void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, 3033 void Browser::ActiveTabChanged(TabContentsWrapper* old_contents,
3008 TabContentsWrapper* new_contents, 3034 TabContentsWrapper* new_contents,
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 void Browser::RunFileChooser(TabContents* tab, 3618 void Browser::RunFileChooser(TabContents* tab,
3593 const ViewHostMsg_RunFileChooser_Params& params) { 3619 const ViewHostMsg_RunFileChooser_Params& params) {
3594 Browser::RunFileChooserHelper(tab, params); 3620 Browser::RunFileChooserHelper(tab, params);
3595 } 3621 }
3596 3622
3597 void Browser::EnumerateDirectory(TabContents* tab, int request_id, 3623 void Browser::EnumerateDirectory(TabContents* tab, int request_id,
3598 const FilePath& path) { 3624 const FilePath& path) {
3599 Browser::EnumerateDirectoryHelper(tab, request_id, path); 3625 Browser::EnumerateDirectoryHelper(tab, request_id, path);
3600 } 3626 }
3601 3627
3628 void Browser::ToggleFullscreenModeForTab(TabContents* tab,
3629 bool enter_fullscreen) {
3630 if (tab != GetSelectedTabContents())
3631 return;
3632 fullscreened_tab_ = enter_fullscreen ?
3633 TabContentsWrapper::GetCurrentWrapperForContents(tab) : NULL;
3634 if (enter_fullscreen && !window_->IsFullscreen())
3635 tab_caused_fullscreen_ = true;
3636 if (tab_caused_fullscreen_)
3637 ToggleFullscreenMode();
3638 }
3639
3640 void Browser::ExitTabbedFullscreenModeIfNecessary() {
3641 if (tab_caused_fullscreen_)
3642 ToggleFullscreenMode();
3643 else
3644 NotifyTabOfFullscreenExitIfNecessary();
3645 }
3646
3602 /////////////////////////////////////////////////////////////////////////////// 3647 ///////////////////////////////////////////////////////////////////////////////
3603 // Browser, TabContentsWrapperDelegate implementation: 3648 // Browser, TabContentsWrapperDelegate implementation:
3604 3649
3605 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3650 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3606 int32 page_id) { 3651 int32 page_id) {
3607 if (GetSelectedTabContentsWrapper() != source) 3652 if (GetSelectedTabContentsWrapper() != source)
3608 return; 3653 return;
3609 3654
3610 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3655 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3611 if (!entry || (entry->page_id() != page_id)) 3656 if (!entry || (entry->page_id() != page_id))
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
4934 } 4979 }
4935 4980
4936 void Browser::ShowSyncSetup() { 4981 void Browser::ShowSyncSetup() {
4937 ProfileSyncService* service = 4982 ProfileSyncService* service =
4938 profile()->GetOriginalProfile()->GetProfileSyncService(); 4983 profile()->GetOriginalProfile()->GetProfileSyncService();
4939 if (service->HasSyncSetupCompleted()) 4984 if (service->HasSyncSetupCompleted())
4940 ShowOptionsTab(chrome::kSyncSetupSubPage); 4985 ShowOptionsTab(chrome::kSyncSetupSubPage);
4941 else 4986 else
4942 service->ShowLoginDialog(); 4987 service->ShowLoginDialog();
4943 } 4988 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698