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

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

Issue 23301018: Add quit item to app menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h » ('j') | no next file with comments »
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 "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Reset the "trying to quit" state, so that closing all browser windows 375 // Reset the "trying to quit" state, so that closing all browser windows
376 // will no longer lead to termination. 376 // will no longer lead to termination.
377 browser_shutdown::SetTryingToQuit(false); 377 browser_shutdown::SetTryingToQuit(false);
378 378
379 // TODO(viettrungluu): Were we to remove Apple Event handlers above, we 379 // TODO(viettrungluu): Were we to remove Apple Event handlers above, we
380 // would have to reinstall them here. http://crbug.com/40861 380 // would have to reinstall them here. http://crbug.com/40861
381 } 381 }
382 } 382 }
383 383
384 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app { 384 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app {
385 using apps::ShellWindowRegistry;
386
387 // If there are no windows, quit immediately. 385 // If there are no windows, quit immediately.
388 if (chrome::BrowserIterator().done() && 386 if (chrome::BrowserIterator().done() &&
389 !ShellWindowRegistry::IsShellWindowRegisteredInAnyProfile(0)) { 387 !apps::ShellWindowRegistry::IsShellWindowRegisteredInAnyProfile(0)) {
390 return NSTerminateNow; 388 return NSTerminateNow;
391 } 389 }
392 390
393 // Check if this is a keyboard initiated quit on an app window. If so, quit
394 // the app. This could cause the app to trigger another terminate, but that
395 // will be caught by the no windows condition above.
396 if ([[app currentEvent] type] == NSKeyDown) {
397 apps::ShellWindow* shellWindow =
398 ShellWindowRegistry::GetShellWindowForNativeWindowAnyProfile(
399 [app keyWindow]);
400 if (shellWindow) {
401 apps::ExtensionAppShimHandler::QuitAppForWindow(shellWindow);
402 return NSTerminateCancel;
403 }
404 }
405
406 // Check if the preference is turned on. 391 // Check if the preference is turned on.
407 const PrefService* prefs = g_browser_process->local_state(); 392 const PrefService* prefs = g_browser_process->local_state();
408 if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) { 393 if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) {
409 confirm_quit::RecordHistogram(confirm_quit::kNoConfirm); 394 confirm_quit::RecordHistogram(confirm_quit::kNoConfirm);
410 return NSTerminateNow; 395 return NSTerminateNow;
411 } 396 }
412 397
413 // If the application is going to terminate as the result of a Cmd+Q 398 // If the application is going to terminate as the result of a Cmd+Q
414 // invocation, use the special sauce to prevent accidental quitting. 399 // invocation, use the special sauce to prevent accidental quitting.
415 // http://dev.chromium.org/developers/design-documents/confirm-to-quit-experim ent 400 // http://dev.chromium.org/developers/design-documents/confirm-to-quit-experim ent
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1416
1432 //--------------------------------------------------------------------------- 1417 //---------------------------------------------------------------------------
1433 1418
1434 namespace app_controller_mac { 1419 namespace app_controller_mac {
1435 1420
1436 bool IsOpeningNewWindow() { 1421 bool IsOpeningNewWindow() {
1437 return g_is_opening_new_window; 1422 return g_is_opening_new_window;
1438 } 1423 }
1439 1424
1440 } // namespace app_controller_mac 1425 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698