diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 15:54:48 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-29 15:54:48 +0000 |
commit | c1ca1c3b1a234281fd24b8ec9a1802c4055d07a0 (patch) | |
tree | d40bab9751445bce8ecdf5da8f238b6a18c1f497 /chrome | |
parent | 0519e110045415c8d674a8a5d0cdd587b9ce8e1f (diff) | |
download | chromium_src-c1ca1c3b1a234281fd24b8ec9a1802c4055d07a0.zip chromium_src-c1ca1c3b1a234281fd24b8ec9a1802c4055d07a0.tar.gz chromium_src-c1ca1c3b1a234281fd24b8ec9a1802c4055d07a0.tar.bz2 |
[Mac] Hook up part of the download preferences
Enable the download location path and the prompt-for-download settings.
BUG=22047
TEST=Preferences --> Under the hood, set download location, downloaded file is in new location.
TEST=Enable prompt for download location, download file, save panel comes up.
Review URL: http://codereview.chromium.org/239008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/nibs/Preferences.xib | 146 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 55 |
3 files changed, 175 insertions, 32 deletions
diff --git a/chrome/app/nibs/Preferences.xib b/chrome/app/nibs/Preferences.xib index 027c422..ac386ec5 100644 --- a/chrome/app/nibs/Preferences.xib +++ b/chrome/app/nibs/Preferences.xib @@ -13,7 +13,6 @@ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> <integer value="74"/> - <integer value="18"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -49,7 +48,7 @@ <nil key="NSViewClass"/> <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <object class="NSView" key="NSWindowView" id="408649839"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -63,7 +62,7 @@ <object class="NSTabViewItem" id="1024664267"> <string key="NSIdentifier">1</string> <object class="NSView" key="NSView" id="412364894"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder" ref="838559838"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1081,6 +1080,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <string key="NSFrame">{{10, 33}, {513, 453}}</string> + <reference key="NSSuperview" ref="838559838"/> </object> <string key="NSLabel">Basics</string> <reference key="NSColor" ref="592613688"/> @@ -1089,7 +1089,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSTabViewItem" id="614928174"> <string key="NSIdentifier">2</string> <object class="NSView" key="NSView" id="712581699"> - <reference key="NSNextResponder" ref="838559838"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1620,16 +1620,16 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSButton" id="423027085"> <reference key="NSNextResponder" ref="712581699"/> <int key="NSvFlags">268</int> - <string key="NSFrame">{{161, 117}, {117, 32}}</string> + <string key="NSFrame">{{165, 83}, {129, 32}}</string> <reference key="NSSuperview" ref="712581699"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="309945174"> <int key="NSCellFlags">67239424</int> <int key="NSCellFlags2">134217728</int> - <string key="NSContents">Get themes…</string> + <string key="NSContents">Get Themes…</string> <reference key="NSSupport" ref="445696277"/> <reference key="NSControlView" ref="423027085"/> - <int key="NSButtonFlags">-2034876161</int> + <int key="NSButtonFlags">-2038284033</int> <int key="NSButtonFlags2">129</int> <string key="NSAlternateContents"/> <string key="NSKeyEquivalent"/> @@ -1640,7 +1640,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSButton" id="865039969"> <reference key="NSNextResponder" ref="712581699"/> <int key="NSvFlags">268</int> - <string key="NSFrame">{{274, 116}, {183, 32}}</string> + <string key="NSFrame">{{165, 115}, {183, 32}}</string> <reference key="NSSuperview" ref="712581699"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="270492768"> @@ -1659,7 +1659,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <string key="NSFrame">{{10, 33}, {513, 453}}</string> - <reference key="NSSuperview" ref="838559838"/> </object> <string key="NSLabel">Personal Stuff</string> <reference key="NSColor" ref="592613688"/> @@ -1755,19 +1754,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="NSTabView" ref="838559838"/> </object> </object> - <reference key="NSSelectedTabViewItem" ref="614928174"/> + <reference key="NSSelectedTabViewItem" ref="1024664267"/> <reference key="NSFont" ref="445696277"/> <int key="NSTvFlags">0</int> <bool key="NSAllowTruncatedLabels">YES</bool> <bool key="NSDrawsBackground">YES</bool> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="712581699"/> + <reference ref="412364894"/> </object> </object> </object> <string key="NSFrameSize">{559, 515}</string> - <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> @@ -1777,6 +1775,26 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <int key="NSvFlags">268</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSButton" id="602116533"> + <reference key="NSNextResponder" ref="1016273328"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{354, 331}, {98, 32}}</string> + <reference key="NSSuperview" ref="1016273328"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="82310084"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents">Browse…</string> + <reference key="NSSupport" ref="445696277"/> + <reference key="NSControlView" ref="602116533"/> + <int key="NSButtonFlags">-2038284033</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> <object class="NSTextField" id="1032231978"> <reference key="NSNextResponder" ref="1016273328"/> <int key="NSvFlags">268</int> @@ -2153,7 +2171,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>NSFilenamesPboardType</string> </object> </object> - <string key="NSFrame">{{20, 333}, {179, 26}}</string> + <string key="NSFrame">{{25, 339}, {322, 22}}</string> <reference key="NSSuperview" ref="1016273328"/> <bool key="NSEnabled">YES</bool> <object class="NSPathCell" key="NSCell" id="25958950"> @@ -2161,21 +2179,24 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <int key="NSCellFlags2">0</int> <reference key="NSSupport" ref="445696277"/> <reference key="NSControlView" ref="484273049"/> + <object class="NSColor" key="NSBackgroundColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MSAwAA</bytes> + </object> <object class="NSMutableArray" key="NSPathComponentCells"> <bool key="EncodedWithXMLCoder">YES</bool> </object> - <int key="NSPathStyle">2</int> <reference key="NSDelegate" ref="484273049"/> </object> </object> <object class="NSButton" id="928184762"> <reference key="NSNextResponder" ref="1016273328"/> <int key="NSvFlags">268</int> - <string key="NSFrame">{{32, 309}, {323, 18}}</string> + <string key="NSFrame">{{26, 309}, {323, 18}}</string> <reference key="NSSuperview" ref="1016273328"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="731161158"> - <int key="NSCellFlags">-1543373312</int> + <int key="NSCellFlags">-2080244224</int> <int key="NSCellFlags2">0</int> <string key="NSContents">Ask where to save each file before downloading</string> <reference key="NSSupport" ref="445696277"/> @@ -2823,6 +2844,54 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <int key="connectionID">474</int> </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: askForSaveLocation</string> + <reference key="source" ref="928184762"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="928184762"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">value: askForSaveLocation</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">askForSaveLocation</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">475</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">browseDownloadLocation:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="602116533"/> + </object> + <int key="connectionID">478</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">downloadLocationControl_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="484273049"/> + </object> + <int key="connectionID">479</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: defaultDownloadLocation</string> + <reference key="source" ref="484273049"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="484273049"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">value: defaultDownloadLocation</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">defaultDownloadLocation</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">480</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -2932,8 +3001,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference ref="885386403"/> <reference ref="987908490"/> <reference ref="854747859"/> - <reference ref="423027085"/> <reference ref="865039969"/> + <reference ref="423027085"/> </object> <reference key="parent" ref="614928174"/> </object> @@ -3208,11 +3277,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference ref="913832943"/> <reference ref="685290609"/> <reference ref="630848197"/> - <reference ref="484273049"/> - <reference ref="928184762"/> <reference ref="777041502"/> <reference ref="346222444"/> <reference ref="1054376288"/> + <reference ref="928184762"/> + <reference ref="484273049"/> + <reference ref="602116533"/> </object> <reference key="parent" ref="0"/> <string key="objectName">Under The Hood</string> @@ -3895,6 +3965,20 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="object" ref="270492768"/> <reference key="parent" ref="865039969"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">476</int> + <reference key="object" ref="602116533"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="82310084"/> + </object> + <reference key="parent" ref="1016273328"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">477</int> + <reference key="object" ref="82310084"/> + <reference key="parent" ref="602116533"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -3998,11 +4082,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>44.IBPluginDependency</string> <string>45.IBPluginDependency</string> <string>457.IBPluginDependency</string> - <string>458.CustomClassName</string> <string>458.IBPluginDependency</string> <string>47.IBPluginDependency</string> <string>472.IBPluginDependency</string> <string>473.IBPluginDependency</string> + <string>476.IBPluginDependency</string> + <string>477.IBPluginDependency</string> <string>48.IBPluginDependency</string> <string>49.IBPluginDependency</string> <string>5.IBPluginDependency</string> @@ -4102,8 +4187,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{556, 284}, {559, 515}}</string> - <string>{{556, 284}, {559, 515}}</string> + <string>{{610, 327}, {559, 515}}</string> + <string>{{610, 327}, {559, 515}}</string> <boolean value="NO"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -4149,7 +4234,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>HyperlinkButtonCell</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -4218,7 +4304,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <nil key="sourceID"/> - <int key="maxID">476</int> + <int key="maxID">480</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -4247,14 +4333,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <object class="IBPartialClassDescription"> - <string key="className">HyperlinkButtonCell</string> - <string key="superclassName">NSButtonCell</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/hyperlink_button_cell.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> @@ -4291,6 +4369,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>addHomepage:</string> + <string>browseDownloadLocation:</string> <string>clearData:</string> <string>importData:</string> <string>makeDefaultBrowser:</string> @@ -4315,6 +4394,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="outlets"> @@ -4324,6 +4404,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>advancedScroller_</string> <string>advancedView_</string> <string>customPagesArrayController_</string> + <string>downloadLocationControl_</string> <string>tabView_</string> </object> <object class="NSMutableArray" key="dict.values"> @@ -4331,6 +4412,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>NSScrollView</string> <string>NSView</string> <string>NSArrayController</string> + <string>NSPathControl</string> <string>NSTabView</string> </object> </object> diff --git a/chrome/browser/cocoa/preferences_window_controller.h b/chrome/browser/cocoa/preferences_window_controller.h index 5aa8b95..66bc78a 100644 --- a/chrome/browser/cocoa/preferences_window_controller.h +++ b/chrome/browser/cocoa/preferences_window_controller.h @@ -60,6 +60,9 @@ class Profile; BooleanPrefMember safeBrowsing_; BooleanPrefMember metricsRecording_; IntegerPrefMember cookieBehavior_; + IBOutlet NSPathControl* downloadLocationControl_; + StringPrefMember defaultDownloadLocation_; + BooleanPrefMember askForSaveLocation_; } // Designated initializer. |profile| should not be NULL. @@ -84,6 +87,9 @@ class Profile; - (IBAction)resetThemeToDefault:(id)sender; - (IBAction)themesGallery:(id)sender; +// Under the hood +- (IBAction)browseDownloadLocation:(id)sender; + // Usable from cocoa bindings to hook up the custom home pages table. @property(readonly) CustomHomePagesModel* customPagesSource; diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index b3f234d..8182420 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -74,6 +74,7 @@ std::wstring GetNewTabUIURLString() { - (void)setSafeBrowsing:(BOOL)value; - (void)setMetricsRecording:(BOOL)value; - (void)setCookieBehavior:(NSInteger)value; +- (void)setAskForSaveLocation:(BOOL)value; @end // A C++ class registered for changes in preferences. Bridges the @@ -201,6 +202,9 @@ class PrefObserverBridge : public NotificationObserver { metricsRecording_.Init(prefs::kMetricsReportingEnabled, local, observer_.get()); cookieBehavior_.Init(prefs::kCookieBehavior, prefs_, observer_.get()); + defaultDownloadLocation_.Init(prefs::kDownloadDefaultDirectory, prefs_, + observer_.get()); + askForSaveLocation_.Init(prefs::kPromptForDownload, prefs_, observer_.get()); } // Clean up what was registered in -registerPrefObservers. We only have to @@ -727,6 +731,38 @@ const int kDisabledIndex = 1; else if (*prefName == prefs::kCookieBehavior) { [self setCookieBehavior:cookieBehavior_.GetValue()]; } + else if (*prefName == prefs::kPromptForDownload) { + [self setAskForSaveLocation:askForSaveLocation_.GetValue() ? YES : NO]; + } +} + +// Set the new download path and notify the UI via KVO. +- (void)downloadPathPanelDidEnd:(NSOpenPanel*)panel + code:(NSInteger)returnCode + context:(void*)context { + if (returnCode == NSOKButton) { + [self recordUserAction:L"Options_SetDownloadDirectory"]; + NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item. + [self willChangeValueForKey:@"defaultDownloadLocation"]; + defaultDownloadLocation_.SetValue(base::SysNSStringToWide([path path])); + [self didChangeValueForKey:@"defaultDownloadLocation"]; + } +} + +// Bring up an open panel to allow the user to set a new downloads location. +- (void)browseDownloadLocation:(id)sender { + NSOpenPanel* panel = [NSOpenPanel openPanel]; + [panel setAllowsMultipleSelection:NO]; + [panel setCanChooseFiles:NO]; + [panel setCanChooseDirectories:YES]; + NSString* path = base::SysWideToNSString(defaultDownloadLocation_.GetValue()); + [panel beginSheetForDirectory:path + file:nil + types:nil + modalForWindow:[self window] + modalDelegate:self + didEndSelector:@selector(downloadPathPanelDidEnd:code:context:) + contextInfo:NULL]; } // Returns whether the alternate error page checkbox should be checked based @@ -860,6 +896,25 @@ const int kDisabledIndex = 1; cookieBehavior_.SetValue(policy); } +- (NSURL*)defaultDownloadLocation { + NSString* pathString = + base::SysWideToNSString(defaultDownloadLocation_.GetValue()); + return [NSURL fileURLWithPath:pathString]; +} + +- (BOOL)askForSaveLocation { + return askForSaveLocation_.GetValue(); +} + +- (void)setAskForSaveLocation:(BOOL)value { + if (value) { + [self recordUserAction:L"Options_AskForSaveLocation_Enable"]; + } else { + [self recordUserAction:L"Options_AskForSaveLocation_Disable"]; + } + askForSaveLocation_.SetValue(value); +} + //------------------------------------------------------------------------- // Callback when preferences are changed. |prefName| is the name of the |