diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-19 22:10:53 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-19 22:10:53 +0000 |
commit | fcdc18a51a39aa9f9a8961306eb583d17ee26289 (patch) | |
tree | 8cc16230516561665acb685acf1dda408a29fdc2 | |
parent | 5d722824a29973ca54ae6e1bb4ee36a88e6854d5 (diff) | |
download | chromium_src-fcdc18a51a39aa9f9a8961306eb583d17ee26289.zip chromium_src-fcdc18a51a39aa9f9a8961306eb583d17ee26289.tar.gz chromium_src-fcdc18a51a39aa9f9a8961306eb583d17ee26289.tar.bz2 |
Mac: Save/restore task manager window pos and size.
Make window size remembering mechanism easier to use and more compatible with windows's chrome profiles.
Nib changes: Unset "show at startup" so that the initial repositioning isn't visible.
BUG=32147
TEST=Move & size taskman window, quit chrome, reopen chrome. Size & pos should've stayed. Same for keyword editor. Page info dialog should behave as it did before.
Review URL: http://codereview.chromium.org/536086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36557 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/KeywordEditor.xib | 612 | ||||
-rw-r--r-- | chrome/app/nibs/PageInfo.xib | 19 | ||||
-rw-r--r-- | chrome/app/nibs/TaskManager.xib | 4 | ||||
-rw-r--r-- | chrome/browser/browser_prefs.cc | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/keyword_editor_cocoa_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/keyword_editor_cocoa_controller.mm | 27 | ||||
-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 | 71 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.mm | 35 | ||||
-rw-r--r-- | chrome/browser/cocoa/task_manager_mac.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/task_manager_mac.mm | 23 | ||||
-rw-r--r-- | chrome/browser/cocoa/window_size_autosaver.h | 45 | ||||
-rw-r--r-- | chrome/browser/cocoa/window_size_autosaver.mm | 95 | ||||
-rw-r--r-- | chrome/browser/cocoa/window_size_autosaver_unittest.mm | 157 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 4 | ||||
-rwxr-xr-x | chrome/chrome_tests.gypi | 2 |
18 files changed, 397 insertions, 775 deletions
diff --git a/chrome/app/nibs/KeywordEditor.xib b/chrome/app/nibs/KeywordEditor.xib index 7e28a4e..15c0f28 100644 --- a/chrome/app/nibs/KeywordEditor.xib +++ b/chrome/app/nibs/KeywordEditor.xib @@ -1,18 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <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> + <string key="IBDocument.SystemVersion">9L31a</string> + <string key="IBDocument.InterfaceBuilderVersion">677</string> + <string key="IBDocument.AppKitVersion">949.54</string> + <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="8"/> + <integer value="1"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -20,7 +16,7 @@ </object> <object class="NSMutableDictionary" key="IBDocument.Metadata"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys" id="0"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <object class="NSMutableArray" key="dict.values"> @@ -46,7 +42,7 @@ <string key="NSWindowTitle">^IDS_SEARCH_ENGINES_EDITOR_WINDOW_TITLE</string> <string key="NSWindowClass">NSWindow</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> + <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{400, 250}</string> <object class="NSView" key="NSWindowView" id="1006"> <reference key="NSNextResponder"/> @@ -86,16 +82,16 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSTableColumn" id="219687723"> <string key="NSIdentifier">name</string> - <double key="NSWidth">286</double> - <double key="NSMinWidth">40</double> - <double key="NSMaxWidth">1000</double> + <double key="NSWidth">2.860000e+02</double> + <double key="NSMinWidth">4.000000e+01</double> + <double key="NSMaxWidth">1.000000e+03</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> <string key="NSContents">^IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN</string> <object class="NSFont" key="NSSupport" id="26"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">11</double> + <double key="NSSize">1.100000e+01</double> <int key="NSfFlags">3100</int> </object> <object class="NSColor" key="NSBackgroundColor" id="360181545"> @@ -118,7 +114,7 @@ <string key="NSContents">Image and Text Cell</string> <object class="NSFont" key="NSSupport" id="28180702"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">13</double> + <double key="NSSize">1.300000e+01</double> <int key="NSfFlags">1044</int> </object> <reference key="NSControlView" ref="79465721"/> @@ -142,9 +138,9 @@ </object> <object class="NSTableColumn" id="683197110"> <string key="NSIdentifier">keyword</string> - <double key="NSWidth">266</double> - <double key="NSMinWidth">40</double> - <double key="NSMaxWidth">1000</double> + <double key="NSWidth">2.660000e+02</double> + <double key="NSMinWidth">4.000000e+01</double> + <double key="NSMaxWidth">1.000000e+03</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -165,7 +161,7 @@ <string key="NSColorName">controlBackgroundColor</string> <object class="NSColor" key="NSColor"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> + <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> </object> </object> <object class="NSColor" key="NSTextColor"> @@ -180,8 +176,8 @@ <reference key="NSTableView" ref="79465721"/> </object> </object> - <double key="NSIntercellSpacingWidth">3</double> - <double key="NSIntercellSpacingHeight">2</double> + <double key="NSIntercellSpacingWidth">3.000000e+00</double> + <double key="NSIntercellSpacingHeight">2.000000e+00</double> <reference key="NSBackgroundColor" ref="720866291"/> <object class="NSColor" key="NSGridColor"> <int key="NSColorSpace">6</int> @@ -192,15 +188,12 @@ <bytes key="NSWhite">MC41AA</bytes> </object> </object> - <double key="NSRowHeight">18</double> + <double key="NSRowHeight">1.800000e+01</double> <int key="NSTvFlags">1379958784</int> - <reference key="NSDelegate"/> - <reference key="NSDataSource"/> <int key="NSColumnAutoresizingStyle">1</int> <int key="NSDraggingSourceMaskForLocal">15</int> <int key="NSDraggingSourceMaskForNonLocal">0</int> <bool key="NSAllowsTypeSelect">YES</bool> - <int key="NSTableViewDraggingDestinationStyle">0</int> </object> </object> <string key="NSFrame">{{1, 17}, {558, 315}}</string> @@ -217,7 +210,7 @@ <reference key="NSSuperview" ref="905365236"/> <reference key="NSTarget" ref="905365236"/> <string key="NSAction">_doScroller:</string> - <double key="NSPercent">0.99683549999999999</double> + <double key="NSPercent">9.968355e-01</double> </object> <object class="NSScroller" id="565719222"> <reference key="NSNextResponder" ref="905365236"/> @@ -227,7 +220,7 @@ <int key="NSsFlags">1</int> <reference key="NSTarget" ref="905365236"/> <string key="NSAction">_doScroller:</string> - <double key="NSPercent">0.93781512605042017</double> + <double key="NSPercent">9.378151e-01</double> </object> <object class="NSClipView" id="466409131"> <reference key="NSNextResponder" ref="905365236"/> @@ -330,7 +323,7 @@ </object> <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> <string key="NSMinSize">{400, 272}</string> - <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> + <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> </object> <object class="NSCustomObject" id="757649325"> <string key="NSClassName">ChromeUILocalizer</string> @@ -441,26 +434,28 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBObjectRecord"> <int key="objectID">0</int> - <reference key="object" ref="0"/> + <object class="NSArray" key="object" id="526976829"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> <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="0"/> - <string key="objectName">File's Owner</string> + <reference key="parent" ref="526976829"/> + <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="0"/> + <reference key="parent" ref="526976829"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="0"/> + <reference key="parent" ref="526976829"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -470,7 +465,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="1006"/> </object> - <reference key="parent" ref="0"/> + <reference key="parent" ref="526976829"/> </object> <object class="IBObjectRecord"> <int key="objectID">2</int> @@ -589,7 +584,7 @@ <object class="IBObjectRecord"> <int key="objectID">29</int> <reference key="object" ref="757649325"/> - <reference key="parent" ref="0"/> + <reference key="parent" ref="526976829"/> </object> <object class="IBObjectRecord"> <int key="objectID">41</int> @@ -600,7 +595,7 @@ </object> <object class="NSMutableDictionary" key="flattenedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>-1.IBPluginDependency</string> <string>-2.IBPluginDependency</string> @@ -636,10 +631,10 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{329, 482}, {558, 352}}</string> + <string>{{205, 482}, {558, 352}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{329, 482}, {558, 352}}</string> - <integer value="1"/> + <string>{{205, 482}, {558, 352}}</string> + <boolean value="NO"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> <boolean value="YES"/> @@ -665,7 +660,9 @@ </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -673,7 +670,9 @@ <nil key="activeLocalization"/> <object class="NSMutableDictionary" key="localizations"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -697,7 +696,7 @@ <string key="superclassName">NSObject</string> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>otherObjectToLocalize_</string> <string>owner_</string> @@ -720,7 +719,7 @@ <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>addKeyword:</string> <string>deleteKeyword:</string> @@ -735,7 +734,7 @@ </object> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>addButton_</string> <string>makeDefaultButton_</string> @@ -777,529 +776,8 @@ </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="121988484"> - <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="700489963"> - <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="134565972"> - <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">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="913227515"> - <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">NSMenu</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="797656932"> - <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="121988484"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="700489963"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="134565972"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="913227515"/> - </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="797656932"/> - </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" id="558744269"> - <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="742314025"> - <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">NSScrollView</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSScrollView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSScroller</string> - <string key="superclassName">NSControl</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSScroller.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTableColumn</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTableColumn.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTableHeaderView</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTableHeaderView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTableView</string> - <string key="superclassName">NSControl</string> - <reference key="sourceIdentifier" ref="558744269"/> - </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="742314025"/> - </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/app/nibs/PageInfo.xib b/chrome/app/nibs/PageInfo.xib index a294a65..d043b27 100644 --- a/chrome/app/nibs/PageInfo.xib +++ b/chrome/app/nibs/PageInfo.xib @@ -2,13 +2,13 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L30</string> + <string key="IBDocument.SystemVersion">9L31a</string> <string key="IBDocument.InterfaceBuilderVersion">677</string> <string key="IBDocument.AppKitVersion">949.54</string> <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="2"/> + <integer value="1"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -768,11 +768,11 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{549, 366}, {460, 290}}</string> + <string>{{303, 366}, {460, 290}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <boolean value="NO"/> - <string>{{549, 366}, {460, 290}}</string> - <integer value="1"/> + <boolean value="NO" id="6"/> + <string>{{303, 366}, {460, 290}}</string> + <reference ref="6"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -911,13 +911,6 @@ </object> </object> <object class="IBPartialClassDescription"> - <string key="className">NSWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/nswindow_local_state.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">PageInfoWindowController</string> <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> diff --git a/chrome/app/nibs/TaskManager.xib b/chrome/app/nibs/TaskManager.xib index 2fe33d8..ceed983 100644 --- a/chrome/app/nibs/TaskManager.xib +++ b/chrome/app/nibs/TaskManager.xib @@ -8,7 +8,7 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="3"/> + <integer value="1"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -573,7 +573,7 @@ <string>{{274, 515}, {480, 270}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{274, 515}, {480, 270}}</string> - <integer value="1"/> + <boolean value="NO"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc index ced36f5..b9e7fa2 100644 --- a/chrome/browser/browser_prefs.cc +++ b/chrome/browser/browser_prefs.cc @@ -31,19 +31,12 @@ #include "chrome/browser/session_startup_pref.h" #include "chrome/browser/ssl/ssl_manager.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/task_manager.h" #if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port #include "chrome/browser/views/frame/browser_view.h" #endif -#if defined(OS_WIN) || defined(OS_LINUX) -#include "chrome/browser/task_manager.h" -#endif - -#if defined(OS_WIN) -#include "chrome/browser/views/keyword_editor_view.h" -#endif - #if defined(TOOLKIT_GTK) #include "chrome/browser/gtk/browser_window_gtk.h" #endif @@ -77,9 +70,7 @@ void RegisterLocalState(PrefService* local_state) { #if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port BrowserView::RegisterBrowserViewPrefs(local_state); #endif -#if defined(OS_WIN) || defined(OS_LINUX) TaskManager::RegisterPrefs(local_state); -#endif } void RegisterUserPrefs(PrefService* user_prefs) { diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller.h b/chrome/browser/cocoa/keyword_editor_cocoa_controller.h index 9023a15..73aed70 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller.h +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller.h @@ -15,6 +15,7 @@ class EditSearchEngineControllerDelegate; @class KeywordEditorCocoaController; class Profile; +@class WindowSizeAutosaver; // Very thin bridge that simply pushes notifications from C++ to ObjC. class KeywordEditorModelObserver : public TemplateURLModelObserver, @@ -77,6 +78,8 @@ class KeywordEditorModelObserver : public TemplateURLModelObserver, Profile* profile_; // weak scoped_ptr<KeywordEditorController> controller_; scoped_ptr<KeywordEditorModelObserver> observer_; + + scoped_nsobject<WindowSizeAutosaver> sizeSaver_; } @property (readonly) KeywordEditorController* controller; diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm index 7440a17..5495235 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller.mm @@ -9,8 +9,8 @@ #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" +#import "chrome/browser/cocoa/window_size_autosaver.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_table_model.h" #include "chrome/common/pref_names.h" @@ -144,6 +144,14 @@ typedef std::map<Profile*,KeywordEditorCocoaController*> ProfileControllerMap; controller_->table_model()->SetObserver(observer_.get()); controller_->url_model()->AddObserver(observer_.get()); groupCell_.reset([[NSTextFieldCell alloc] init]); + + if (g_browser_process && g_browser_process->local_state()) { + sizeSaver_.reset([[WindowSizeAutosaver alloc] + initWithWindow:[self window] + prefService:g_browser_process->local_state() + path:prefs::kKeywordEditorWindowPlacement + state:kSaveWindowRect]); + } } return self; } @@ -164,14 +172,6 @@ typedef std::map<Profile*,KeywordEditorCocoaController*> ProfileControllerMap; 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]; @@ -192,15 +192,6 @@ typedef std::map<Profile*,KeywordEditorCocoaController*> ProfileControllerMap; } } -// Remeber the position of the keyword editor. -- (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]; [self adjustEditingButtons]; diff --git a/chrome/browser/cocoa/nswindow_local_state.h b/chrome/browser/cocoa/nswindow_local_state.h deleted file mode 100644 index 93be19bc..0000000 --- a/chrome/browser/cocoa/nswindow_local_state.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index 42bc948..0000000 --- a/chrome/browser/cocoa/nswindow_local_state.mm +++ /dev/null @@ -1,37 +0,0 @@ -// 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 deleted file mode 100644 index ccd4628..0000000 --- a/chrome/browser/cocoa/nswindow_local_state_unittest.mm +++ /dev/null @@ -1,71 +0,0 @@ -// 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 CocoaTest { - virtual void SetUp() { - CocoaTest::SetUp(); - path_ = L"NSWindowLocalStateTest"; - window_ = - [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 20, 20) - styleMask:NSTitledWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - browser_helper_.profile()->GetPrefs()->RegisterDictionaryPref(path_); - } - - virtual void TearDown() { - [window_ close]; - CocoaTest::TearDown(); - } - - public: - BrowserTestHelper browser_helper_; - 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 5ad689b..c8e5564 100644 --- a/chrome/browser/cocoa/page_info_window_controller.h +++ b/chrome/browser/cocoa/page_info_window_controller.h @@ -9,6 +9,7 @@ class PageInfoWindowMac; class PrefService; +@class WindowSizeAutosaver; // This NSWindowController subclass implements the Cocoa window for // PageInfoWindow. This creates and owns the PageInfoWindowMac subclass. @@ -34,6 +35,8 @@ class PrefService; // Bridge to Chromium that we own. scoped_ptr<PageInfoWindowMac> pageInfo_; + + scoped_nsobject<WindowSizeAutosaver> sizeSaver_; } @property(readwrite, retain) NSImage* identityImg; diff --git a/chrome/browser/cocoa/page_info_window_controller.mm b/chrome/browser/cocoa/page_info_window_controller.mm index 04c8049..144cfcb 100644 --- a/chrome/browser/cocoa/page_info_window_controller.mm +++ b/chrome/browser/cocoa/page_info_window_controller.mm @@ -8,17 +8,12 @@ #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/browser/cocoa/window_size_autosaver.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "grit/theme_resources.h" -@interface PageInfoWindowController (Private) -// Saves the window preference to the local state. -- (void)saveWindowPositionToLocalState; -@end - @implementation PageInfoWindowController @synthesize identityImg = identityImg_; @synthesize connectionImg = connectionImg_; @@ -36,18 +31,24 @@ ResourceBundle& rb = ResourceBundle::GetSharedInstance(); goodImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_GOOD) retain]); badImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_BAD) retain]); + + if (g_browser_process && g_browser_process->local_state()) { + sizeSaver_.reset([[WindowSizeAutosaver alloc] + initWithWindow:[self window] + prefService:g_browser_process->local_state() + path:prefs::kPageInfoWindowPlacement + state:kSaveWindowPos]); + // Cascade again to get the offset when opening new windows. + NSRect frame = [[self window] frame]; + NSPoint cascadePoint = [[self window] + cascadeTopLeftFromPoint:NSMakePoint(NSMinX(frame), NSMaxY(frame))]; + [[self window] cascadeTopLeftFromPoint:cascadePoint]; + } } return self; } - (void)awakeFromNib { - if (g_browser_process && g_browser_process->local_state()) { - // Get the positioning information. - PrefService* prefs = g_browser_process->local_state(); - [[self window] restoreWindowPositionFromPrefs:prefs - withPath:prefs::kPageInfoWindowPlacement]; - } - // By default, assume we have no history information. [self setShowHistoryBox:NO]; } @@ -103,12 +104,4 @@ [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()) - [[self window] saveWindowPositionToPrefs:g_browser_process->local_state() - withPath:prefs::kPageInfoWindowPlacement]; -} - @end diff --git a/chrome/browser/cocoa/task_manager_mac.h b/chrome/browser/cocoa/task_manager_mac.h index 5d78cff..b76f80a 100644 --- a/chrome/browser/cocoa/task_manager_mac.h +++ b/chrome/browser/cocoa/task_manager_mac.h @@ -10,6 +10,7 @@ #include "chrome/browser/cocoa/table_row_nsimage_cache.h" #include "chrome/browser/task_manager.h" +@class WindowSizeAutosaver; class TaskManagerMac; // This class is responsible for loading the task manager window and for @@ -21,6 +22,8 @@ class TaskManagerMac; TaskManagerMac* taskManagerObserver_; // weak TaskManager* taskManager_; // weak TaskManagerModel* model_; // weak + + scoped_nsobject<WindowSizeAutosaver> size_saver_; } // Creates and shows the task manager's window. diff --git a/chrome/browser/cocoa/task_manager_mac.mm b/chrome/browser/cocoa/task_manager_mac.mm index 8ff5e87..593d9a1 100644 --- a/chrome/browser/cocoa/task_manager_mac.mm +++ b/chrome/browser/cocoa/task_manager_mac.mm @@ -10,9 +10,11 @@ #include "app/l10n_util_mac.h" #include "base/mac_util.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/browser_process.h" +#import "chrome/browser/cocoa/window_size_autosaver.h" +#include "chrome/common/pref_names.h" #include "grit/generated_resources.h" -// TODO(thakis): Autoremember window size/pos (and selected columns?) // TODO(thakis): Better resizing behavior (and think about storing column sizes) // TODO(thakis): Column sort comparator // TODO(thakis): Clicking column header doesn't sort @@ -39,6 +41,14 @@ taskManagerObserver_ = taskManagerObserver; taskManager_ = taskManagerObserver_->task_manager(); model_ = taskManager_->model(); + + if (g_browser_process && g_browser_process->local_state()) { + size_saver_.reset([[WindowSizeAutosaver alloc] + initWithWindow:[self window] + prefService:g_browser_process->local_state() + path:prefs::kTaskManagerWindowPlacement + state:kSaveWindowRect]); + } [[self window] makeKeyAndOrderFront:self]; } return self; @@ -189,17 +199,6 @@ [self adjustEndProcessButton]; } -// Called when the window is being closed. Send out a notification that the user -// is done editing preferences. Make sure there are no pending field editors -// by clearing the first responder. -- (void)windowWillClose:(NSNotification*)notification { - if (taskManagerObserver_) { - taskManagerObserver_->WindowWasClosed(); - taskManagerObserver_ = nil; - } - [self autorelease]; -} - @end @implementation TaskManagerWindowController (NSTableDataSource) diff --git a/chrome/browser/cocoa/window_size_autosaver.h b/chrome/browser/cocoa/window_size_autosaver.h new file mode 100644 index 0000000..c8ace00 --- /dev/null +++ b/chrome/browser/cocoa/window_size_autosaver.h @@ -0,0 +1,45 @@ +// Copyright (c) 2010 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. + +#ifndef CHROME_BROWSER_COCOA_WINDOW_SIZE_AUTOSAVER_H_ +#define CHROME_BROWSER_COCOA_WINDOW_SIZE_AUTOSAVER_H_ + +class PrefService; +@class NSWindow; + +enum WindowSizeAutosaverState { + + // Autosave only the window's bottom-right corner. + kSaveWindowPos, + + // Autosave the whole window rect, i.e. both position and size. + kSaveWindowRect, +}; + +// WindowSizeAutosaver is a helper class that makes it easy to let windows +// autoremember their position or position and size in a PrefService object. +// To use this, add a |scoped_nsobject<WindowSizeAutosaver>| to your window +// controller and initialize it in the window controller's init method, passing +// a window and an autosave name. The autosaver will register for "window moved" +// and "window resized" notifications and write the current window state to the +// prefs service every time they fire. The window's size is automatically +// restored when the autosaver's |initWithWindow:...| method is called. +// +// Note: Your xib file should have "Visible at launch" UNCHECKED, so that the +// initial repositioning is not visible. +@interface WindowSizeAutosaver : NSObject { + NSWindow* window_; // weak + PrefService* prefService_; // weak + const wchar_t* path_; + WindowSizeAutosaverState state_; +} + +- (id)initWithWindow:(NSWindow*)window + prefService:(PrefService*)prefs + path:(const wchar_t*)path + state:(WindowSizeAutosaverState)state; +@end + +#endif // CHROME_BROWSER_COCOA_WINDOW_SIZE_AUTOSAVER_H_ + diff --git a/chrome/browser/cocoa/window_size_autosaver.mm b/chrome/browser/cocoa/window_size_autosaver.mm new file mode 100644 index 0000000..d8c0f77 --- /dev/null +++ b/chrome/browser/cocoa/window_size_autosaver.mm @@ -0,0 +1,95 @@ +// Copyright (c) 2010 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> + +#import "chrome/browser/cocoa/window_size_autosaver.h" + +#include "chrome/common/pref_service.h" + +@interface WindowSizeAutosaver (Private) +- (void)save:(NSNotification*)notification; +- (void)restore; +@end + +@implementation WindowSizeAutosaver + +- (id)initWithWindow:(NSWindow*)window + prefService:(PrefService*)prefs + path:(const wchar_t*)path + state:(WindowSizeAutosaverState)state { + if ((self = [super init])) { + window_ = window; + prefService_ = prefs; + path_ = path; + state_ = state; + + [self restore]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(save:) + name:NSWindowDidMoveNotification + object:window_]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(save:) + name:NSWindowDidResizeNotification + object:window_]; + } + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + +- (void)save:(NSNotification*)notification { + DictionaryValue* windowPrefs = prefService_->GetMutableDictionary(path_); + NSRect frame = [window_ frame]; + if (state_ == kSaveWindowRect) { + // Save the origin of the window. + windowPrefs->SetInteger(L"left", NSMinX(frame)); + windowPrefs->SetInteger(L"right", NSMaxX(frame)); + // windows's and linux's profiles have top < bottom due to having their + // screen origin in the upper left, while cocoa's is in the lower left. To + // keep the top < bottom invariant, store top in bottom and vice versa. + windowPrefs->SetInteger(L"top", NSMinY(frame)); + windowPrefs->SetInteger(L"bottom", NSMaxY(frame)); + } else if (state_ == kSaveWindowPos) { + // Save the origin of the window. + windowPrefs->SetInteger(L"x", frame.origin.x); + windowPrefs->SetInteger(L"y", frame.origin.y); + } else { + NOTREACHED(); + } +} + +- (void)restore { + // Get the positioning information. + DictionaryValue* windowPrefs = prefService_->GetMutableDictionary(path_); + if (state_ == kSaveWindowRect) { + int x1, x2, y1, y2; + if (!windowPrefs->GetInteger(L"left", &x1) || + !windowPrefs->GetInteger(L"right", &x2) || + !windowPrefs->GetInteger(L"top", &y1) || + !windowPrefs->GetInteger(L"bottom", &y2)) { + return; + } + [window_ setFrame:NSMakeRect(x1, y1, x2 - x1, y2 - y1) display:YES]; + } else if (state_ == kSaveWindowPos) { + int x, y; + if (!windowPrefs->GetInteger(L"x", &x) || + !windowPrefs->GetInteger(L"y", &y)) + return; // Nothing stored. + // Turn the origin (lower-left) into an upper-left window point. + NSPoint upperLeft = NSMakePoint(x, y + NSHeight([window_ frame])); + [window_ cascadeTopLeftFromPoint:upperLeft]; + } else { + NOTREACHED(); + } +} + +@end + diff --git a/chrome/browser/cocoa/window_size_autosaver_unittest.mm b/chrome/browser/cocoa/window_size_autosaver_unittest.mm new file mode 100644 index 0000000..e5460d4 --- /dev/null +++ b/chrome/browser/cocoa/window_size_autosaver_unittest.mm @@ -0,0 +1,157 @@ +// 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> + +#import "chrome/browser/cocoa/window_size_autosaver.h" + +#include "base/scoped_nsobject.h" +#include "chrome/browser/cocoa/browser_test_helper.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "chrome/common/pref_service.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" + +class WindowSizeAutosaverTest : public CocoaTest { + virtual void SetUp() { + CocoaTest::SetUp(); + path_ = L"WindowSizeAutosaverTest"; + window_ = + [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 101, 150, 151) + styleMask:NSTitledWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + browser_helper_.profile()->GetPrefs()->RegisterDictionaryPref(path_); + } + + virtual void TearDown() { + [window_ close]; + CocoaTest::TearDown(); + } + + public: + BrowserTestHelper browser_helper_; + NSWindow* window_; + const wchar_t* path_; +}; + +TEST_F(WindowSizeAutosaverTest, RestoresAndSavesPos) { + PrefService* pref = browser_helper_.profile()->GetPrefs(); + ASSERT_TRUE(pref != NULL); + + // Check to make sure there is no existing pref for window placement. + ASSERT_TRUE(pref->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. + + { + NSRect frame = [window_ frame]; + // Empty state, shouldn't restore: + scoped_nsobject<WindowSizeAutosaver> sizeSaver([[WindowSizeAutosaver alloc] + initWithWindow:window_ + prefService:pref + path:path_ + state:kSaveWindowPos]); + EXPECT_EQ(NSMinX(frame), NSMinX([window_ frame])); + EXPECT_EQ(NSMinY(frame), NSMinY([window_ frame])); + EXPECT_EQ(NSWidth(frame), NSWidth([window_ frame])); + EXPECT_EQ(NSHeight(frame), NSHeight([window_ frame])); + + // Move and resize window, should store position but not size. + [window_ setFrame:NSMakeRect(300, 310, 50, 52) display:NO]; + } + + // Another window movement -- shouldn't be recorded. + [window_ setFrame:NSMakeRect(400, 420, 160, 162) display:NO]; + + { + // Should restore last stored position, but not size. + scoped_nsobject<WindowSizeAutosaver> sizeSaver([[WindowSizeAutosaver alloc] + initWithWindow:window_ + prefService:pref + path:path_ + state:kSaveWindowPos]); + EXPECT_EQ(300, NSMinX([window_ frame])); + EXPECT_EQ(310, NSMinY([window_ frame])); + EXPECT_EQ(160, NSWidth([window_ frame])); + EXPECT_EQ(162, NSHeight([window_ frame])); + } + + // ...and it should be in the profile, too. + EXPECT_TRUE(pref->GetDictionary(path_) != NULL); + int x, y; + DictionaryValue* windowPref = pref->GetMutableDictionary(path_); + EXPECT_FALSE(windowPref->GetInteger(L"left", &x)); + EXPECT_FALSE(windowPref->GetInteger(L"right", &x)); + EXPECT_FALSE(windowPref->GetInteger(L"top", &x)); + EXPECT_FALSE(windowPref->GetInteger(L"bottom", &x)); + ASSERT_TRUE(windowPref->GetInteger(L"x", &x)); + ASSERT_TRUE(windowPref->GetInteger(L"y", &y)); + EXPECT_EQ(300, x); + EXPECT_EQ(310, y); +} + +TEST_F(WindowSizeAutosaverTest, RestoresAndSavesRect) { + PrefService* pref = browser_helper_.profile()->GetPrefs(); + ASSERT_TRUE(pref != NULL); + + // Check to make sure there is no existing pref for window placement. + ASSERT_TRUE(pref->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. + + { + NSRect frame = [window_ frame]; + // Empty state, shouldn't restore: + scoped_nsobject<WindowSizeAutosaver> sizeSaver([[WindowSizeAutosaver alloc] + initWithWindow:window_ + prefService:pref + path:path_ + state:kSaveWindowRect]); + EXPECT_EQ(NSMinX(frame), NSMinX([window_ frame])); + EXPECT_EQ(NSMinY(frame), NSMinY([window_ frame])); + EXPECT_EQ(NSWidth(frame), NSWidth([window_ frame])); + EXPECT_EQ(NSHeight(frame), NSHeight([window_ frame])); + + // Move and resize window, should store + [window_ setFrame:NSMakeRect(300, 310, 50, 52) display:NO]; + } + + // Another window movement -- shouldn't be recorded. + [window_ setFrame:NSMakeRect(400, 420, 160, 162) display:NO]; + + { + // Should restore last stored size + scoped_nsobject<WindowSizeAutosaver> sizeSaver([[WindowSizeAutosaver alloc] + initWithWindow:window_ + prefService:pref + path:path_ + state:kSaveWindowRect]); + EXPECT_EQ(300, NSMinX([window_ frame])); + EXPECT_EQ(310, NSMinY([window_ frame])); + EXPECT_EQ(50, NSWidth([window_ frame])); + EXPECT_EQ(52, NSHeight([window_ frame])); + } + + // ...and it should be in the profile, too. + EXPECT_TRUE(pref->GetDictionary(path_) != NULL); + int x1, y1, x2, y2; + DictionaryValue* windowPref = pref->GetMutableDictionary(path_); + EXPECT_FALSE(windowPref->GetInteger(L"x", &x1)); + EXPECT_FALSE(windowPref->GetInteger(L"y", &x1)); + ASSERT_TRUE(windowPref->GetInteger(L"left", &x1)); + ASSERT_TRUE(windowPref->GetInteger(L"right", &x2)); + ASSERT_TRUE(windowPref->GetInteger(L"top", &y1)); + ASSERT_TRUE(windowPref->GetInteger(L"bottom", &y2)); + EXPECT_EQ(300, x1); + EXPECT_EQ(310, y1); + EXPECT_EQ(300 + 50, x2); + EXPECT_EQ(310 + 52, y2); +} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 666ecf8..69680d1 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -522,8 +522,6 @@ 'browser/cocoa/multi_key_equivalent_button.mm', 'browser/cocoa/nsmenuitem_additions.h', 'browser/cocoa/nsmenuitem_additions.mm', - 'browser/cocoa/nswindow_local_state.h', - 'browser/cocoa/nswindow_local_state.mm', 'browser/cocoa/objc_method_swizzle.h', 'browser/cocoa/objc_method_swizzle.mm', 'browser/cocoa/page_info_window_controller.h', @@ -589,6 +587,8 @@ 'browser/cocoa/web_drag_source.mm', 'browser/cocoa/web_drop_target.h', 'browser/cocoa/web_drop_target.mm', + 'browser/cocoa/window_size_autosaver.h', + 'browser/cocoa/window_size_autosaver.mm', 'browser/command_updater.cc', 'browser/command_updater.h', 'browser/cookies_tree_model.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 7ed6e6a..5b70806 100755 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -634,7 +634,6 @@ 'browser/cocoa/menu_controller_unittest.mm', 'browser/cocoa/nsimage_cache_unittest.mm', 'browser/cocoa/nsmenuitem_additions_unittest.mm', - 'browser/cocoa/nswindow_local_state_unittest.mm', 'browser/cocoa/objc_method_swizzle_unittest.mm', 'browser/cocoa/page_info_window_controller_unittest.mm', 'browser/cocoa/preferences_window_controller_unittest.mm', @@ -662,6 +661,7 @@ 'browser/cocoa/view_resizer_pong.h', 'browser/cocoa/view_resizer_pong.mm', 'browser/cocoa/web_drop_target_unittest.mm', + 'browser/cocoa/window_size_autosaver_unittest.mm', 'browser/command_updater_unittest.cc', 'browser/cookies_tree_model_unittest.cc', 'browser/debugger/devtools_manager_unittest.cc', |