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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 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
« no previous file with comments | « no previous file | chrome/browser/apps/app_browsertest.cc » ('j') | ui/gfx/host_desktop_type.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // make a new window while there are no other active windows. 119 // make a new window while there are no other active windows.
120 bool g_is_opening_new_window = false; 120 bool g_is_opening_new_window = false;
121 121
122 // Activates a browser window having the given profile (the last one active) if 122 // Activates a browser window having the given profile (the last one active) if
123 // possible and returns a pointer to the activate |Browser| or NULL if this was 123 // possible and returns a pointer to the activate |Browser| or NULL if this was
124 // not possible. If the last active browser is minimized (in particular, if 124 // not possible. If the last active browser is minimized (in particular, if
125 // there are only minimized windows), it will unminimize it. 125 // there are only minimized windows), it will unminimize it.
126 Browser* ActivateBrowser(Profile* profile) { 126 Browser* ActivateBrowser(Profile* profile) {
127 Browser* browser = chrome::FindLastActiveWithProfile( 127 Browser* browser = chrome::FindLastActiveWithProfile(
128 profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : profile, 128 profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : profile,
129 chrome::HOST_DESKTOP_TYPE_NATIVE); 129 ui::HOST_DESKTOP_TYPE_NATIVE);
130 if (browser) 130 if (browser)
131 browser->window()->Activate(); 131 browser->window()->Activate();
132 return browser; 132 return browser;
133 } 133 }
134 134
135 // Creates an empty browser window with the given profile and returns a pointer 135 // Creates an empty browser window with the given profile and returns a pointer
136 // to the new |Browser|. 136 // to the new |Browser|.
137 Browser* CreateBrowser(Profile* profile) { 137 Browser* CreateBrowser(Profile* profile) {
138 { 138 {
139 base::AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); 139 base::AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true);
140 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE); 140 chrome::NewEmptyWindow(profile, ui::HOST_DESKTOP_TYPE_NATIVE);
141 } 141 }
142 142
143 Browser* browser = chrome::GetLastActiveBrowser(); 143 Browser* browser = chrome::GetLastActiveBrowser();
144 CHECK(browser); 144 CHECK(browser);
145 return browser; 145 return browser;
146 } 146 }
147 147
148 // Activates a browser window having the given profile (the last one active) if 148 // Activates a browser window having the given profile (the last one active) if
149 // possible or creates an empty one if necessary. Returns a pointer to the 149 // possible or creates an empty one if necessary. Returns a pointer to the
150 // activated/new |Browser|. 150 // activated/new |Browser|.
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 [self unregisterEventHandlers]; 528 [self unregisterEventHandlers];
529 529
530 appShimMenuController_.reset(); 530 appShimMenuController_.reset();
531 531
532 STLDeleteContainerPairSecondPointers(profileBookmarkMenuBridgeMap_.begin(), 532 STLDeleteContainerPairSecondPointers(profileBookmarkMenuBridgeMap_.begin(),
533 profileBookmarkMenuBridgeMap_.end()); 533 profileBookmarkMenuBridgeMap_.end());
534 } 534 }
535 535
536 - (void)didEndMainMessageLoop { 536 - (void)didEndMainMessageLoop {
537 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile], 537 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile],
538 chrome::HOST_DESKTOP_TYPE_NATIVE)); 538 ui::HOST_DESKTOP_TYPE_NATIVE));
539 if (!chrome::GetBrowserCount([self lastProfile], 539 if (!chrome::GetBrowserCount([self lastProfile],
540 chrome::HOST_DESKTOP_TYPE_NATIVE)) { 540 ui::HOST_DESKTOP_TYPE_NATIVE)) {
541 // As we're shutting down, we need to nuke the TabRestoreService, which 541 // As we're shutting down, we need to nuke the TabRestoreService, which
542 // will start the shutdown of the NavigationControllers and allow for 542 // will start the shutdown of the NavigationControllers and allow for
543 // proper shutdown. If we don't do this, Chrome won't shut down cleanly, 543 // proper shutdown. If we don't do this, Chrome won't shut down cleanly,
544 // and may end up crashing when some thread tries to use the IO thread (or 544 // and may end up crashing when some thread tries to use the IO thread (or
545 // another thread) that is no longer valid. 545 // another thread) that is no longer valid.
546 TabRestoreServiceFactory::ResetForProfile([self lastProfile]); 546 TabRestoreServiceFactory::ResetForProfile([self lastProfile]);
547 } 547 }
548 } 548 }
549 549
550 // If the window has a tab controller, make "close window" be cmd-shift-w, 550 // If the window has a tab controller, make "close window" be cmd-shift-w,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 BrowserThread::PostTask( 771 BrowserThread::PostTask(
772 BrowserThread::FILE, FROM_HERE, 772 BrowserThread::FILE, FROM_HERE,
773 base::Bind(&RecordLastRunAppBundlePath)); 773 base::Bind(&RecordLastRunAppBundlePath));
774 774
775 // Makes "Services" menu items available. 775 // Makes "Services" menu items available.
776 [self registerServicesMenuTypesTo:[notify object]]; 776 [self registerServicesMenuTypesTo:[notify object]];
777 777
778 startupComplete_ = YES; 778 startupComplete_ = YES;
779 779
780 Browser* browser = 780 Browser* browser =
781 FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_NATIVE); 781 chrome::FindLastActiveWithHostDesktopType(ui::HOST_DESKTOP_TYPE_NATIVE);
782 content::WebContents* activeWebContents = nullptr; 782 content::WebContents* activeWebContents = nullptr;
783 if (browser) 783 if (browser)
784 activeWebContents = browser->tab_strip_model()->GetActiveWebContents(); 784 activeWebContents = browser->tab_strip_model()->GetActiveWebContents();
785 [self updateHandoffManager:activeWebContents]; 785 [self updateHandoffManager:activeWebContents];
786 [self openStartupUrls]; 786 [self openStartupUrls];
787 787
788 PrefService* localState = g_browser_process->local_state(); 788 PrefService* localState = g_browser_process->local_state();
789 if (localState) { 789 if (localState) {
790 localPrefRegistrar_.Init(localState); 790 localPrefRegistrar_.Init(localState);
791 localPrefRegistrar_.Add( 791 localPrefRegistrar_.Add(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 DownloadManager* download_manager = 847 DownloadManager* download_manager =
848 (download_service->HasCreatedDownloadManager() ? 848 (download_service->HasCreatedDownloadManager() ?
849 BrowserContext::GetDownloadManager(profiles[i]) : NULL); 849 BrowserContext::GetDownloadManager(profiles[i]) : NULL);
850 if (download_manager && 850 if (download_manager &&
851 download_manager->NonMaliciousInProgressCount() > 0) { 851 download_manager->NonMaliciousInProgressCount() > 0) {
852 int downloadCount = download_manager->NonMaliciousInProgressCount(); 852 int downloadCount = download_manager->NonMaliciousInProgressCount();
853 if ([self userWillWaitForInProgressDownloads:downloadCount]) { 853 if ([self userWillWaitForInProgressDownloads:downloadCount]) {
854 // Create a new browser window (if necessary) and navigate to the 854 // Create a new browser window (if necessary) and navigate to the
855 // downloads page if the user chooses to wait. 855 // downloads page if the user chooses to wait.
856 Browser* browser = chrome::FindBrowserWithProfile( 856 Browser* browser = chrome::FindBrowserWithProfile(
857 profiles[i], chrome::HOST_DESKTOP_TYPE_NATIVE); 857 profiles[i], ui::HOST_DESKTOP_TYPE_NATIVE);
858 if (!browser) { 858 if (!browser) {
859 browser = new Browser(Browser::CreateParams( 859 browser = new Browser(
860 profiles[i], chrome::HOST_DESKTOP_TYPE_NATIVE)); 860 Browser::CreateParams(profiles[i], ui::HOST_DESKTOP_TYPE_NATIVE));
861 browser->window()->Show(); 861 browser->window()->Show();
862 } 862 }
863 DCHECK(browser); 863 DCHECK(browser);
864 chrome::ShowDownloads(browser); 864 chrome::ShowDownloads(browser);
865 return NO; 865 return NO;
866 } 866 }
867 867
868 // User wants to exit. 868 // User wants to exit.
869 return YES; 869 return YES;
870 } 870 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 case IDC_FOCUS_SEARCH: 1067 case IDC_FOCUS_SEARCH:
1068 chrome::ExecuteCommand(ActivateOrCreateBrowser(lastProfile), 1068 chrome::ExecuteCommand(ActivateOrCreateBrowser(lastProfile),
1069 IDC_FOCUS_SEARCH); 1069 IDC_FOCUS_SEARCH);
1070 break; 1070 break;
1071 case IDC_NEW_INCOGNITO_WINDOW: 1071 case IDC_NEW_INCOGNITO_WINDOW:
1072 CreateBrowser(lastProfile->GetOffTheRecordProfile()); 1072 CreateBrowser(lastProfile->GetOffTheRecordProfile());
1073 break; 1073 break;
1074 case IDC_RESTORE_TAB: 1074 case IDC_RESTORE_TAB:
1075 // There is only the native desktop on Mac. 1075 // There is only the native desktop on Mac.
1076 chrome::OpenWindowWithRestoredTabs(lastProfile, 1076 chrome::OpenWindowWithRestoredTabs(lastProfile,
1077 chrome::HOST_DESKTOP_TYPE_NATIVE); 1077 ui::HOST_DESKTOP_TYPE_NATIVE);
1078 break; 1078 break;
1079 case IDC_OPEN_FILE: 1079 case IDC_OPEN_FILE:
1080 chrome::ExecuteCommand(CreateBrowser(lastProfile), IDC_OPEN_FILE); 1080 chrome::ExecuteCommand(CreateBrowser(lastProfile), IDC_OPEN_FILE);
1081 break; 1081 break;
1082 case IDC_CLEAR_BROWSING_DATA: { 1082 case IDC_CLEAR_BROWSING_DATA: {
1083 // There may not be a browser open, so use the default profile. 1083 // There may not be a browser open, so use the default profile.
1084 if (Browser* browser = ActivateBrowser(lastProfile)) { 1084 if (Browser* browser = ActivateBrowser(lastProfile)) {
1085 chrome::ShowClearBrowsingDataDialog(browser); 1085 chrome::ShowClearBrowsingDataDialog(browser);
1086 } else { 1086 } else {
1087 chrome::OpenClearBrowsingDataDialogWindow(lastProfile); 1087 chrome::OpenClearBrowsingDataDialogWindow(lastProfile);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 // to bottleneck the openings through that for uniform handling. 1382 // to bottleneck the openings through that for uniform handling.
1383 - (void)openUrls:(const std::vector<GURL>&)urls { 1383 - (void)openUrls:(const std::vector<GURL>&)urls {
1384 if (!startupComplete_) { 1384 if (!startupComplete_) {
1385 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); 1385 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end());
1386 return; 1386 return;
1387 } 1387 }
1388 1388
1389 Browser* browser = chrome::GetLastActiveBrowser(); 1389 Browser* browser = chrome::GetLastActiveBrowser();
1390 // if no browser window exists then create one with no tabs to be filled in 1390 // if no browser window exists then create one with no tabs to be filled in
1391 if (!browser) { 1391 if (!browser) {
1392 browser = new Browser(Browser::CreateParams( 1392 browser = new Browser(Browser::CreateParams([self lastProfile],
1393 [self lastProfile], chrome::HOST_DESKTOP_TYPE_NATIVE)); 1393 ui::HOST_DESKTOP_TYPE_NATIVE));
1394 browser->window()->Show(); 1394 browser->window()->Show();
1395 } 1395 }
1396 1396
1397 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 1397 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
1398 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 1398 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
1399 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 1399 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
1400 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 1400 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
1401 launch.OpenURLsInBrowser(browser, false, urls, browser->host_desktop_type()); 1401 launch.OpenURLsInBrowser(browser, false, urls, browser->host_desktop_type());
1402 } 1402 }
1403 1403
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 1720
1721 //--------------------------------------------------------------------------- 1721 //---------------------------------------------------------------------------
1722 1722
1723 namespace app_controller_mac { 1723 namespace app_controller_mac {
1724 1724
1725 bool IsOpeningNewWindow() { 1725 bool IsOpeningNewWindow() {
1726 return g_is_opening_new_window; 1726 return g_is_opening_new_window;
1727 } 1727 }
1728 1728
1729 } // namespace app_controller_mac 1729 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/apps/app_browsertest.cc » ('j') | ui/gfx/host_desktop_type.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698