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 "apps/app_shim/app_shim_mac.h" | 7 #include "apps/app_shim/app_shim_mac.h" |
8 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 8 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "chrome/browser/ui/browser.h" | 45 #include "chrome/browser/ui/browser.h" |
46 #include "chrome/browser/ui/browser_command_controller.h" | 46 #include "chrome/browser/ui/browser_command_controller.h" |
47 #include "chrome/browser/ui/browser_commands.h" | 47 #include "chrome/browser/ui/browser_commands.h" |
48 #include "chrome/browser/ui/browser_dialogs.h" | 48 #include "chrome/browser/ui/browser_dialogs.h" |
49 #include "chrome/browser/ui/browser_finder.h" | 49 #include "chrome/browser/ui/browser_finder.h" |
50 #include "chrome/browser/ui/browser_iterator.h" | 50 #include "chrome/browser/ui/browser_iterator.h" |
51 #include "chrome/browser/ui/browser_mac.h" | 51 #include "chrome/browser/ui/browser_mac.h" |
52 #include "chrome/browser/ui/browser_window.h" | 52 #include "chrome/browser/ui/browser_window.h" |
53 #include "chrome/browser/ui/chrome_pages.h" | 53 #include "chrome/browser/ui/chrome_pages.h" |
54 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" | 54 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" |
| 55 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" |
55 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 56 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
56 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 57 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
57 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 58 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
58 #import "chrome/browser/ui/cocoa/confirm_quit.h" | 59 #import "chrome/browser/ui/cocoa/confirm_quit.h" |
59 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 60 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
60 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 61 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
61 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" | 62 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" |
62 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 63 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
63 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" | 64 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
64 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 65 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 365 |
365 - (BOOL)tryToTerminateApplication:(NSApplication*)app { | 366 - (BOOL)tryToTerminateApplication:(NSApplication*)app { |
366 // Check for in-process downloads, and prompt the user if they really want | 367 // Check for in-process downloads, and prompt the user if they really want |
367 // to quit (and thus cancel downloads). Only check if we're not already | 368 // to quit (and thus cancel downloads). Only check if we're not already |
368 // shutting down, else the user might be prompted multiple times if the | 369 // shutting down, else the user might be prompted multiple times if the |
369 // download isn't stopped before terminate is called again. | 370 // download isn't stopped before terminate is called again. |
370 if (!browser_shutdown::IsTryingToQuit() && | 371 if (!browser_shutdown::IsTryingToQuit() && |
371 ![self shouldQuitWithInProgressDownloads]) | 372 ![self shouldQuitWithInProgressDownloads]) |
372 return NO; | 373 return NO; |
373 | 374 |
| 375 // Check for active apps, and prompt the user if they really want to quit |
| 376 // (and also quit the apps). |
| 377 if (!browser_shutdown::IsTryingToQuit() && |
| 378 quitWithAppsController_.get() && !quitWithAppsController_->ShouldQuit()) |
| 379 return NO; |
| 380 |
374 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave | 381 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave |
375 // them in, but I'm not sure about UX; we'd also want to disable other things | 382 // them in, but I'm not sure about UX; we'd also want to disable other things |
376 // though.) http://crbug.com/40861 | 383 // though.) http://crbug.com/40861 |
377 | 384 |
378 // Check if the user really wants to quit by employing the confirm-to-quit | 385 // Check if the user really wants to quit by employing the confirm-to-quit |
379 // mechanism. | 386 // mechanism. |
380 if (!browser_shutdown::IsTryingToQuit() && | 387 if (!browser_shutdown::IsTryingToQuit() && |
381 [self applicationShouldTerminate:app] != NSTerminateNow) | 388 [self applicationShouldTerminate:app] != NSTerminateNow) |
382 return NO; | 389 return NO; |
383 | 390 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // Notify BrowserList to keep the application running so it doesn't go away | 695 // Notify BrowserList to keep the application running so it doesn't go away |
689 // when all the browser windows get closed. | 696 // when all the browser windows get closed. |
690 chrome::IncrementKeepAliveCount(); | 697 chrome::IncrementKeepAliveCount(); |
691 | 698 |
692 [self setUpdateCheckInterval]; | 699 [self setUpdateCheckInterval]; |
693 | 700 |
694 // Start managing the menu for app windows. This needs to be done here because | 701 // Start managing the menu for app windows. This needs to be done here because |
695 // main menu item titles are not yet initialized in awakeFromNib. | 702 // main menu item titles are not yet initialized in awakeFromNib. |
696 [self initAppShimMenuController]; | 703 [self initAppShimMenuController]; |
697 | 704 |
| 705 // If enabled, keep Chrome alive when apps are open instead of quitting all |
| 706 // apps. |
| 707 quitWithAppsController_ = new QuitWithAppsController(); |
| 708 |
698 // Build up the encoding menu, the order of the items differs based on the | 709 // Build up the encoding menu, the order of the items differs based on the |
699 // current locale (see http://crbug.com/7647 for details). | 710 // current locale (see http://crbug.com/7647 for details). |
700 // We need a valid g_browser_process to get the profile which is why we can't | 711 // We need a valid g_browser_process to get the profile which is why we can't |
701 // call this from awakeFromNib. | 712 // call this from awakeFromNib. |
702 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; | 713 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; |
703 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; | 714 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; |
704 NSMenu* encodingMenu = [encodingMenuItem submenu]; | 715 NSMenu* encodingMenu = [encodingMenuItem submenu]; |
705 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], | 716 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], |
706 encodingMenu); | 717 encodingMenu); |
707 | 718 |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 | 1525 |
1515 //--------------------------------------------------------------------------- | 1526 //--------------------------------------------------------------------------- |
1516 | 1527 |
1517 namespace app_controller_mac { | 1528 namespace app_controller_mac { |
1518 | 1529 |
1519 bool IsOpeningNewWindow() { | 1530 bool IsOpeningNewWindow() { |
1520 return g_is_opening_new_window; | 1531 return g_is_opening_new_window; |
1521 } | 1532 } |
1522 | 1533 |
1523 } // namespace app_controller_mac | 1534 } // namespace app_controller_mac |
OLD | NEW |