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

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

Issue 7809013: Remove Animation When "Resuming" Window in Lion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds context parameter to BrowserWindow::Show(...) 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
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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 return app_name_ == DevToolsWindow::kDevToolsApp; 560 return app_name_ == DevToolsWindow::kDevToolsApp;
561 } 561 }
562 562
563 /////////////////////////////////////////////////////////////////////////////// 563 ///////////////////////////////////////////////////////////////////////////////
564 // Browser, Creation Helpers: 564 // Browser, Creation Helpers:
565 565
566 // static 566 // static
567 void Browser::OpenEmptyWindow(Profile* profile) { 567 void Browser::OpenEmptyWindow(Profile* profile) {
568 Browser* browser = Browser::Create(profile); 568 Browser* browser = Browser::Create(profile);
569 browser->AddBlankTab(true); 569 browser->AddBlankTab(true);
570 browser->window()->Show(); 570 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
571 } 571 }
572 572
573 // static 573 // static
574 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { 574 void Browser::OpenWindowWithRestoredTabs(Profile* profile) {
575 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); 575 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile);
576 if (service) 576 if (service)
577 service->RestoreMostRecentEntry(NULL); 577 service->RestoreMostRecentEntry(NULL);
578 } 578 }
579 579
580 // static 580 // static
581 void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { 581 void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
582 Browser* browser = GetOrCreateTabbedBrowser( 582 Browser* browser = GetOrCreateTabbedBrowser(
583 profile->GetOffTheRecordProfile()); 583 profile->GetOffTheRecordProfile());
584 browser->AddSelectedTabWithURL(url, PageTransition::LINK); 584 browser->AddSelectedTabWithURL(url, PageTransition::LINK);
585 browser->window()->Show(); 585 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
586 } 586 }
587 587
588 // static 588 // static
589 TabContents* Browser::OpenApplication( 589 TabContents* Browser::OpenApplication(
590 Profile* profile, 590 Profile* profile,
591 const Extension* extension, 591 const Extension* extension,
592 extension_misc::LaunchContainer container, 592 extension_misc::LaunchContainer container,
593 WindowOpenDisposition disposition) { 593 WindowOpenDisposition disposition) {
594 TabContents* tab = NULL; 594 TabContents* tab = NULL;
595 ExtensionPrefs* prefs = profile->GetExtensionService()->extension_prefs(); 595 ExtensionPrefs* prefs = profile->GetExtensionService()->extension_prefs();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 profile); 651 profile);
652 652
653 if (app_browser) 653 if (app_browser)
654 *app_browser = browser; 654 *app_browser = browser;
655 655
656 TabContentsWrapper* wrapper = 656 TabContentsWrapper* wrapper =
657 browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); 657 browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE);
658 TabContents* contents = wrapper->tab_contents(); 658 TabContents* contents = wrapper->tab_contents();
659 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 659 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
660 contents->render_view_host()->SyncRendererPrefs(); 660 contents->render_view_host()->SyncRendererPrefs();
661 browser->window()->Show(); 661 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
662 662
663 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial 663 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
664 // focus explicitly. 664 // focus explicitly.
665 contents->view()->SetInitialFocus(); 665 contents->view()->SetInitialFocus();
666 return contents; 666 return contents;
667 } 667 }
668 668
669 TabContents* Browser::OpenAppShortcutWindow(Profile* profile, 669 TabContents* Browser::OpenAppShortcutWindow(Profile* profile,
670 const GURL& url, 670 const GURL& url,
671 bool update_shortcut) { 671 bool update_shortcut) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 !browser->window()->IsFullscreen()) 756 !browser->window()->IsFullscreen())
757 browser->ToggleFullscreenMode(); 757 browser->ToggleFullscreenMode();
758 758
759 return contents; 759 return contents;
760 } 760 }
761 761
762 // static 762 // static
763 void Browser::OpenBookmarkManagerWindow(Profile* profile) { 763 void Browser::OpenBookmarkManagerWindow(Profile* profile) {
764 Browser* browser = Browser::Create(profile); 764 Browser* browser = Browser::Create(profile);
765 browser->OpenBookmarkManager(); 765 browser->OpenBookmarkManager();
766 browser->window()->Show(); 766 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
767 } 767 }
768 768
769 #if defined(OS_MACOSX) 769 #if defined(OS_MACOSX)
770 // static 770 // static
771 void Browser::OpenHistoryWindow(Profile* profile) { 771 void Browser::OpenHistoryWindow(Profile* profile) {
772 Browser* browser = Browser::Create(profile); 772 Browser* browser = Browser::Create(profile);
773 browser->ShowHistoryTab(); 773 browser->ShowHistoryTab();
774 browser->window()->Show(); 774 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
775 } 775 }
776 776
777 // static 777 // static
778 void Browser::OpenDownloadsWindow(Profile* profile) { 778 void Browser::OpenDownloadsWindow(Profile* profile) {
779 Browser* browser = Browser::Create(profile); 779 Browser* browser = Browser::Create(profile);
780 browser->ShowDownloadsTab(); 780 browser->ShowDownloadsTab();
781 browser->window()->Show(); 781 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
782 } 782 }
783 783
784 // static 784 // static
785 void Browser::OpenHelpWindow(Profile* profile) { 785 void Browser::OpenHelpWindow(Profile* profile) {
786 Browser* browser = Browser::Create(profile); 786 Browser* browser = Browser::Create(profile);
787 browser->ShowHelpTab(); 787 browser->ShowHelpTab();
788 browser->window()->Show(); 788 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
789 } 789 }
790 790
791 // static 791 // static
792 void Browser::OpenOptionsWindow(Profile* profile) { 792 void Browser::OpenOptionsWindow(Profile* profile) {
793 Browser* browser = Browser::Create(profile); 793 Browser* browser = Browser::Create(profile);
794 browser->OpenOptionsDialog(); 794 browser->OpenOptionsDialog();
795 browser->window()->Show(); 795 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
796 } 796 }
797 797
798 // static 798 // static
799 void Browser::OpenClearBrowsingDataDialogWindow(Profile* profile) { 799 void Browser::OpenClearBrowsingDataDialogWindow(Profile* profile) {
800 Browser* browser = Browser::Create(profile); 800 Browser* browser = Browser::Create(profile);
801 browser->OpenClearBrowsingDataDialog(); 801 browser->OpenClearBrowsingDataDialog();
802 browser->window()->Show(); 802 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
803 } 803 }
804 804
805 // static 805 // static
806 void Browser::OpenImportSettingsDialogWindow(Profile* profile) { 806 void Browser::OpenImportSettingsDialogWindow(Profile* profile) {
807 Browser* browser = Browser::Create(profile); 807 Browser* browser = Browser::Create(profile);
808 browser->OpenImportSettingsDialog(); 808 browser->OpenImportSettingsDialog();
809 browser->window()->Show(); 809 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
810 } 810 }
811 811
812 // static 812 // static
813 void Browser::OpenInstantConfirmDialogWindow(Profile* profile) { 813 void Browser::OpenInstantConfirmDialogWindow(Profile* profile) {
814 Browser* browser = Browser::Create(profile); 814 Browser* browser = Browser::Create(profile);
815 browser->OpenInstantConfirmDialog(); 815 browser->OpenInstantConfirmDialog();
816 browser->window()->Show(); 816 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
817 } 817 }
818 #endif 818 #endif
819 819
820 // static 820 // static
821 void Browser::OpenExtensionsWindow(Profile* profile) { 821 void Browser::OpenExtensionsWindow(Profile* profile) {
822 Browser* browser = Browser::Create(profile); 822 Browser* browser = Browser::Create(profile);
823 browser->ShowExtensionsTab(); 823 browser->ShowExtensionsTab();
824 browser->window()->Show(); 824 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
825 } 825 }
826 826
827 // static 827 // static
828 void Browser::NewWindowWithProfile(Profile* profile) { 828 void Browser::NewWindowWithProfile(Profile* profile) {
829 UserMetrics::RecordAction(UserMetricsAction("NewWindow")); 829 UserMetrics::RecordAction(UserMetricsAction("NewWindow"));
830 SessionService* session_service = 830 SessionService* session_service =
831 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile()); 831 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile());
832 if (!session_service || 832 if (!session_service ||
833 !session_service->RestoreIfNecessary(std::vector<GURL>())) { 833 !session_service->RestoreIfNecessary(std::vector<GURL>())) {
834 Browser::OpenEmptyWindow(profile->GetOriginalProfile()); 834 Browser::OpenEmptyWindow(profile->GetOriginalProfile());
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 current_tab, -1, PageTransition::LINK, 1316 current_tab, -1, PageTransition::LINK,
1317 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE : 1317 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE :
1318 TabStripModel::ADD_NONE); 1318 TabStripModel::ADD_NONE);
1319 break; 1319 break;
1320 } 1320 }
1321 case NEW_WINDOW: { 1321 case NEW_WINDOW: {
1322 current_tab = current_tab->Clone(); 1322 current_tab = current_tab->Clone();
1323 Browser* browser = Browser::Create(profile_); 1323 Browser* browser = Browser::Create(profile_);
1324 browser->tabstrip_model()->AddTabContents( 1324 browser->tabstrip_model()->AddTabContents(
1325 current_tab, -1, PageTransition::LINK, TabStripModel::ADD_ACTIVE); 1325 current_tab, -1, PageTransition::LINK, TabStripModel::ADD_ACTIVE);
1326 browser->window()->Show(); 1326 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
1327 break; 1327 break;
1328 } 1328 }
1329 default: 1329 default:
1330 break; 1330 break;
1331 } 1331 }
1332 return current_tab->tab_contents(); 1332 return current_tab->tab_contents();
1333 } 1333 }
1334 1334
1335 void Browser::UpdateTabStripModelInsertionPolicy() { 1335 void Browser::UpdateTabStripModelInsertionPolicy() {
1336 tab_handler_->GetTabStripModel()->SetInsertionPolicy(UseVerticalTabs() ? 1336 tab_handler_->GetTabStripModel()->SetInsertionPolicy(UseVerticalTabs() ?
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 1540
1541 void Browser::NewTab() { 1541 void Browser::NewTab() {
1542 UserMetrics::RecordAction(UserMetricsAction("NewTab")); 1542 UserMetrics::RecordAction(UserMetricsAction("NewTab"));
1543 1543
1544 if (is_type_tabbed()) { 1544 if (is_type_tabbed()) {
1545 AddBlankTab(true); 1545 AddBlankTab(true);
1546 GetSelectedTabContentsWrapper()->view()->RestoreFocus(); 1546 GetSelectedTabContentsWrapper()->view()->RestoreFocus();
1547 } else { 1547 } else {
1548 Browser* b = GetOrCreateTabbedBrowser(profile_); 1548 Browser* b = GetOrCreateTabbedBrowser(profile_);
1549 b->AddBlankTab(true); 1549 b->AddBlankTab(true);
1550 b->window()->Show(); 1550 b->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
1551 // The call to AddBlankTab above did not set the focus to the tab as its 1551 // The call to AddBlankTab above did not set the focus to the tab as its
1552 // window was not active, so we have to do it explicitly. 1552 // window was not active, so we have to do it explicitly.
1553 // See http://crbug.com/6380. 1553 // See http://crbug.com/6380.
1554 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus(); 1554 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus();
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 void Browser::CloseTab() { 1558 void Browser::CloseTab() {
1559 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator")); 1559 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
1560 if (CanCloseTab()) 1560 if (CanCloseTab())
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 g_browser_process->clipboard()); 1637 g_browser_process->clipboard());
1638 } 1638 }
1639 1639
1640 void Browser::ConvertPopupToTabbedBrowser() { 1640 void Browser::ConvertPopupToTabbedBrowser() {
1641 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); 1641 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"));
1642 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); 1642 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index();
1643 TabContentsWrapper* contents = 1643 TabContentsWrapper* contents =
1644 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); 1644 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index);
1645 Browser* browser = Browser::Create(profile_); 1645 Browser* browser = Browser::Create(profile_);
1646 browser->tabstrip_model()->AppendTabContents(contents, true); 1646 browser->tabstrip_model()->AppendTabContents(contents, true);
1647 browser->window()->Show(); 1647 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
1648 } 1648 }
1649 1649
1650 void Browser::ToggleFullscreenMode() { 1650 void Browser::ToggleFullscreenMode() {
1651 bool entering_fullscreen = !window_->IsFullscreen(); 1651 bool entering_fullscreen = !window_->IsFullscreen();
1652 1652
1653 #if !defined(OS_MACOSX) 1653 #if !defined(OS_MACOSX)
1654 // In kiosk mode, we always want to be fullscreen. When the browser first 1654 // In kiosk mode, we always want to be fullscreen. When the browser first
1655 // starts we're not yet fullscreen, so let the initial toggle go through. 1655 // starts we're not yet fullscreen, so let the initial toggle go through.
1656 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && 1656 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) &&
1657 window_->IsFullscreen()) 1657 window_->IsFullscreen())
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2956 } 2956 }
2957 2957
2958 // Preserve the size of the original window. The new window has already 2958 // Preserve the size of the original window. The new window has already
2959 // been given an offset by the OS, so we shouldn't copy the old bounds. 2959 // been given an offset by the OS, so we shouldn't copy the old bounds.
2960 BrowserWindow* new_window = browser->window(); 2960 BrowserWindow* new_window = browser->window();
2961 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), 2961 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(),
2962 window()->GetRestoredBounds().size())); 2962 window()->GetRestoredBounds().size()));
2963 2963
2964 // We need to show the browser now. Otherwise ContainerWin assumes the 2964 // We need to show the browser now. Otherwise ContainerWin assumes the
2965 // TabContents is invisible and won't size it. 2965 // TabContents is invisible and won't size it.
2966 browser->window()->Show(); 2966 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
2967 2967
2968 // The page transition below is only for the purpose of inserting the tab. 2968 // The page transition below is only for the purpose of inserting the tab.
2969 browser->AddTab(contents_dupe, PageTransition::LINK); 2969 browser->AddTab(contents_dupe, PageTransition::LINK);
2970 } 2970 }
2971 2971
2972 SessionService* session_service = 2972 SessionService* session_service =
2973 SessionServiceFactory::GetForProfileIfExisting(profile_); 2973 SessionServiceFactory::GetForProfileIfExisting(profile_);
2974 if (session_service) 2974 if (session_service)
2975 session_service->TabRestored(contents_dupe, pinned); 2975 session_service->TabRestored(contents_dupe, pinned);
2976 } 2976 }
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3505 Browser* app_browser = Browser::CreateForApp( 3505 Browser* app_browser = Browser::CreateForApp(
3506 TYPE_POPUP, app_name, gfx::Rect(), profile_); 3506 TYPE_POPUP, app_name, gfx::Rect(), profile_);
3507 TabContentsWrapper* wrapper = 3507 TabContentsWrapper* wrapper =
3508 TabContentsWrapper::GetCurrentWrapperForContents(contents); 3508 TabContentsWrapper::GetCurrentWrapperForContents(contents);
3509 if (!wrapper) 3509 if (!wrapper)
3510 wrapper = new TabContentsWrapper(contents); 3510 wrapper = new TabContentsWrapper(contents);
3511 app_browser->tabstrip_model()->AppendTabContents(wrapper, true); 3511 app_browser->tabstrip_model()->AppendTabContents(wrapper, true);
3512 3512
3513 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 3513 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
3514 contents->render_view_host()->SyncRendererPrefs(); 3514 contents->render_view_host()->SyncRendererPrefs();
3515 app_browser->window()->Show(); 3515 app_browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
3516 } 3516 }
3517 3517
3518 void Browser::BeforeUnloadFired(TabContents* tab, 3518 void Browser::BeforeUnloadFired(TabContents* tab,
3519 bool proceed, 3519 bool proceed,
3520 bool* proceed_to_fire_unload) { 3520 bool* proceed_to_fire_unload) {
3521 if (!is_attempting_to_close_browser_) { 3521 if (!is_attempting_to_close_browser_) {
3522 *proceed_to_fire_unload = proceed; 3522 *proceed_to_fire_unload = proceed;
3523 if (!proceed) 3523 if (!proceed)
3524 tab->set_closed_by_user_gesture(false); 3524 tab->set_closed_by_user_gesture(false);
3525 return; 3525 return;
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
5051 Browser* browser = Browser::CreateForType(TYPE_TABBED, profile_); 5051 Browser* browser = Browser::CreateForType(TYPE_TABBED, profile_);
5052 5052
5053 // Preserve the size of the original window. The new window has already 5053 // Preserve the size of the original window. The new window has already
5054 // been given an offset by the OS, so we shouldn't copy the old bounds. 5054 // been given an offset by the OS, so we shouldn't copy the old bounds.
5055 BrowserWindow* new_window = browser->window(); 5055 BrowserWindow* new_window = browser->window();
5056 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), 5056 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(),
5057 window()->GetRestoredBounds().size())); 5057 window()->GetRestoredBounds().size()));
5058 5058
5059 // We need to show the browser now. Otherwise ContainerWin assumes the 5059 // We need to show the browser now. Otherwise ContainerWin assumes the
5060 // TabContents is invisible and won't size it. 5060 // TabContents is invisible and won't size it.
5061 browser->window()->Show(); 5061 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_NORMAL);
5062 5062
5063 // The page transition below is only for the purpose of inserting the tab. 5063 // The page transition below is only for the purpose of inserting the tab.
5064 browser->AddTab(view_source_contents, PageTransition::LINK); 5064 browser->AddTab(view_source_contents, PageTransition::LINK);
5065 } 5065 }
5066 5066
5067 SessionService* session_service = 5067 SessionService* session_service =
5068 SessionServiceFactory::GetForProfileIfExisting(profile_); 5068 SessionServiceFactory::GetForProfileIfExisting(profile_);
5069 if (session_service) 5069 if (session_service)
5070 session_service->TabRestored(view_source_contents, false); 5070 session_service->TabRestored(view_source_contents, false);
5071 } 5071 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5120 } 5120 }
5121 5121
5122 void Browser::ShowSyncSetup() { 5122 void Browser::ShowSyncSetup() {
5123 ProfileSyncService* service = 5123 ProfileSyncService* service =
5124 profile()->GetOriginalProfile()->GetProfileSyncService(); 5124 profile()->GetOriginalProfile()->GetProfileSyncService();
5125 if (service->HasSyncSetupCompleted()) 5125 if (service->HasSyncSetupCompleted())
5126 ShowOptionsTab(chrome::kSyncSetupSubPage); 5126 ShowOptionsTab(chrome::kSyncSetupSubPage);
5127 else 5127 else
5128 service->ShowLoginDialog(); 5128 service->ShowLoginDialog();
5129 } 5129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698