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

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

Issue 220373003: Prevent Chrome from quitting when apps are open. (Mac) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 8 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) 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
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/profile_menu_controller.h" 64 #import "chrome/browser/ui/cocoa/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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 364
364 - (BOOL)tryToTerminateApplication:(NSApplication*)app { 365 - (BOOL)tryToTerminateApplication:(NSApplication*)app {
365 // Check for in-process downloads, and prompt the user if they really want 366 // Check for in-process downloads, and prompt the user if they really want
366 // to quit (and thus cancel downloads). Only check if we're not already 367 // to quit (and thus cancel downloads). Only check if we're not already
367 // shutting down, else the user might be prompted multiple times if the 368 // shutting down, else the user might be prompted multiple times if the
368 // download isn't stopped before terminate is called again. 369 // download isn't stopped before terminate is called again.
369 if (!browser_shutdown::IsTryingToQuit() && 370 if (!browser_shutdown::IsTryingToQuit() &&
370 ![self shouldQuitWithInProgressDownloads]) 371 ![self shouldQuitWithInProgressDownloads])
371 return NO; 372 return NO;
372 373
374 // Check for active apps, and prompt the user if they really want to quit
375 // (and also quit the apps).
376 if (!browser_shutdown::IsTryingToQuit() &&
377 quitWithAppsController_.get() && !quitWithAppsController_->ShouldQuit())
378 return NO;
379
373 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave 380 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave
374 // them in, but I'm not sure about UX; we'd also want to disable other things 381 // them in, but I'm not sure about UX; we'd also want to disable other things
375 // though.) http://crbug.com/40861 382 // though.) http://crbug.com/40861
376 383
377 // Check if the user really wants to quit by employing the confirm-to-quit 384 // Check if the user really wants to quit by employing the confirm-to-quit
378 // mechanism. 385 // mechanism.
379 if (!browser_shutdown::IsTryingToQuit() && 386 if (!browser_shutdown::IsTryingToQuit() &&
380 [self applicationShouldTerminate:app] != NSTerminateNow) 387 [self applicationShouldTerminate:app] != NSTerminateNow)
381 return NO; 388 return NO;
382 389
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // Notify BrowserList to keep the application running so it doesn't go away 694 // Notify BrowserList to keep the application running so it doesn't go away
688 // when all the browser windows get closed. 695 // when all the browser windows get closed.
689 chrome::IncrementKeepAliveCount(); 696 chrome::IncrementKeepAliveCount();
690 697
691 [self setUpdateCheckInterval]; 698 [self setUpdateCheckInterval];
692 699
693 // Start managing the menu for app windows. This needs to be done here because 700 // Start managing the menu for app windows. This needs to be done here because
694 // main menu item titles are not yet initialized in awakeFromNib. 701 // main menu item titles are not yet initialized in awakeFromNib.
695 [self initAppShimMenuController]; 702 [self initAppShimMenuController];
696 703
704 // If enabled, keep Chrome alive when apps are open instead of quitting all
705 // apps.
706 quitWithAppsController_ = new QuitWithAppsController();
707
697 // Build up the encoding menu, the order of the items differs based on the 708 // Build up the encoding menu, the order of the items differs based on the
698 // current locale (see http://crbug.com/7647 for details). 709 // current locale (see http://crbug.com/7647 for details).
699 // We need a valid g_browser_process to get the profile which is why we can't 710 // We need a valid g_browser_process to get the profile which is why we can't
700 // call this from awakeFromNib. 711 // call this from awakeFromNib.
701 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; 712 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu];
702 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; 713 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU];
703 NSMenu* encodingMenu = [encodingMenuItem submenu]; 714 NSMenu* encodingMenu = [encodingMenuItem submenu];
704 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], 715 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
705 encodingMenu); 716 encodingMenu);
706 717
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 1496
1486 //--------------------------------------------------------------------------- 1497 //---------------------------------------------------------------------------
1487 1498
1488 namespace app_controller_mac { 1499 namespace app_controller_mac {
1489 1500
1490 bool IsOpeningNewWindow() { 1501 bool IsOpeningNewWindow() {
1491 return g_is_opening_new_window; 1502 return g_is_opening_new_window;
1492 } 1503 }
1493 1504
1494 } // namespace app_controller_mac 1505 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698