summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-21 20:58:48 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-21 20:58:48 +0000
commita99fce0ea927c4040410566b7c6a31049a9d9811 (patch)
treeb254206eb05db424f05155aa79d2cf2694f195d1 /chrome
parent89f5aa8cd1f29a63a989907c454495993659854e (diff)
downloadchromium_src-a99fce0ea927c4040410566b7c6a31049a9d9811.zip
chromium_src-a99fce0ea927c4040410566b7c6a31049a9d9811.tar.gz
chromium_src-a99fce0ea927c4040410566b7c6a31049a9d9811.tar.bz2
[Mac] Confirm-to-quit: Add an option in the app menu.
This option is off by default. This CL also removes the command line flag and the about:flags strings. XIB changes: * Add a new menu item and separator. * Wire up the menu item to -[AppController toggleConfirmToQuit:] BUG=60591 TEST=Go to Chromium menu. See "Warn Before Quitting (Cmd+Q)". Select it to enable/disable. Feature works as before, respecting this flag. Review URL: http://codereview.chromium.org/6708058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/app/nibs/MainMenu.xib81
-rw-r--r--chrome/browser/app_controller_mac.h5
-rw-r--r--chrome/browser/app_controller_mac.mm35
-rw-r--r--chrome/browser/sync/glue/preference_change_processor.cc2
-rw-r--r--chrome/browser/sync/glue/synchronized_preferences.h3
-rw-r--r--chrome/browser/ui/browser.cc1
-rw-r--r--chrome/browser/ui/cocoa/confirm_quit_panel_controller.h5
-rw-r--r--chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm9
-rw-r--r--chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm3
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/pref_names.cc4
-rw-r--r--chrome/common/pref_names.h1
14 files changed, 118 insertions, 44 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 099fb55..493c2a5 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4131,12 +4131,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_PAGE_PRERENDER_DISABLED" desc="Option name for always disabling the 'Prerendering' lab">
Always Disabled
</message>
- <message name="IDS_FLAGS_CONFIRM_TO_QUIT_NAME" desc="Name of the 'Confirm to Quit' lab.">
- Confirm to Quit
- </message>
- <message name="IDS_FLAGS_CONFIRM_TO_QUIT_DESCRIPTION" desc="Description of the 'Confirm to Quit' lab.">
- Receive a prompt before quitting to confirm the action.
- </message>
<message name="IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME" desc="Name of the 'Experimental Extension APIs' lab.">
Experimental Extension APIs
</message>
@@ -4775,6 +4769,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_CONFIRM_TO_QUIT_DESCRIPTION" desc="Instructions for how the user should confirm quitting.">
Hold <ph name="KEY_EQUIVALENT">$1<ex>⌘Q</ex></ph> to Quit.
</message>
+ <message name="IDS_CONFIRM_TO_QUIT_OPTION" desc="The label of the checkbox preference that enables the confirm-to-quit feature.">
+ Warn Before Quitting (<ph name="KEY_EQUIVALENT">$1<ex>⌘Q</ex></ph>)
+ </message>
<!-- Importer Lock Dialog -->
<message name="IDS_IMPORTER_LOCK_TITLE" desc="Dialog title for importer lock dialog">
diff --git a/chrome/app/nibs/MainMenu.xib b/chrome/app/nibs/MainMenu.xib
index 84553059..fb46027 100644
--- a/chrome/app/nibs/MainMenu.xib
+++ b/chrome/app/nibs/MainMenu.xib
@@ -2,17 +2,17 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">10F2108</string>
+ <string key="IBDocument.SystemVersion">10J567</string>
<string key="IBDocument.InterfaceBuilderVersion">823</string>
- <string key="IBDocument.AppKitVersion">1038.29</string>
- <string key="IBDocument.HIToolboxVersion">461.00</string>
+ <string key="IBDocument.AppKitVersion">1038.35</string>
+ <string key="IBDocument.HIToolboxVersion">462.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">823</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="24"/>
+ <integer value="57"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -197,6 +197,24 @@
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
</object>
+ <object class="NSMenuItem" id="140035077">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">^IDS_CONFIRM_TO_QUIT_OPTION</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="353210768"/>
+ <reference key="NSMixedImage" ref="549394948"/>
+ </object>
+ <object class="NSMenuItem" id="276231874">
+ <reference key="NSMenu" ref="110575045"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="353210768"/>
+ <reference key="NSMixedImage" ref="549394948"/>
+ </object>
<object class="NSMenuItem" id="632727374">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">^IDS_EXIT_MAC$IDS_PRODUCT_NAME</string>
@@ -1772,6 +1790,14 @@
</object>
<int key="connectionID">685</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">toggleConfirmToQuit:</string>
+ <reference key="source" ref="168151378"/>
+ <reference key="destination" ref="140035077"/>
+ </object>
+ <int key="connectionID">688</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2105,6 +2131,8 @@
<reference ref="198763083"/>
<reference ref="198763083"/>
<reference ref="214319129"/>
+ <reference ref="276231874"/>
+ <reference ref="140035077"/>
</object>
<reference key="parent" ref="694149608"/>
</object>
@@ -2628,6 +2656,16 @@
<reference key="object" ref="693413486"/>
<reference key="parent" ref="835318025"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">686</int>
+ <reference key="object" ref="276231874"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">687</int>
+ <reference key="object" ref="140035077"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -2820,6 +2858,8 @@
<string>674.IBPluginDependency</string>
<string>676.IBPluginDependency</string>
<string>682.IBPluginDependency</string>
+ <string>686.IBPluginDependency</string>
+ <string>687.IBPluginDependency</string>
<string>72.IBPluginDependency</string>
<string>72.ImportedFromIB2</string>
<string>73.IBPluginDependency</string>
@@ -2896,7 +2936,7 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{744, 1273}, {358, 243}}</string>
+ <string>{{517, 94}, {358, 243}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{197, 734}, {243, 243}}</string>
@@ -2936,17 +2976,17 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{1292, 763}, {323, 223}}</string>
+ <string>{{1292, 114}, {323, 223}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{525, 802}, {197, 73}}</string>
- <string>{{102, 986}, {1578, 20}}</string>
+ <string>{{102, 337}, {1578, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{74, 862}</string>
<string>{{11, 977}, {478, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{916, 1283}, {399, 233}}</string>
+ <string>{{689, 104}, {399, 233}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{475, 832}, {234, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2985,7 +3025,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{824, 337}, {301, 153}}</string>
+ <string>{{863, 184}, {301, 153}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -3003,7 +3043,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{111, 358}, {382, 253}}</string>
+ <string>{{114, 54}, {388, 283}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{23, 794}, {245, 183}}</string>
@@ -3032,6 +3072,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@@ -3043,7 +3085,7 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{576, 1233}, {350, 283}}</string>
+ <string>{{349, 54}, {350, 283}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{323, 672}, {199, 203}}</string>
@@ -3071,7 +3113,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">685</int>
+ <int key="maxID">688</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3085,11 +3127,13 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>orderFrontStandardAboutPanel:</string>
<string>showPreferences:</string>
+ <string>toggleConfirmToQuit:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@@ -3098,6 +3142,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>orderFrontStandardAboutPanel:</string>
<string>showPreferences:</string>
+ <string>toggleConfirmToQuit:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -3109,6 +3154,10 @@
<string key="name">showPreferences:</string>
<string key="candidateClassName">id</string>
</object>
+ <object class="IBActionInfo">
+ <string key="name">toggleConfirmToQuit:</string>
+ <string key="candidateClassName">id</string>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -3197,14 +3246,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">CrApplication</string>
- <string key="superclassName">NSApplication</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">common/chrome_application_mac.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">DownloadShelfController</string>
<string key="superclassName">NSViewController</string>
<object class="NSMutableDictionary" key="actions">
diff --git a/chrome/browser/app_controller_mac.h b/chrome/browser/app_controller_mac.h
index d80daea..e9235d6 100644
--- a/chrome/browser/app_controller_mac.h
+++ b/chrome/browser/app_controller_mac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -80,6 +80,9 @@ class Profile;
// Owner" (NSAppliation) for a Branded About Box
- (IBAction)orderFrontStandardAboutPanel:(id)sender;
+// Toggles the "Confirm to Quit" preference.
+- (IBAction)toggleConfirmToQuit:(id)sender;
+
// Delegate method to return the dock menu.
- (NSMenu*)applicationDockMenu:(NSApplication*)sender;
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index c4de5e4..ce5f7b5 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -20,6 +20,7 @@
#include "chrome/browser/fonts_languages_window.h"
#include "chrome/browser/instant/instant_confirm_dialog.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/session_service.h"
@@ -46,6 +47,7 @@
#include "chrome/common/app_mode_common_mac.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/browser/browser_thread.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -141,8 +143,9 @@ void RecordLastRunAppBundlePath() {
} // anonymous namespace
-@interface AppController(Private)
+@interface AppController (Private)
- (void)initMenuState;
+- (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item;
- (void)registerServicesMenuTypesTo:(NSApplication*)app;
- (void)openUrls:(const std::vector<GURL>&)urls;
- (void)getUrl:(NSAppleEventDescriptor*)event
@@ -273,9 +276,9 @@ void RecordLastRunAppBundlePath() {
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app {
- // Check if the experiment is enabled.
- const CommandLine* commandLine(CommandLine::ForCurrentProcess());
- if (commandLine->HasSwitch(switches::kDisableConfirmToQuit))
+ // Check if the preference is turned on.
+ const PrefService* prefs = [self defaultProfile]->GetPrefs();
+ if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled))
return NSTerminateNow;
// If the application is going to terminate as the result of a Cmd+Q
@@ -709,6 +712,9 @@ void RecordLastRunAppBundlePath() {
enable = YES;
} else if (action == @selector(commandFromDock:)) {
enable = YES;
+ } else if (action == @selector(toggleConfirmToQuit:)) {
+ [self updateConfirmToQuitPrefMenuItem:static_cast<NSMenuItem*>(item)];
+ enable = YES;
}
return enable;
}
@@ -954,6 +960,21 @@ void RecordLastRunAppBundlePath() {
menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true);
}
+// The Confirm to Quit preference is atypical in that the preference lives in
+// the app menu right above the Quit menu item. This method will refresh the
+// display of that item depending on the preference state.
+- (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item {
+ // Format the string so that the correct key equivalent is displayed.
+ NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString];
+ NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION,
+ base::SysNSStringToUTF16(acceleratorString));
+ [item setTitle:title];
+
+ const PrefService* prefService = [self defaultProfile]->GetPrefs();
+ bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled);
+ [item setState:enabled ? NSOnState : NSOffState];
+}
+
- (void)registerServicesMenuTypesTo:(NSApplication*)app {
// Note that RenderWidgetHostViewCocoa implements NSServicesRequests which
// handles requests from services.
@@ -1063,6 +1084,12 @@ void RecordLastRunAppBundlePath() {
[aboutController_ showWindow:self];
}
+- (IBAction)toggleConfirmToQuit:(id)sender {
+ PrefService* prefService = [self defaultProfile]->GetPrefs();
+ bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled);
+ prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled);
+}
+
// Explicitly bring to the foreground when creating new windows from the dock.
- (void)commandFromDock:(id)sender {
[NSApp activateIgnoringOtherApps:YES];
diff --git a/chrome/browser/sync/glue/preference_change_processor.cc b/chrome/browser/sync/glue/preference_change_processor.cc
index c04997f..ab78907 100644
--- a/chrome/browser/sync/glue/preference_change_processor.cc
+++ b/chrome/browser/sync/glue/preference_change_processor.cc
@@ -143,7 +143,7 @@ void PreferenceChangeProcessor::ApplyChangesFromSyncModel(
// It is possible that we may receive a change to a preference we
// do not want to sync. For example if the user is syncing a Mac
// client and a Windows client, the Windows client does not
- // support kShowPageOptionsButtons. Ignore updates from these
+ // support kConfirmToQuitEnabled. Ignore updates from these
// preferences.
const char* pref_name = name.c_str();
if (model_associator_->synced_preferences().count(pref_name) == 0)
diff --git a/chrome/browser/sync/glue/synchronized_preferences.h b/chrome/browser/sync/glue/synchronized_preferences.h
index 7f47767..f541e36 100644
--- a/chrome/browser/sync/glue/synchronized_preferences.h
+++ b/chrome/browser/sync/glue/synchronized_preferences.h
@@ -112,6 +112,9 @@ static const char* kSynchronizedPreferences[] = {
// Cookie prompt dialog.
prefs::kCookiePromptExpanded,
+ // (Mac) Application menu.
+ prefs::kConfirmToQuitEnabled,
+
#if defined(OS_CHROMEOS)
// IME prefs
prefs::kLanguageChewingAddPhraseDirection,
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 07306c6..22aada8 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -2052,6 +2052,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
// pref to be already initialized. Doing it here also saves us from having
// to hard-code pref registration in the several unit tests that use
// this preference.
+ prefs->RegisterBooleanPref(prefs::kConfirmToQuitEnabled, false);
prefs->RegisterBooleanPref(prefs::kShowUpdatePromotionInfoBar, true);
#endif
prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, "");
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
index be56941..88b66f3 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.h
@@ -42,10 +42,13 @@
// Returns the Accelerator for the Quit menu item.
+ (ui::AcceleratorCocoa)quitAccelerator;
+// Returns a string representation fit for display of |+quitAccelerator|.
++ (NSString*)keyCommandString;
+
@end
@interface ConfirmQuitPanelController (UnitTesting)
-- (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item;
++ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item;
@end
#endif // CHROME_BROWSER_UI_COCOA_CONFIRM_QUIT_PANEL_CONTROLLER_H_
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
index 2a98357..71841d0 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm
@@ -101,7 +101,6 @@ const NSTimeInterval kWindowFadeAnimationDuration = 0.2;
@interface ConfirmQuitPanelController (Private)
- (void)animateFadeOut;
-- (NSString*)keyCommandString;
- (NSEvent*)pumpEventQueueForKeyUp:(NSApplication*)app untilDate:(NSDate*)date;
- (void)hideAllWindowsForApplication:(NSApplication*)app
withDuration:(NSTimeInterval)duration;
@@ -143,7 +142,7 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
// Set the proper string.
NSString* message = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_DESCRIPTION,
- base::SysNSStringToUTF16([self keyCommandString]));
+ base::SysNSStringToUTF16([[self class] keyCommandString]));
[contentView_ setMessageText:message];
}
return self;
@@ -299,9 +298,9 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
// This looks at the Main Menu and determines what the user has set as the
// key combination for quit. It then gets the modifiers and builds a string
// to display them.
-- (NSString*)keyCommandString {
++ (NSString*)keyCommandString {
ui::AcceleratorCocoa accelerator = [[self class] quitAccelerator];
- return [self keyCombinationForAccelerator:accelerator];
+ return [[self class] keyCombinationForAccelerator:accelerator];
}
// Runs a nested loop that pumps the event queue until the next KeyUp event.
@@ -331,7 +330,7 @@ ConfirmQuitPanelController* g_confirmQuitPanelController = nil;
[NSAnimationContext endGrouping];
}
-- (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item {
++ (NSString*)keyCombinationForAccelerator:(const ui::AcceleratorCocoa&)item {
NSMutableString* string = [NSMutableString string];
NSUInteger modifiers = item.modifiers();
diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm
index 899b444..844ea0b 100644
--- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm
@@ -40,8 +40,7 @@ TEST_F(ConfirmQuitPanelControllerTest, ShowAndDismiss) {
}
TEST_F(ConfirmQuitPanelControllerTest, KeyCombinationForAccelerator) {
- scoped_nsobject<ConfirmQuitPanelController> controller(
- [[ConfirmQuitPanelController alloc] init]);
+ Class controller = [ConfirmQuitPanelController class];
ui::AcceleratorCocoa item = ui::AcceleratorCocoa(@"q", NSCommandKeyMask);
EXPECT_NSEQ(TestString(@"{Cmd}Q"),
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 7286e94..2771f34 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -187,9 +187,6 @@ const char kDisableBackgroundMode[] = "disable-background-mode";
// in the measurements.
const char kDisableBackgroundNetworking[] = "disable-background-networking";
-// Disable the Confirm to Quit experiment (Mac only).
-const char kDisableConfirmToQuit[] = "disable-confirm-to-quit";
-
// Disables blocked content warning animation. Currently shows animation for
// blocked pop-ups only.
const char kDisableBlockContentAnimation[] =
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 7550cff..c494151 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -66,7 +66,6 @@ extern const char kDisableAuthNegotiateCnameLookup[];
extern const char kDisableBackgroundMode[];
extern const char kDisableBackgroundNetworking[];
extern const char kDisableBlockContentAnimation[];
-extern const char kDisableConfirmToQuit[];
extern const char kDisableConnectBackupJobs[];
extern const char kDisableCustomJumpList[];
extern const char kDisableDevTools[];
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 97f1584..04d2e0a 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -161,6 +161,10 @@ const char kIncognitoEnabled[] = "incognito.enabled";
// Boolean that is true when Suggest support is enabled.
const char kSearchSuggestEnabled[] = "search.suggest_enabled";
+// Boolean that indicates whether the browser should put up a confirmation
+// window when the user is attempting to quit. Mac only.
+const char kConfirmToQuitEnabled[] = "browser.confirm_to_quit";
+
// OBSOLETE. Enum that specifies whether to enforce a third-party cookie
// blocking policy. This has been superseded by kDefaultContentSettings +
// kBlockThirdPartyCookies.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index ef8cf16..1550df6 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -65,6 +65,7 @@ extern const char kSafeBrowsingEnabled[];
extern const char kSafeBrowsingReportingEnabled[];
extern const char kIncognitoEnabled[];
extern const char kSearchSuggestEnabled[];
+extern const char kConfirmToQuitEnabled[];
extern const char kCookieBehavior[]; // OBSOLETE
extern const char kDefaultSearchProviderEnabled[];
extern const char kDefaultSearchProviderSearchURL[];