diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 15:55:45 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 15:55:45 +0000 |
commit | 9a2668af70fefef3b25303b9cab561047c109c37 (patch) | |
tree | 89890c85db11c057f2f63c3753d10a11c32bab0e | |
parent | 67f3e65e1b7365184d6f439121fe9d36d41c1ced (diff) | |
download | chromium_src-9a2668af70fefef3b25303b9cab561047c109c37.zip chromium_src-9a2668af70fefef3b25303b9cab561047c109c37.tar.gz chromium_src-9a2668af70fefef3b25303b9cab561047c109c37.tar.bz2 |
Fix default browser info string to change text and color instead of hiding/showing. Record default browser metric.
Review URL: http://codereview.chromium.org/115129
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15638 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/en.lproj/Preferences.xib | 84 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 70 |
2 files changed, 104 insertions, 50 deletions
diff --git a/chrome/app/nibs/en.lproj/Preferences.xib b/chrome/app/nibs/en.lproj/Preferences.xib index 0249d7c..36e4008 100644 --- a/chrome/app/nibs/en.lproj/Preferences.xib +++ b/chrome/app/nibs/en.lproj/Preferences.xib @@ -8,7 +8,7 @@ <string key="IBDocument.HIToolboxVersion">352.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="5"/> + <integer value="39"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1141,22 +1141,26 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <int key="NSTitlePosition">0</int> <bool key="NSTransparent">NO</bool> </object> - <object class="NSTextField" id="886397425"> + <object class="NSTextField" id="402804707"> <reference key="NSNextResponder" ref="412364894"/> <int key="NSvFlags">268</int> - <string key="NSFrame">{{168, 10}, {242, 17}}</string> + <string key="NSFrame">{{168, 13}, {306, 14}}</string> <reference key="NSSuperview" ref="412364894"/> <bool key="NSEnabled">YES</bool> - <object class="NSTextFieldCell" key="NSCell" id="245266980"> + <object class="NSTextFieldCell" key="NSCell" id="448510798"> <int key="NSCellFlags">68288064</int> <int key="NSCellFlags2">272630784</int> <string key="NSContents">Chromium is not the default browser.</string> - <reference key="NSSupport" ref="445696277"/> - <reference key="NSControlView" ref="886397425"/> + <object class="NSFont" key="NSSupport"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">1.100000e+01</double> + <int key="NSfFlags">16</int> + </object> + <reference key="NSControlView" ref="402804707"/> <reference key="NSBackgroundColor" ref="592613688"/> <object class="NSColor" key="NSTextColor"> <int key="NSColorSpace">1</int> - <bytes key="NSRGB">MSAwIDAAA</bytes> + <bytes key="NSRGB">MCAwIDAAA</bytes> </object> </object> </object> @@ -1643,7 +1647,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <string key="NSFrame">{{10, 33}, {513, 453}}</string> </object> - <string key="NSLabel">Minor Tweaks</string> + <string key="NSLabel">User Data</string> <reference key="NSColor" ref="592613688"/> <reference key="NSTabView" ref="838559838"/> </object> @@ -2505,39 +2509,59 @@ ZGVkIGZpbGVzIGRvbid0IG9wZW4gYXV0b21hdGljYWxseS4</string> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">hidden: isDefaultBrowser</string> - <reference key="source" ref="886397425"/> + <string key="label">enabled: isDefaultBrowser</string> + <reference key="source" ref="192681043"/> <reference key="destination" ref="1001"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="886397425"/> + <reference key="NSSource" ref="192681043"/> <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">hidden: isDefaultBrowser</string> - <string key="NSBinding">hidden</string> + <string key="NSLabel">enabled: isDefaultBrowser</string> + <string key="NSBinding">enabled</string> <string key="NSKeyPath">isDefaultBrowser</string> + <object class="NSDictionary" key="NSOptions"> + <string key="NS.key.0">NSValueTransformerName</string> + <string key="NS.object.0">NSNegateBoolean</string> + </object> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">312</int> + <int key="connectionID">315</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">enabled: isDefaultBrowser</string> - <reference key="source" ref="192681043"/> + <string key="label">value: defaultBrowserText</string> + <reference key="source" ref="402804707"/> <reference key="destination" ref="1001"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="192681043"/> + <reference key="NSSource" ref="402804707"/> <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">enabled: isDefaultBrowser</string> - <string key="NSBinding">enabled</string> - <string key="NSKeyPath">isDefaultBrowser</string> + <string key="NSLabel">value: defaultBrowserText</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">defaultBrowserText</string> <object class="NSDictionary" key="NSOptions"> - <string key="NS.key.0">NSValueTransformerName</string> - <string key="NS.object.0">NSNegateBoolean</string> + <string key="NS.key.0">NSAllowsEditingMultipleValuesSelection</string> + <boolean value="NO" key="NS.object.0" id="6"/> </object> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">315</int> + <int key="connectionID">322</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">textColor: defaultBrowserTextColor</string> + <reference key="source" ref="402804707"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="402804707"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">textColor: defaultBrowserTextColor</string> + <string key="NSBinding">textColor</string> + <string key="NSKeyPath">defaultBrowserTextColor</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">323</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -2821,7 +2845,7 @@ ZGVkIGZpbGVzIGRvbid0IG9wZW4gYXV0b21hdGljYWxseS4</string> <reference ref="325467010"/> <reference ref="982570975"/> <reference ref="192681043"/> - <reference ref="886397425"/> + <reference ref="402804707"/> </object> <reference key="parent" ref="1024664267"/> </object> @@ -3671,17 +3695,17 @@ ZGVkIGZpbGVzIGRvbid0IG9wZW4gYXV0b21hdGljYWxseS4</string> </object> <object class="IBObjectRecord"> <int key="objectID">304</int> - <reference key="object" ref="886397425"/> + <reference key="object" ref="402804707"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="245266980"/> + <reference ref="448510798"/> </object> <reference key="parent" ref="412364894"/> </object> <object class="IBObjectRecord"> <int key="objectID">305</int> - <reference key="object" ref="245266980"/> - <reference key="parent" ref="886397425"/> + <reference key="object" ref="448510798"/> + <reference key="parent" ref="402804707"/> </object> </object> </object> @@ -3935,7 +3959,7 @@ ZGVkIGZpbGVzIGRvbid0IG9wZW4gYXV0b21hdGljYWxseS4</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{712, 586}, {559, 515}}</string> <string>{{712, 586}, {559, 515}}</string> - <boolean value="NO"/> + <reference ref="6"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -4030,7 +4054,7 @@ ZGVkIGZpbGVzIGRvbid0IG9wZW4gYXV0b21hdGljYWxseS4</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">315</int> + <int key="maxID">325</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index ed7b859..49dc364 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -4,6 +4,7 @@ #import "chrome/browser/cocoa/preferences_window_controller.h" +#include "app/l10n_util.h" #include "base/mac_util.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" @@ -18,6 +19,8 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/url_constants.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" NSString* const kUserDoneEditingPrefsNotification = @"kUserDoneEditingPrefsNotification"; @@ -165,30 +168,14 @@ class PrefObserverBridge : public NotificationObserver { paths = [paths setByAddingObject:@"restoreOnStartupIndex"]; } else if ([key isEqualToString:@"isDefaultBrowser"]) { paths = [paths setByAddingObject:@"defaultBrowser"]; + } else if ([key isEqualToString:@"defaultBrowserTextColor"]) { + paths = [paths setByAddingObject:@"defaultBrowser"]; + } else if ([key isEqualToString:@"defaultBrowserText"]) { + paths = [paths setByAddingObject:@"defaultBrowser"]; } return paths; } -// Called when the user clicks the button to make Chromium the default -// browser. Registers http and https. -- (IBAction)makeDefaultBrowser:(id)sender { - ShellIntegration::SetAsDefaultBrowser(); - - // Tickle KVO so that the UI updates. - [self setDefaultBrowser:YES]; -} - -// A stub setter so that we can trick KVO into thinking the UI needs -// to be updated. -- (void)setDefaultBrowser:(BOOL)ignore { - // Do nothing. -} - -// Returns if Chromium is the default browser. -- (BOOL)isDefaultBrowser { - return ShellIntegration::IsDefaultBrowser() ? YES : NO; -} - //------------------------------------------------------------------------- // Basics panel @@ -363,6 +350,49 @@ enum { kHomepageNewTabPage, kHomepageURL }; showPageOptionButtons_.SetValue(value ? true : false); } +// Called when the user clicks the button to make Chromium the default +// browser. Registers http and https. +- (IBAction)makeDefaultBrowser:(id)sender { + ShellIntegration::SetAsDefaultBrowser(); + [self recordUserAction:L"Options_SetAsDefaultBrowser"]; + // If the user made Chrome the default browser, then he/she arguably wants + // to be notified when that changes. + prefs_->SetBoolean(prefs::kCheckDefaultBrowser, true); + + // Tickle KVO so that the UI updates. + [self setDefaultBrowser:YES]; +} + +// A stub setter so that we can trick KVO into thinking the UI needs +// to be updated. +- (void)setDefaultBrowser:(BOOL)ignore { + // Do nothing. +} + +// Returns if Chromium is the default browser. +- (BOOL)isDefaultBrowser { + return ShellIntegration::IsDefaultBrowser() ? YES : NO; +} + +// Returns the text color of the "chromium is your default browser" text (green +// for yes, red for no). +- (NSColor*)defaultBrowserTextColor { + return [self isDefaultBrowser] ? + [NSColor colorWithCalibratedRed:0.0 green:135.0/255.0 blue:0 alpha:1.0] : + [NSColor colorWithCalibratedRed:135.0/255.0 green:0 blue:0 alpha:1.0]; +} + +// Returns the text for the "chromium is your default browser" string dependent +// on if Chromium actually is or not. +- (NSString*)defaultBrowserText { + BOOL isDefault = [self isDefaultBrowser]; + int stringId = isDefault ? IDS_OPTIONS_DEFAULTBROWSER_DEFAULT : + IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT; + std::wstring text = + l10n_util::GetStringF(stringId, l10n_util::GetString(IDS_PRODUCT_NAME)); + return base::SysWideToNSString(text); +} + //------------------------------------------------------------------------- // Minor Tweaks panel |