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 "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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // Check if the user really wants to quit by employing the confirm-to-quit | 423 // Check if the user really wants to quit by employing the confirm-to-quit |
424 // mechanism. | 424 // mechanism. |
425 if (!browser_shutdown::IsTryingToQuit() && | 425 if (!browser_shutdown::IsTryingToQuit() && |
426 [self applicationShouldTerminate:app] != NSTerminateNow) | 426 [self applicationShouldTerminate:app] != NSTerminateNow) |
427 return NO; | 427 return NO; |
428 | 428 |
429 // Check for active apps. If quitting is prevented, only close browsers and | 429 // Check for active apps. If quitting is prevented, only close browsers and |
430 // sessions. | 430 // sessions. |
431 if (!browser_shutdown::IsTryingToQuit() && quitWithAppsController_.get() && | 431 if (!browser_shutdown::IsTryingToQuit() && quitWithAppsController_.get() && |
432 !quitWithAppsController_->ShouldQuit()) { | 432 !quitWithAppsController_->ShouldQuit()) { |
433 if (CommandLine::ForCurrentProcess()->HasSwitch( | 433 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
434 switches::kHostedAppQuitNotification)) { | 434 switches::kHostedAppQuitNotification)) { |
435 return NO; | 435 return NO; |
436 } | 436 } |
437 | 437 |
438 content::NotificationService::current()->Notify( | 438 content::NotificationService::current()->Notify( |
439 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 439 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
440 content::NotificationService::AllSources(), | 440 content::NotificationService::AllSources(), |
441 content::NotificationService::NoDetails()); | 441 content::NotificationService::NoDetails()); |
442 // This will close all browser sessions. | 442 // This will close all browser sessions. |
443 chrome::CloseAllBrowsers(); | 443 chrome::CloseAllBrowsers(); |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 // Return the profile of the last-used BrowserWindowController, if available. | 1380 // Return the profile of the last-used BrowserWindowController, if available. |
1381 if (lastProfile_) | 1381 if (lastProfile_) |
1382 return lastProfile_; | 1382 return lastProfile_; |
1383 | 1383 |
1384 // On first launch, use the logic that ChromeBrowserMain uses to determine | 1384 // On first launch, use the logic that ChromeBrowserMain uses to determine |
1385 // the initial profile. | 1385 // the initial profile. |
1386 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1386 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1387 if (!profile_manager) | 1387 if (!profile_manager) |
1388 return NULL; | 1388 return NULL; |
1389 | 1389 |
1390 return profile_manager->GetProfile(GetStartupProfilePath( | 1390 return profile_manager->GetProfile( |
1391 profile_manager->user_data_dir(), | 1391 GetStartupProfilePath(profile_manager->user_data_dir(), |
1392 *CommandLine::ForCurrentProcess())); | 1392 *base::CommandLine::ForCurrentProcess())); |
1393 } | 1393 } |
1394 | 1394 |
1395 - (Profile*)safeLastProfileForNewWindows { | 1395 - (Profile*)safeLastProfileForNewWindows { |
1396 Profile* profile = [self lastProfile]; | 1396 Profile* profile = [self lastProfile]; |
1397 | 1397 |
1398 // Guest sessions must always be OffTheRecord. Use that when opening windows. | 1398 // Guest sessions must always be OffTheRecord. Use that when opening windows. |
1399 if (profile->IsGuestSession()) | 1399 if (profile->IsGuestSession()) |
1400 return profile->GetOffTheRecordProfile(); | 1400 return profile->GetOffTheRecordProfile(); |
1401 | 1401 |
1402 return profile; | 1402 return profile; |
(...skipping 19 matching lines...) Expand all Loading... |
1422 } | 1422 } |
1423 | 1423 |
1424 Browser* browser = chrome::GetLastActiveBrowser(); | 1424 Browser* browser = chrome::GetLastActiveBrowser(); |
1425 // if no browser window exists then create one with no tabs to be filled in | 1425 // if no browser window exists then create one with no tabs to be filled in |
1426 if (!browser) { | 1426 if (!browser) { |
1427 browser = new Browser(Browser::CreateParams( | 1427 browser = new Browser(Browser::CreateParams( |
1428 [self lastProfile], chrome::HOST_DESKTOP_TYPE_NATIVE)); | 1428 [self lastProfile], chrome::HOST_DESKTOP_TYPE_NATIVE)); |
1429 browser->window()->Show(); | 1429 browser->window()->Show(); |
1430 } | 1430 } |
1431 | 1431 |
1432 CommandLine dummy(CommandLine::NO_PROGRAM); | 1432 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
1433 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 1433 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
1434 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 1434 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
1435 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 1435 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
1436 launch.OpenURLsInBrowser(browser, false, urls, browser->host_desktop_type()); | 1436 launch.OpenURLsInBrowser(browser, false, urls, browser->host_desktop_type()); |
1437 } | 1437 } |
1438 | 1438 |
1439 - (void)getUrl:(NSAppleEventDescriptor*)event | 1439 - (void)getUrl:(NSAppleEventDescriptor*)event |
1440 withReply:(NSAppleEventDescriptor*)reply { | 1440 withReply:(NSAppleEventDescriptor*)reply { |
1441 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] | 1441 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] |
1442 stringValue]; | 1442 stringValue]; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 | 1743 |
1744 //--------------------------------------------------------------------------- | 1744 //--------------------------------------------------------------------------- |
1745 | 1745 |
1746 namespace app_controller_mac { | 1746 namespace app_controller_mac { |
1747 | 1747 |
1748 bool IsOpeningNewWindow() { | 1748 bool IsOpeningNewWindow() { |
1749 return g_is_opening_new_window; | 1749 return g_is_opening_new_window; |
1750 } | 1750 } |
1751 | 1751 |
1752 } // namespace app_controller_mac | 1752 } // namespace app_controller_mac |
OLD | NEW |