| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (browser) | 132 if (browser) |
| 133 browser->window()->Activate(); | 133 browser->window()->Activate(); |
| 134 return browser; | 134 return browser; |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Creates an empty browser window with the given profile and returns a pointer | 137 // Creates an empty browser window with the given profile and returns a pointer |
| 138 // to the new |Browser|. | 138 // to the new |Browser|. |
| 139 Browser* CreateBrowser(Profile* profile) { | 139 Browser* CreateBrowser(Profile* profile) { |
| 140 { | 140 { |
| 141 base::AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); | 141 base::AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); |
| 142 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | 142 chrome::NewEmptyWindow(profile); |
| 143 } | 143 } |
| 144 | 144 |
| 145 Browser* browser = chrome::GetLastActiveBrowser(); | 145 Browser* browser = chrome::GetLastActiveBrowser(); |
| 146 CHECK(browser); | 146 CHECK(browser); |
| 147 return browser; | 147 return browser; |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Activates a browser window having the given profile (the last one active) if | 150 // Activates a browser window having the given profile (the last one active) if |
| 151 // possible or creates an empty one if necessary. Returns a pointer to the | 151 // possible or creates an empty one if necessary. Returns a pointer to the |
| 152 // activated/new |Browser|. | 152 // activated/new |Browser|. |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 (download_service->HasCreatedDownloadManager() ? | 844 (download_service->HasCreatedDownloadManager() ? |
| 845 BrowserContext::GetDownloadManager(profiles[i]) : NULL); | 845 BrowserContext::GetDownloadManager(profiles[i]) : NULL); |
| 846 if (download_manager && | 846 if (download_manager && |
| 847 download_manager->NonMaliciousInProgressCount() > 0) { | 847 download_manager->NonMaliciousInProgressCount() > 0) { |
| 848 int downloadCount = download_manager->NonMaliciousInProgressCount(); | 848 int downloadCount = download_manager->NonMaliciousInProgressCount(); |
| 849 if ([self userWillWaitForInProgressDownloads:downloadCount]) { | 849 if ([self userWillWaitForInProgressDownloads:downloadCount]) { |
| 850 // Create a new browser window (if necessary) and navigate to the | 850 // Create a new browser window (if necessary) and navigate to the |
| 851 // downloads page if the user chooses to wait. | 851 // downloads page if the user chooses to wait. |
| 852 Browser* browser = chrome::FindBrowserWithProfile(profiles[i]); | 852 Browser* browser = chrome::FindBrowserWithProfile(profiles[i]); |
| 853 if (!browser) { | 853 if (!browser) { |
| 854 browser = new Browser(Browser::CreateParams( | 854 browser = new Browser(Browser::CreateParams(profiles[i])); |
| 855 profiles[i], chrome::HOST_DESKTOP_TYPE_NATIVE)); | |
| 856 browser->window()->Show(); | 855 browser->window()->Show(); |
| 857 } | 856 } |
| 858 DCHECK(browser); | 857 DCHECK(browser); |
| 859 chrome::ShowDownloads(browser); | 858 chrome::ShowDownloads(browser); |
| 860 return NO; | 859 return NO; |
| 861 } | 860 } |
| 862 | 861 |
| 863 // User wants to exit. | 862 // User wants to exit. |
| 864 return YES; | 863 return YES; |
| 865 } | 864 } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 // to bottleneck the openings through that for uniform handling. | 1364 // to bottleneck the openings through that for uniform handling. |
| 1366 - (void)openUrls:(const std::vector<GURL>&)urls { | 1365 - (void)openUrls:(const std::vector<GURL>&)urls { |
| 1367 if (!startupComplete_) { | 1366 if (!startupComplete_) { |
| 1368 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); | 1367 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); |
| 1369 return; | 1368 return; |
| 1370 } | 1369 } |
| 1371 | 1370 |
| 1372 Browser* browser = chrome::GetLastActiveBrowser(); | 1371 Browser* browser = chrome::GetLastActiveBrowser(); |
| 1373 // if no browser window exists then create one with no tabs to be filled in | 1372 // if no browser window exists then create one with no tabs to be filled in |
| 1374 if (!browser) { | 1373 if (!browser) { |
| 1375 browser = new Browser(Browser::CreateParams( | 1374 browser = new Browser(Browser::CreateParams([self lastProfile])); |
| 1376 [self lastProfile], chrome::HOST_DESKTOP_TYPE_NATIVE)); | |
| 1377 browser->window()->Show(); | 1375 browser->window()->Show(); |
| 1378 } | 1376 } |
| 1379 | 1377 |
| 1380 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 1378 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
| 1381 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 1379 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 1382 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 1380 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| 1383 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 1381 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
| 1384 launch.OpenURLsInBrowser(browser, false, urls, browser->host_desktop_type()); | 1382 launch.OpenURLsInBrowser(browser, false, urls, browser->host_desktop_type()); |
| 1385 } | 1383 } |
| 1386 | 1384 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 | 1695 |
| 1698 //--------------------------------------------------------------------------- | 1696 //--------------------------------------------------------------------------- |
| 1699 | 1697 |
| 1700 namespace app_controller_mac { | 1698 namespace app_controller_mac { |
| 1701 | 1699 |
| 1702 bool IsOpeningNewWindow() { | 1700 bool IsOpeningNewWindow() { |
| 1703 return g_is_opening_new_window; | 1701 return g_is_opening_new_window; |
| 1704 } | 1702 } |
| 1705 | 1703 |
| 1706 } // namespace app_controller_mac | 1704 } // namespace app_controller_mac |
| OLD | NEW |