diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-19 01:54:23 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-19 01:54:23 +0000 |
commit | c2788ecbcd5c443fb129f63b7b86f83e944b4950 (patch) | |
tree | 5bf36eb1814dbafe12604c05c19b703897a2c74b | |
parent | d4208dd1717889212bc7749168d1a7b8dea44ebe (diff) | |
download | chromium_src-c2788ecbcd5c443fb129f63b7b86f83e944b4950.zip chromium_src-c2788ecbcd5c443fb129f63b7b86f83e944b4950.tar.gz chromium_src-c2788ecbcd5c443fb129f63b7b86f83e944b4950.tar.bz2 |
[Mac] Polish the search engine manager
* Make the edit search engine window a sheet.
* Only allow one instance of the search engine manager to be opened at once.
* The search engine manager now remembers its position.
* Create NSWindow(LocalStateAdditions) category to assist with storing window
position in Chromium's local state.
BUG=21761,21762,21883,21996
TEST=Editing/adding a search engine happens in a sheet. Press [Manage] multiple times and only 1 window should open. Press [Manage] and the window should be at its last position.
Review URL: http://codereview.chromium.org/207027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26646 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/EditSearchEngine.xib | 594 | ||||
-rw-r--r-- | chrome/browser/browser_prefs.cc | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/keyword_editor_cocoa_controller.mm | 40 | ||||
-rw-r--r-- | chrome/browser/cocoa/nswindow_local_state.h | 21 | ||||
-rw-r--r-- | chrome/browser/cocoa/nswindow_local_state.mm | 37 | ||||
-rw-r--r-- | chrome/browser/cocoa/nswindow_local_state_unittest.mm | 66 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.h | 8 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.mm | 36 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller_unittest.mm | 17 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 19 | ||||
-rw-r--r-- | chrome/browser/search_engines/keyword_editor_controller.cc | 9 | ||||
-rw-r--r-- | chrome/browser/search_engines/keyword_editor_controller.h | 3 | ||||
-rw-r--r-- | chrome/chrome.gyp | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
17 files changed, 775 insertions, 102 deletions
diff --git a/chrome/app/nibs/EditSearchEngine.xib b/chrome/app/nibs/EditSearchEngine.xib index c31701c..892ccae 100644 --- a/chrome/app/nibs/EditSearchEngine.xib +++ b/chrome/app/nibs/EditSearchEngine.xib @@ -1,11 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L30</string> - <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.54</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> + <string key="IBDocument.SystemVersion">10B504</string> + <string key="IBDocument.InterfaceBuilderVersion">732</string> + <string key="IBDocument.AppKitVersion">1038.2</string> + <string key="IBDocument.HIToolboxVersion">437.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="NS.object.0">732</string> + </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> <integer value="2"/> @@ -16,7 +20,7 @@ </object> <object class="NSMutableDictionary" key="IBDocument.Metadata"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys" id="0"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <object class="NSMutableArray" key="dict.values"> @@ -35,14 +39,14 @@ <string key="NSClassName">NSApplication</string> </object> <object class="NSWindowTemplate" id="1005"> - <int key="NSWindowStyleMask">5</int> + <int key="NSWindowStyleMask">69</int> <int key="NSWindowBacking">2</int> <string key="NSWindowRect">{{196, 343}, {396, 167}}</string> <int key="NSWTFlags">544735232</int> <string key="NSWindowTitle">^IDS_SEARCH_ENGINES_EDITOR_NEW_WINDOW_TITLE</string> - <string key="NSWindowClass">NSPanel</string> + <string key="NSWindowClass">NSWindow</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <object class="NSView" key="NSWindowView" id="1006"> <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> @@ -65,7 +69,7 @@ <string key="NSContents">^IDS_OK</string> <object class="NSFont" key="NSSupport" id="1043256678"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.300000e+01</double> + <double key="NSSize">13</double> <int key="NSfFlags">1044</int> </object> <reference key="NSControlView" ref="627445567"/> @@ -125,7 +129,7 @@ <string key="NSColorName">controlColor</string> <object class="NSColor" key="NSColor"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> + <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> </object> </object> <object class="NSColor" key="NSTextColor" id="1037435607"> @@ -191,7 +195,7 @@ <int key="NSvFlags">265</int> <object class="NSMutableSet" key="NSDragTypes"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="set.sortedObjects"> + <object class="NSArray" key="set.sortedObjects"> <bool key="EncodedWithXMLCoder">YES</bool> <string>Apple PDF pasteboard type</string> <string>Apple PICT pasteboard type</string> @@ -219,7 +223,7 @@ <int key="NSvFlags">265</int> <object class="NSMutableSet" key="NSDragTypes"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="set.sortedObjects"> + <object class="NSArray" key="set.sortedObjects"> <bool key="EncodedWithXMLCoder">YES</bool> <string>Apple PDF pasteboard type</string> <string>Apple PICT pasteboard type</string> @@ -311,7 +315,7 @@ <int key="NSvFlags">265</int> <object class="NSMutableSet" key="NSDragTypes"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="set.sortedObjects"> + <object class="NSArray" key="set.sortedObjects"> <bool key="EncodedWithXMLCoder">YES</bool> <string>Apple PDF pasteboard type</string> <string>Apple PICT pasteboard type</string> @@ -346,7 +350,7 @@ <string key="NSContents">^IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL</string> <object class="NSFont" key="NSSupport"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.100000e+01</double> + <double key="NSSize">11</double> <int key="NSfFlags">16</int> </object> <reference key="NSControlView" ref="1040217251"/> @@ -368,7 +372,7 @@ <string key="NSContents"/> <object class="NSFont" key="NSSupport"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.100000e+01</double> + <double key="NSSize">11</double> <int key="NSfFlags">3100</int> </object> <reference key="NSBackgroundColor" ref="948976970"/> @@ -388,7 +392,7 @@ <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> <object class="NSCustomObject" id="534663943"> <string key="NSClassName">ChromeUILocalizer</string> @@ -574,28 +578,26 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBObjectRecord"> <int key="objectID">0</int> - <object class="NSArray" key="object" id="373524166"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="object" ref="0"/> <reference key="children" ref="1000"/> <nil key="parent"/> </object> <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="1001"/> - <reference key="parent" ref="373524166"/> - <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="373524166"/> + <reference key="parent" ref="0"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="373524166"/> + <reference key="parent" ref="0"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -605,7 +607,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="1006"/> </object> - <reference key="parent" ref="373524166"/> + <reference key="parent" ref="0"/> </object> <object class="IBObjectRecord"> <int key="objectID">2</int> @@ -621,12 +623,12 @@ <object class="IBObjectRecord"> <int key="objectID">45</int> <reference key="object" ref="534663943"/> - <reference key="parent" ref="373524166"/> + <reference key="parent" ref="0"/> </object> <object class="IBObjectRecord"> <int key="objectID">49</int> <reference key="object" ref="689567283"/> - <reference key="parent" ref="373524166"/> + <reference key="parent" ref="0"/> </object> <object class="IBObjectRecord"> <int key="objectID">54</int> @@ -836,7 +838,7 @@ </object> <object class="NSMutableDictionary" key="flattenedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>-1.IBPluginDependency</string> <string>-2.IBPluginDependency</string> @@ -884,7 +886,7 @@ <string>{{469, 537}, {396, 167}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{469, 537}, {396, 167}}</string> - <integer value="1"/> + <boolean value="NO"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -921,9 +923,7 @@ </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="dict.sortedKeys" ref="0"/> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -931,9 +931,7 @@ <nil key="activeLocalization"/> <object class="NSMutableDictionary" key="localizations"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="dict.sortedKeys" ref="0"/> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -957,7 +955,7 @@ <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>cancel:</string> <string>save:</string> @@ -970,7 +968,7 @@ </object> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>doneButton_</string> <string>fieldAndImageContainer_</string> @@ -1007,7 +1005,7 @@ <string key="superclassName">NSObject</string> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>otherObjectToLocalize_</string> <string>owner_</string> @@ -1030,7 +1028,7 @@ <string key="superclassName">NSObject</string> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>localizerOwner_</string> <string>localizer_</string> @@ -1053,7 +1051,7 @@ <string key="superclassName">NSView</string> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>viewToResize_</string> <string>viewToSlideAndResize_</string> @@ -1083,8 +1081,524 @@ </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">NSActionCell</string> + <string key="superclassName">NSCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <string key="superclassName">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="793157456"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="50403614"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="656638078"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSBox</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSBox.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSButton</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSButton.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSButtonCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSCell</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSControl</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="361279917"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSControl.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSFormatter</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSImageCell</string> + <string key="superclassName">NSCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSImageCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSImageView</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSImageView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSMenu</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="972321352"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="793157456"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="50403614"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="656638078"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="361279917"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="972321352"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="973074284"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSError.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFAuthorizationView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFCertificatePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFChooseIdentityPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextField</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextFieldCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <string key="superclassName">NSResponder</string> + <reference key="sourceIdentifier" ref="973074284"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <string key="superclassName">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindowScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindowController</string> + <string key="superclassName">NSResponder</string> + <object class="NSMutableDictionary" key="actions"> + <string key="NS.key.0">showWindow:</string> + <string key="NS.object.0">id</string> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindowController.h</string> + </object> + </object> + </object> </object> <int key="IBDocument.localizationMode">0</int> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1050" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1050" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> + <integer value="3000" key="NS.object.0"/> + </object> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> </data> diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc index cb1a8cc..15b3508 100644 --- a/chrome/browser/browser_prefs.cc +++ b/chrome/browser/browser_prefs.cc @@ -22,6 +22,7 @@ #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" +#include "chrome/browser/search_engines/keyword_editor_controller.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/session_startup_pref.h" #include "chrome/browser/ssl/ssl_manager.h" @@ -51,6 +52,7 @@ void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) { WebCacheManager::RegisterPrefs(local_state); ExternalProtocolHandler::RegisterPrefs(local_state); GoogleURLTracker::RegisterPrefs(local_state); + KeywordEditorController::RegisterPrefs(local_state); MetricsLog::RegisterPrefs(local_state); MetricsService::RegisterPrefs(local_state); SafeBrowsingService::RegisterPrefs(local_state); diff --git a/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm b/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm index 00e4913..d3e2131 100644 --- a/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm +++ b/chrome/browser/cocoa/edit_search_engine_cocoa_controller.mm @@ -102,8 +102,18 @@ void ShiftOriginY(NSView* view, CGFloat amount) { [self autorelease]; } +// Performs the logic of closing the window. If we are a sheet, then it ends the +// modal session; otherwise, it closes the window. +- (void)doClose { + if ([[self window] isSheet]) { + [NSApp endSheet:[self window]]; + } else { + [[self window] close]; + } +} + - (IBAction)cancel:(id)sender { - [[self window] close]; + [self doClose]; } - (IBAction)save:(id)sender { @@ -112,7 +122,7 @@ void ShiftOriginY(NSView* view, CGFloat amount) { std::wstring keyword = base::SysNSStringToWide([keywordField_ stringValue]); std::wstring url = base::SysNSStringToWide([urlField_ stringValue]); controller_->AcceptAddOrEdit(title, keyword, url); - [[self window] close]; + [self doClose]; } // Delegate method for the text fields. diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm index d564b6b..4d90f15 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm @@ -6,10 +6,14 @@ #import "base/mac_util.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/browser_process.h" #import "chrome/browser/cocoa/edit_search_engine_cocoa_controller.h" +#import "chrome/browser/cocoa/nswindow_local_state.h" #import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_table_model.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" #include "grit/generated_resources.h" #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" @@ -76,6 +80,14 @@ void KeywordEditorModelObserver::OnEditedKeyword( size.height = NSHeight([addButton_ frame]); [makeDefaultButton_ setFrameSize:size]; + // Restore the window position. + if (g_browser_process && g_browser_process->local_state()) { + PrefService* prefs = g_browser_process->local_state(); + NSWindow* window = [self window]; + [window restoreWindowPositionFromPrefs:prefs + withPath:prefs::kKeywordEditorWindowPlacement]; + } + [self adjustEditingButtons]; [tableView_ setDoubleAction:@selector(editKeyword:)]; [tableView_ setTarget:self]; @@ -86,6 +98,16 @@ void KeywordEditorModelObserver::OnEditedKeyword( [self autorelease]; } +// The last page info window that was moved will determine the location of the +// next new one. +- (void)windowDidMove:(NSNotification*)notif { + if (g_browser_process && g_browser_process->local_state()) { + NSWindow* window = [self window]; + [window saveWindowPositionToPrefs:g_browser_process->local_state() + withPath:prefs::kKeywordEditorWindowPlacement]; + } +} + - (void)modelChanged { [tableView_ reloadData]; } @@ -94,13 +116,23 @@ void KeywordEditorModelObserver::OnEditedKeyword( return controller_.get(); } +- (void)sheetDidEnd:(NSWindow*)sheet + returnCode:(NSInteger)code + context:(void*)context { + [sheet orderOut:self]; +} + - (IBAction)addKeyword:(id)sender { // The controller will release itself when the window closes. EditSearchEngineCocoaController* editor = [[EditSearchEngineCocoaController alloc] initWithProfile:profile_ delegate:observer_.get() templateURL:NULL]; - [[editor window] makeKeyAndOrderFront:self]; + [NSApp beginSheet:[editor window] + modalForWindow:[self window] + modalDelegate:self + didEndSelector:@selector(sheetDidEnd:returnCode:context:) + contextInfo:NULL]; } - (void)editKeyword:(id)sender { @@ -113,7 +145,11 @@ void KeywordEditorModelObserver::OnEditedKeyword( [[EditSearchEngineCocoaController alloc] initWithProfile:profile_ delegate:observer_.get() templateURL:url]; - [[editor window] makeKeyAndOrderFront:self]; + [NSApp beginSheet:[editor window] + modalForWindow:[self window] + modalDelegate:self + didEndSelector:@selector(sheetDidEnd:returnCode:context:) + contextInfo:NULL]; } - (IBAction)deleteKeyword:(id)sender { diff --git a/chrome/browser/cocoa/nswindow_local_state.h b/chrome/browser/cocoa/nswindow_local_state.h new file mode 100644 index 0000000..3a3394c --- /dev/null +++ b/chrome/browser/cocoa/nswindow_local_state.h @@ -0,0 +1,21 @@ +// Copyright (c) 2009 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. + +class PrefService; +@class NSWindow; + +// These additions to NSWindow assist in saving and restoring a window's +// position to Chromium's local state preferences. + +@interface NSWindow (LocalStateAdditions) + +// Saves the window's origin into the given PrefService. Caller is responsible +// for making sure |prefs| is not NULL. +- (void)saveWindowPositionToPrefs:(PrefService*)prefs + withPath:(const wchar_t*)path; + +- (void)restoreWindowPositionFromPrefs:(PrefService*)prefs + withPath:(const wchar_t*)path; + +@end diff --git a/chrome/browser/cocoa/nswindow_local_state.mm b/chrome/browser/cocoa/nswindow_local_state.mm new file mode 100644 index 0000000..7fdfff6 --- /dev/null +++ b/chrome/browser/cocoa/nswindow_local_state.mm @@ -0,0 +1,37 @@ +// Copyright (c) 2009 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. + +#import <Cocoa/Cocoa.h> +#include "chrome/common/pref_service.h" + +@implementation NSWindow (LocalStateAdditions) + +- (void)saveWindowPositionToPrefs:(PrefService*)prefs + withPath:(const wchar_t*)path { + DCHECK(prefs); + // Save the origin of the window. + DictionaryValue* windowPrefs = prefs->GetMutableDictionary(path); + NSRect frame = [self frame]; + windowPrefs->SetInteger(L"x", frame.origin.x); + windowPrefs->SetInteger(L"y", frame.origin.y); +} + +- (void)restoreWindowPositionFromPrefs:(PrefService*)prefs + withPath:(const wchar_t*)path { + DCHECK(prefs); + // Get the positioning information. + DictionaryValue* windowPrefs = prefs->GetMutableDictionary(path); + int x = 0, y = 0; + windowPrefs->GetInteger(L"x", &x); + windowPrefs->GetInteger(L"y", &y); + // Turn the origin (lower-left) into an upper-left window point. + NSPoint upperLeft = NSMakePoint(x, y + [self frame].size.height); + NSPoint cascadePoint = [self cascadeTopLeftFromPoint:upperLeft]; + // Cascade again to get the offset when opening new windows. + [self cascadeTopLeftFromPoint:cascadePoint]; + // Force a save of the pref. + [self saveWindowPositionToPrefs:prefs withPath:path]; +} + +@end diff --git a/chrome/browser/cocoa/nswindow_local_state_unittest.mm b/chrome/browser/cocoa/nswindow_local_state_unittest.mm new file mode 100644 index 0000000..6d4fab1 --- /dev/null +++ b/chrome/browser/cocoa/nswindow_local_state_unittest.mm @@ -0,0 +1,66 @@ +// Copyright (c) 2009 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. + +#import <Cocoa/Cocoa.h> + +#include "base/scoped_nsobject.h" +#include "chrome/browser/cocoa/browser_test_helper.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#import "chrome/browser/cocoa/nswindow_local_state.h" +#include "chrome/common/pref_service.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" + +class NSWindowLocalStateTest : public PlatformTest { + virtual void SetUp() { + path_ = L"NSWindowLocalStateTest"; + window_.reset( + [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 20, 20) + styleMask:NSTitledWindowMask + backing:NSBackingStoreBuffered + defer:NO]); + browser_helper_.profile()->GetPrefs()->RegisterDictionaryPref(path_); + } + + public: + CocoaTestHelper cocoa_helper_; + BrowserTestHelper browser_helper_; + scoped_nsobject<NSWindow> window_; + const wchar_t* path_; +}; + +TEST_F(NSWindowLocalStateTest, SaveWindowPlacement) { + PrefService* prefs = browser_helper_.profile()->GetPrefs(); + ASSERT_TRUE(prefs != NULL); + + // Check to make sure there is no existing pref for window placement. + ASSERT_TRUE(prefs->GetDictionary(path_) == NULL); + + // Ask the window to save its position, then check that a preference + // exists. We're technically passing in a pointer to the user prefs + // and not the local state prefs, but a PrefService* is a + // PrefService*, and this is a unittest. + [window_ saveWindowPositionToPrefs:prefs withPath:path_]; + EXPECT_TRUE(prefs->GetDictionary(path_) != NULL); + int x, y; + DictionaryValue* windowPrefs = prefs->GetMutableDictionary(path_); + windowPrefs->GetInteger(L"x", &x); + windowPrefs->GetInteger(L"y", &y); + EXPECT_EQ(x, [window_ frame].origin.x); + EXPECT_EQ(y, [window_ frame].origin.y); +} + +TEST_F(NSWindowLocalStateTest, RestoreWindowPlacement) { + PrefService* prefs = browser_helper_.profile()->GetPrefs(); + DictionaryValue* windowPrefs = prefs->GetMutableDictionary(path_); + + // Large enough so that the window is on screen without cascasding to a + // totally new location. + const int value = 420; + windowPrefs->SetInteger(L"x", value); + windowPrefs->SetInteger(L"y", value); + [window_ restoreWindowPositionFromPrefs:prefs withPath:path_]; + EXPECT_LT(value, [window_ frame].origin.x); + EXPECT_GT(value, [window_ frame].origin.y); +} diff --git a/chrome/browser/cocoa/page_info_window_controller.h b/chrome/browser/cocoa/page_info_window_controller.h index c62893b..5ad689b 100644 --- a/chrome/browser/cocoa/page_info_window_controller.h +++ b/chrome/browser/cocoa/page_info_window_controller.h @@ -59,11 +59,3 @@ class PrefService; - (void)setShowHistoryBox:(BOOL)show; @end - -@interface PageInfoWindowController (ExposedForTesting) - -// Saves the window's origin into the given PrefService. Caller is responsible -// for making sure |prefs| is not NULL. -- (void)saveWindowPositionToPrefs:(PrefService*)prefs; - -@end diff --git a/chrome/browser/cocoa/page_info_window_controller.mm b/chrome/browser/cocoa/page_info_window_controller.mm index 9f3b813..d8eb7c7 100644 --- a/chrome/browser/cocoa/page_info_window_controller.mm +++ b/chrome/browser/cocoa/page_info_window_controller.mm @@ -7,6 +7,7 @@ #include "base/mac_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" +#import "chrome/browser/cocoa/nswindow_local_state.h" #include "chrome/browser/cocoa/page_info_window_mac.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" @@ -45,17 +46,8 @@ if (g_browser_process && g_browser_process->local_state()) { // Get the positioning information. PrefService* prefs = g_browser_process->local_state(); - DictionaryValue* windowPrefs = - prefs->GetMutableDictionary(prefs::kPageInfoWindowPlacement); - int x = 0, y = 0; - windowPrefs->GetInteger(L"x", &x); - windowPrefs->GetInteger(L"y", &y); - // Turn the origin (lower-left) into an upper-left window point. - NSPoint upperLeft = NSMakePoint(x, y + [[self window] frame].size.height); - NSPoint cascadePoint = [[self window] cascadeTopLeftFromPoint:upperLeft]; - // Cascade again to get the offset when opening new windows. - [[self window] cascadeTopLeftFromPoint:cascadePoint]; - [self saveWindowPositionToLocalState]; // Force a save of the pref. + [[self window] restoreWindowPositionFromPrefs:prefs + withPath:prefs::kPageInfoWindowPlacement]; } // By default, assume we have no history information. @@ -116,25 +108,9 @@ // The last page info window that was moved will determine the location of the // next new one. - (void)windowDidMove:(NSNotification*)notif { - [self saveWindowPositionToLocalState]; -} - -// Saves the window preference to the local state. -- (void)saveWindowPositionToLocalState { - if (!g_browser_process || !g_browser_process->local_state()) - return; - [self saveWindowPositionToPrefs:g_browser_process->local_state()]; -} - -// Saves the window's origin into the given PrefService. Caller is responsible -// for making sure |prefs| is not NULL. -- (void)saveWindowPositionToPrefs:(PrefService*)prefs { - // Save the origin of the window. - DictionaryValue* windowPrefs = prefs->GetMutableDictionary( - prefs::kPageInfoWindowPlacement); - NSRect frame = [[self window] frame]; - windowPrefs->SetInteger(L"x", frame.origin.x); - windowPrefs->SetInteger(L"y", frame.origin.y); + if (g_browser_process && g_browser_process->local_state()) + [[self window] saveWindowPositionToPrefs:g_browser_process->local_state() + withPath:prefs::kPageInfoWindowPlacement]; } @end diff --git a/chrome/browser/cocoa/page_info_window_controller_unittest.mm b/chrome/browser/cocoa/page_info_window_controller_unittest.mm index 66018a2..8c92098 100644 --- a/chrome/browser/cocoa/page_info_window_controller_unittest.mm +++ b/chrome/browser/cocoa/page_info_window_controller_unittest.mm @@ -50,20 +50,3 @@ TEST_F(PageInfoWindowControllerTest, TestShrink) { EXPECT_LE(newFrame.size.height, frame.size.height); EXPECT_GE(newFrame.origin.y, frame.origin.y); } - - -TEST_F(PageInfoWindowControllerTest, TestSaveWindowPlacement) { - PrefService* prefs = helper_.profile()->GetPrefs(); - ASSERT_TRUE(prefs != NULL); - - // Check to make sure there is no existing pref for window placement. - ASSERT_TRUE(prefs->GetDictionary(prefs::kPageInfoWindowPlacement) == NULL); - - // Ask the window to save its position, then check that a preference - // exists. We're technically passing in a pointer to the user prefs - // and not the local state prefs, but a PrefService* is a - // PrefService*, and this is a unittest. - [controller_ saveWindowPositionToPrefs:prefs]; - EXPECT_TRUE(prefs->GetDictionary(prefs::kPageInfoWindowPlacement) != NULL); -} - diff --git a/chrome/browser/cocoa/preferences_window_controller.h b/chrome/browser/cocoa/preferences_window_controller.h index 7b333ee..5aa8b95 100644 --- a/chrome/browser/cocoa/preferences_window_controller.h +++ b/chrome/browser/cocoa/preferences_window_controller.h @@ -9,6 +9,7 @@ #include "chrome/common/pref_member.h" @class CustomHomePagesModel; +@class KeywordEditorCocoaController; class PrefObserverBridge; class PrefService; class Profile; @@ -42,6 +43,7 @@ class Profile; BooleanPrefMember showHomeButton_; BooleanPrefMember showPageOptionButtons_; scoped_nsobject<SearchEngineListModel> searchEngineModel_; + KeywordEditorCocoaController* keywordEditorController_; // weak // Used when creating a new home page url to make the new cell editable. BOOL pendingSelectForEdit_; diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 26a82bb..b3f234d 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -540,11 +540,24 @@ enum { kHomepageNewTabPage, kHomepageURL }; [self setSearchEngineSelectedIndex:[self searchEngineSelectedIndex]]; } +// Notification receiver for when the keyword editor window closes. The +// controller will clean up the window, but we need to clean up. +- (void)keywordEditorClosed:(NSNotification*)notif { + keywordEditorController_ = nil; +} + // Brings up the edit search engines window. - (IBAction)manageSearchEngines:(id)sender { - KeywordEditorCocoaController* controller = - [[KeywordEditorCocoaController alloc] initWithProfile:profile_]; - [[controller window] makeKeyAndOrderFront:sender]; + if (!keywordEditorController_) { + keywordEditorController_ = + [[KeywordEditorCocoaController alloc] initWithProfile:profile_]; + NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; + [center addObserver:self + selector:@selector(keywordEditorClosed:) + name:NSWindowWillCloseNotification + object:[keywordEditorController_ window]]; + } + [[keywordEditorController_ window] makeKeyAndOrderFront:sender]; } // Called when the user clicks the button to make Chromium the default diff --git a/chrome/browser/search_engines/keyword_editor_controller.cc b/chrome/browser/search_engines/keyword_editor_controller.cc index 022af56..04b385d 100644 --- a/chrome/browser/search_engines/keyword_editor_controller.cc +++ b/chrome/browser/search_engines/keyword_editor_controller.cc @@ -9,6 +9,8 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/search_engines/template_url_table_model.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" KeywordEditorController::KeywordEditorController(Profile* profile) : profile_(profile) { @@ -18,6 +20,13 @@ KeywordEditorController::KeywordEditorController(Profile* profile) KeywordEditorController::~KeywordEditorController() { } +// static +// TODO(rsesek): Other platforms besides Mac should remember window +// placement. http://crbug.com/22269 +void KeywordEditorController::RegisterPrefs(PrefService* prefs) { + prefs->RegisterDictionaryPref(prefs::kKeywordEditorWindowPlacement); +} + int KeywordEditorController::AddTemplateURL(const std::wstring& title, const std::wstring& keyword, const std::wstring& url) { diff --git a/chrome/browser/search_engines/keyword_editor_controller.h b/chrome/browser/search_engines/keyword_editor_controller.h index 1aafc2c..4c62feb 100644 --- a/chrome/browser/search_engines/keyword_editor_controller.h +++ b/chrome/browser/search_engines/keyword_editor_controller.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" +class PrefService; class Profile; class TemplateURL; class TemplateURLModel; @@ -20,6 +21,8 @@ class KeywordEditorController { explicit KeywordEditorController(Profile* profile); ~KeywordEditorController(); + static void RegisterPrefs(PrefService* prefs); + // Invoked when the user succesfully fills out the add keyword dialog. // Propagates the change to the TemplateURLModel and updates the table model. // Returns the index of the added URL. diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 1ac3e76..94f95ca 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -985,6 +985,8 @@ 'browser/cocoa/menu_button.mm', 'browser/cocoa/nsimage_cache.h', 'browser/cocoa/nsimage_cache.mm', + 'browser/cocoa/nswindow_local_state.h', + 'browser/cocoa/nswindow_local_state.mm', 'browser/cocoa/page_info_window_controller.h', 'browser/cocoa/page_info_window_controller.mm', 'browser/cocoa/page_info_window_mac.h', @@ -4106,6 +4108,7 @@ 'browser/cocoa/history_menu_cocoa_controller_unittest.mm', 'browser/cocoa/menu_button_unittest.mm', 'browser/cocoa/nsimage_cache_unittest.mm', + 'browser/cocoa/nswindow_local_state_unittest.mm', 'browser/cocoa/page_info_window_controller_unittest.mm', 'browser/cocoa/preferences_window_controller_unittest.mm', 'browser/cocoa/rwhvm_editcommand_helper_unittest.mm', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 6724092..d6d75e8 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -427,6 +427,11 @@ const wchar_t kTaskManagerWindowPlacement[] = L"task_manager.window_placement"; // window to restore on startup. const wchar_t kPageInfoWindowPlacement[] = L"page_info.window_placement"; +// A collection of position, size, and other data relating to the keyword +// editor window to restore on startup. +const wchar_t kKeywordEditorWindowPlacement[] = + L"keyword_editor.window_placement"; + // An integer specifying the total number of bytes to be used by the // renderer's in-memory cache of objects. const wchar_t kMemoryCacheSize[] = L"renderer.memory_cache.size"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index cd496d0..43b89e7 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -160,6 +160,7 @@ extern const wchar_t kUninstallLastObservedRunTimeSec[]; extern const wchar_t kBrowserWindowPlacement[]; extern const wchar_t kTaskManagerWindowPlacement[]; extern const wchar_t kPageInfoWindowPlacement[]; +extern const wchar_t kKeywordEditorWindowPlacement[]; extern const wchar_t kMemoryCacheSize[]; extern const wchar_t kDownloadDefaultDirectory[]; |