diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 21:49:05 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 21:49:05 +0000 |
commit | 1d8e4ce0743eed37a143d99e568c28abbe3202f1 (patch) | |
tree | ce8c850b2fa6d8a87f419255c368817c02f23a4f /chrome | |
parent | f59a9c06d5cc9b7e0faace2b76582d3a12c3ec6c (diff) | |
download | chromium_src-1d8e4ce0743eed37a143d99e568c28abbe3202f1.zip chromium_src-1d8e4ce0743eed37a143d99e568c28abbe3202f1.tar.gz chromium_src-1d8e4ce0743eed37a143d99e568c28abbe3202f1.tar.bz2 |
Implement temporary First Run Dialog on OS X
We use a modal dialog with a single checkbox on OS X.
We use the OSX defaults system since we want something quick and reliable. The
dialog is displayed at a very early stage in Chrome startup (Before any
subsystems start relying on the stats variable). This means there are a few
quirks in displaying the UI.
A change was also needed to our event handling code since when the dialog is
shown we spin an event loop at a very early stage in the process lifetime.
Changed default value for stats to false and updated unit tests to reflect that.
Also some misc. minor cleanup.
BUG=11971,12046
Review URL: http://codereview.chromium.org/115608
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/breakpad_mac.mm | 5 | ||||
-rw-r--r-- | chrome/app/nibs/en.lproj/FirstRunDialog.xib | 664 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 19 | ||||
-rw-r--r-- | chrome/browser/cocoa/first_run_dialog.h | 34 | ||||
-rw-r--r-- | chrome/browser/cocoa/first_run_dialog.mm | 52 | ||||
-rw-r--r-- | chrome/browser/cocoa/shell_dialogs_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/first_run_mac.mm | 54 | ||||
-rw-r--r-- | chrome/browser/google_update_settings_mac.mm | 12 | ||||
-rw-r--r-- | chrome/browser/google_update_settings_mac_unittest.mm | 6 | ||||
-rw-r--r-- | chrome/chrome.gyp | 4 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cc | 10 |
11 files changed, 850 insertions, 12 deletions
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm index 28afe27..9155e29 100644 --- a/chrome/app/breakpad_mac.mm +++ b/chrome/app/breakpad_mac.mm @@ -16,6 +16,9 @@ #include "chrome/installer/util/google_update_settings.h" #if !defined(GOOGLE_CHROME_BUILD) + +extern "C" { + // If we aren't compiling as a branded build, then add dummy versions of the // Breakpad functions so we don't have to link against Breakpad. @@ -36,6 +39,8 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { NOTREACHED(); } +} + #endif // !defined(GOOGLE_CHROME_BUILD) namespace { diff --git a/chrome/app/nibs/en.lproj/FirstRunDialog.xib b/chrome/app/nibs/en.lproj/FirstRunDialog.xib new file mode 100644 index 0000000..b041b6e --- /dev/null +++ b/chrome/app/nibs/en.lproj/FirstRunDialog.xib @@ -0,0 +1,664 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> + <data> + <int key="IBDocument.SystemTarget">1050</int> + <string key="IBDocument.SystemVersion">9G55</string> + <string key="IBDocument.InterfaceBuilderVersion">677</string> + <string key="IBDocument.AppKitVersion">949.43</string> + <string key="IBDocument.HIToolboxVersion">353.00</string> + <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> + <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="2"/> + </object> + <object class="NSArray" key="IBDocument.PluginDependencies"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + </object> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSCustomObject" id="1001"> + <string key="NSClassName">FirstRunDialogController</string> + </object> + <object class="NSCustomObject" id="1003"> + <string key="NSClassName">FirstResponder</string> + </object> + <object class="NSCustomObject" id="1004"> + <string key="NSClassName">NSApplication</string> + </object> + <object class="NSWindowTemplate" id="1005"> + <int key="NSWindowStyleMask">1</int> + <int key="NSWindowBacking">2</int> + <string key="NSWindowRect">{{196, 316}, {486, 194}}</string> + <int key="NSWTFlags">1610613760</int> + <string key="NSWindowTitle">Welcome to Google Chrome for Mac OS X</string> + <string key="NSWindowClass">NSWindow</string> + <nil key="NSViewClass"/> + <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <object class="NSView" key="NSWindowView" id="1006"> + <reference key="NSNextResponder"/> + <int key="NSvFlags">256</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTextField" id="502236431"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{17, 89}, {451, 85}}</string> + <reference key="NSSuperview" ref="1006"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="1018548691"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">1346371584</int> + <string type="base64-UTF8" key="NSContents">V2VsY29tZSB0byBHb29nbGUgQ2hyb21lIGZvciBNYWMgT1MgWCAtIERldmVsb3BlciBSZWxlYXNlIE9u +bHkKCkJvb2ttYXJrIGFuZCBwYXNzd29yZCBpbXBvcnQgYXJlIHVuYXZhaWxhYmxlIGF0IHRoaXMgdGlt +ZSwgYW5kIHlvdXIgY3VycmVudCBkZWZhdWx0IGJyb3dzZXIgd2lsbCByZW1haW4gdGhlIGRlZmF1bHQu +A</string> + <object class="NSFont" key="NSSupport" id="832514646"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">1.300000e+01</double> + <int key="NSfFlags">1044</int> + </object> + <reference key="NSControlView" ref="502236431"/> + <object class="NSColor" key="NSBackgroundColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlColor</string> + <object class="NSColor" key="NSColor" id="463577634"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> + </object> + </object> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlTextColor</string> + <object class="NSColor" key="NSColor" id="375704399"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MAA</bytes> + </object> + </object> + </object> + </object> + <object class="NSButton" id="949645676"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{18, 58}, {22, 25}}</string> + <reference key="NSSuperview" ref="1006"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="135453653"> + <int key="NSCellFlags">-2080244224</int> + <int key="NSCellFlags2">0</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="832514646"/> + <reference key="NSControlView" ref="949645676"/> + <int key="NSButtonFlags">1211912703</int> + <int key="NSButtonFlags2">130</int> + <object class="NSCustomResource" key="NSNormalImage"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSSwitch</string> + </object> + <object class="NSButtonImageSource" key="NSAlternateImage"> + <string key="NSImageName">NSSwitch</string> + </object> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSButton" id="585627708"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{194, 12}, {96, 32}}</string> + <reference key="NSSuperview" ref="1006"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="515660988"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents">OK</string> + <reference key="NSSupport" ref="832514646"/> + <reference key="NSControlView" ref="585627708"/> + <int key="NSButtonFlags">-2038284033</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string type="base64-UTF8" key="NSKeyEquivalent">DQ</string> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSScrollView" id="899181073"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">256</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSClipView" id="193016761"> + <reference key="NSNextResponder" ref="899181073"/> + <int key="NSvFlags">2304</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTextView" id="421721722"> + <reference key="NSNextResponder" ref="193016761"/> + <int key="NSvFlags">2322</int> + <string key="NSFrameSize">{433, 32}</string> + <reference key="NSSuperview" ref="193016761"/> + <object class="NSTextContainer" key="NSTextContainer" id="465558439"> + <object class="NSLayoutManager" key="NSLayoutManager"> + <object class="NSTextStorage" key="NSTextStorage"> + <object class="NSMutableString" key="NSString"> + <characters key="NS.bytes">Optional: Help make Google Chrome better by automatically sending usage statistics and crash reports to Google. Learn more</characters> + </object> + <object class="NSMutableArray" key="NSAttributes"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSDictionary"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSFont</string> + <string>NSParagraphStyle</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSFont"> + <string key="NSName">LucidaGrande-Bold</string> + <double key="NSSize">1.300000e+01</double> + <int key="NSfFlags">16</int> + </object> + <object class="NSParagraphStyle" id="755641935"> + <int key="NSAlignment">4</int> + <object class="NSArray" key="NSTabStops"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTextTab" id="1070966546"> + <double key="NSLocation">3.600000e+01</double> + </object> + <object class="NSTextTab" id="211679900"> + <double key="NSLocation">7.200000e+01</double> + </object> + <object class="NSTextTab" id="144751252"> + <double key="NSLocation">1.080000e+02</double> + </object> + <object class="NSTextTab" id="68538921"> + <double key="NSLocation">1.440000e+02</double> + </object> + <object class="NSTextTab" id="619543405"> + <double key="NSLocation">1.800000e+02</double> + </object> + <object class="NSTextTab" id="558567972"> + <double key="NSLocation">2.160000e+02</double> + </object> + <object class="NSTextTab" id="162838443"> + <double key="NSLocation">2.520000e+02</double> + </object> + <object class="NSTextTab" id="222845524"> + <double key="NSLocation">2.880000e+02</double> + </object> + <object class="NSTextTab" id="488780994"> + <double key="NSLocation">3.240000e+02</double> + </object> + <object class="NSTextTab" id="509357653"> + <double key="NSLocation">3.600000e+02</double> + </object> + <object class="NSTextTab" id="124538056"> + <double key="NSLocation">3.960000e+02</double> + </object> + <object class="NSTextTab" id="516925898"> + <double key="NSLocation">4.320000e+02</double> + </object> + </object> + </object> + </object> + </object> + <object class="NSDictionary"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSFont</string> + <string>NSParagraphStyle</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSFont" id="564347508"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">1.300000e+01</double> + <int key="NSfFlags">16</int> + </object> + <reference ref="755641935"/> + </object> + </object> + <object class="NSDictionary"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSFont</string> + <string>NSLink</string> + <string>NSParagraphStyle</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="564347508"/> + <object class="NSURL"> + <nil key="NS.base"/> + <string key="NS.relative">http://www.google.com/support/chrome/go/mac_usage_stats</string> + </object> + <object class="NSParagraphStyle"> + <int key="NSAlignment">4</int> + <object class="NSArray" key="NSTabStops"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="1070966546"/> + <reference ref="211679900"/> + <reference ref="144751252"/> + <reference ref="68538921"/> + <reference ref="619543405"/> + <reference ref="558567972"/> + <reference ref="162838443"/> + <reference ref="222845524"/> + <reference ref="488780994"/> + <reference ref="509357653"/> + <reference ref="124538056"/> + <reference ref="516925898"/> + </object> + </object> + </object> + </object> + </object> + <object class="NSMutableData" key="NSAttributeInfo"> + <bytes key="NS.bytes">CQBoAQoCA</bytes> + </object> + <nil key="NSDelegate"/> + </object> + <object class="NSMutableArray" key="NSTextContainers"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="465558439"/> + </object> + <int key="NSLMFlags">6</int> + <nil key="NSDelegate"/> + </object> + <reference key="NSTextView" ref="421721722"/> + <double key="NSWidth">4.330000e+02</double> + <int key="NSTCFlags">1</int> + </object> + <object class="NSTextViewSharedData" key="NSSharedData"> + <int key="NSFlags">2053</int> + <object class="NSColor" key="NSBackgroundColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MSAwAA</bytes> + </object> + <reference key="NSInsertionColor" ref="375704399"/> + <object class="NSDictionary" key="NSSelectedAttributes"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSBackgroundColor</string> + <string>NSColor</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">selectedTextBackgroundColor</string> + <reference key="NSColor" ref="463577634"/> + </object> + <object class="NSColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">selectedTextColor</string> + <reference key="NSColor" ref="375704399"/> + </object> + </object> + </object> + <nil key="NSMarkedAttributes"/> + <object class="NSDictionary" key="NSLinkAttributes"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSColor</string> + <string>NSUnderline</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSColor"> + <int key="NSColorSpace">1</int> + <bytes key="NSRGB">MCAwIDEAA</bytes> + </object> + <integer value="1"/> + </object> + </object> + <nil key="NSDefaultParagraphStyle"/> + </object> + <int key="NSTVFlags">6</int> + <string key="NSMaxSize">{866, 1e+07}</string> + <string key="NSMinize">{223, 0}</string> + <nil key="NSDelegate"/> + </object> + </object> + <string key="NSFrameSize">{433, 51}</string> + <reference key="NSSuperview" ref="899181073"/> + <reference key="NSNextKeyView" ref="421721722"/> + <reference key="NSDocView" ref="421721722"/> + <object class="NSColor" key="NSBGColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MSAwAA</bytes> + </object> + <object class="NSCursor" key="NSCursor"> + <string key="NSHotSpot">{4, -5}</string> + <int key="NSCursorType">1</int> + </object> + <int key="NScvFlags">2</int> + </object> + <object class="NSScroller" id="811607404"> + <reference key="NSNextResponder" ref="899181073"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{-100, -100}, {15, 133}}</string> + <reference key="NSSuperview" ref="899181073"/> + <reference key="NSTarget" ref="899181073"/> + <string key="NSAction">_doScroller:</string> + <double key="NSPercent">7.388889e-01</double> + </object> + <object class="NSScroller" id="550475465"> + <reference key="NSNextResponder" ref="899181073"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{-100, -100}, {87, 18}}</string> + <reference key="NSSuperview" ref="899181073"/> + <int key="NSsFlags">1</int> + <reference key="NSTarget" ref="899181073"/> + <string key="NSAction">_doScroller:</string> + <double key="NSCurValue">1.000000e+00</double> + <double key="NSPercent">9.456522e-01</double> + </object> + </object> + <string key="NSFrame">{{33, 31}, {433, 51}}</string> + <reference key="NSSuperview" ref="1006"/> + <reference key="NSNextKeyView" ref="193016761"/> + <int key="NSsFlags">0</int> + <reference key="NSVScroller" ref="811607404"/> + <reference key="NSHScroller" ref="550475465"/> + <reference key="NSContentView" ref="193016761"/> + </object> + </object> + <string key="NSFrameSize">{486, 194}</string> + <reference key="NSSuperview"/> + </object> + <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> + <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + </object> + </object> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <object class="NSMutableArray" key="connectionRecords"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">initialFirstResponder</string> + <reference key="source" ref="1005"/> + <reference key="destination" ref="585627708"/> + </object> + <int key="connectionID">9</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">CloseDialog:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="585627708"/> + </object> + <int key="connectionID">16</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">first_run_dialog_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="1005"/> + </object> + <int key="connectionID">17</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: stats_enabled_</string> + <reference key="source" ref="949645676"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="949645676"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">value: stats_enabled_</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">stats_enabled_</string> + <object class="NSDictionary" key="NSOptions"> + <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">22</int> + </object> + </object> + <object class="IBMutableOrderedSet" key="objectRecords"> + <object class="NSArray" key="orderedObjects"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBObjectRecord"> + <int key="objectID">0</int> + <object class="NSArray" key="object" id="1002"> + <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="1002"/> + <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="1002"/> + <string key="objectName">First Responder</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-3</int> + <reference key="object" ref="1004"/> + <reference key="parent" ref="1002"/> + <string key="objectName">Application</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1</int> + <reference key="object" ref="1005"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="1006"/> + </object> + <reference key="parent" ref="1002"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">2</int> + <reference key="object" ref="1006"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="502236431"/> + <reference ref="949645676"/> + <reference ref="899181073"/> + <reference ref="585627708"/> + </object> + <reference key="parent" ref="1005"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">3</int> + <reference key="object" ref="502236431"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="1018548691"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">4</int> + <reference key="object" ref="1018548691"/> + <reference key="parent" ref="502236431"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5</int> + <reference key="object" ref="949645676"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="135453653"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">6</int> + <reference key="object" ref="135453653"/> + <reference key="parent" ref="949645676"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">7</int> + <reference key="object" ref="585627708"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="515660988"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">8</int> + <reference key="object" ref="515660988"/> + <reference key="parent" ref="585627708"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">29</int> + <reference key="object" ref="899181073"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="421721722"/> + <reference ref="550475465"/> + <reference ref="811607404"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">32</int> + <reference key="object" ref="421721722"/> + <reference key="parent" ref="899181073"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">31</int> + <reference key="object" ref="550475465"/> + <reference key="parent" ref="899181073"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">30</int> + <reference key="object" ref="811607404"/> + <reference key="parent" ref="899181073"/> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="flattenedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>-1.IBPluginDependency</string> + <string>-2.IBPluginDependency</string> + <string>-3.IBPluginDependency</string> + <string>1.IBEditorWindowLastContentRect</string> + <string>1.IBPluginDependency</string> + <string>1.IBWindowTemplateEditedContentRect</string> + <string>1.NSWindowTemplate.visibleAtLaunch</string> + <string>1.WindowOrigin</string> + <string>1.editorWindowContentRectSynchronizationRect</string> + <string>2.IBPluginDependency</string> + <string>29.IBPluginDependency</string> + <string>3.IBPluginDependency</string> + <string>30.IBPluginDependency</string> + <string>31.IBPluginDependency</string> + <string>32.IBPluginDependency</string> + <string>4.IBPluginDependency</string> + <string>5.IBPluginDependency</string> + <string>6.IBPluginDependency</string> + <string>7.IBPluginDependency</string> + <string>8.IBPluginDependency</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{334, 559}, {486, 194}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{334, 559}, {486, 194}}</string> + <reference ref="6"/> + <string>{196, 240}</string> + <string>{{357, 418}, {480, 270}}</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> + <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> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + </object> + </object> + <object class="NSMutableDictionary" key="unlocalizedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="activeLocalization"/> + <object class="NSMutableDictionary" key="localizations"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="sourceID"/> + <int key="maxID">34</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"> + <object class="NSMutableArray" key="referencedPartialClassDescriptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">FirstRunDialogController</string> + <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="actions"> + <string key="NS.key.0">CloseDialog:</string> + <string key="NS.object.0">id</string> + </object> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">first_run_dialog_</string> + <string key="NS.object.0">NSWindow</string> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/first_run_dialog.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string> + </object> + </object> + </object> + </object> + <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.LastKnownRelativeProjectPath">../../../chrome.xcodeproj</string> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + </data> +</archive> diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 0f023c3..78ae72d 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -327,6 +327,18 @@ int BrowserMain(const MainFunctionParams& parameters) { local_state->RegisterStringPref(prefs::kApplicationLocale, L""); local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); +#if defined(OS_POSIX) + // On POSIX we display the first run dialog as early as possible, so we can + // get the stats enabled. + if (is_first_run && !first_run_ui_bypass) { + // Dummy value, we don't need the profile for the OS X version of this + // method at present. + Profile* profile = NULL; + OpenFirstRunDialog(profile, &process_singleton); + } +#endif // OS_POSIX + + // During first run we read the google_update registry key to find what // language the user selected when downloading the installer. This // becomes our default language in the prefs. @@ -511,6 +523,12 @@ int BrowserMain(const MainFunctionParams& parameters) { process_singleton.Create(); + // TODO: This block of code should probably be used on all platforms! + // On POSIX we need to display this dialog before setting the value of + // kMetricsReportingEnabled, so we display this dialog much earlier. + // On Windows a download is tagged with stats enabled/disabled so the UI + // can be displayed later in the startup process. +#if defined(OS_WIN) // Show the First Run UI if this is the first time Chrome has been run on // this computer, or we're being compelled to do so by a command line flag. // Note that this be done _after_ the PrefService is initialized and all @@ -519,6 +537,7 @@ int BrowserMain(const MainFunctionParams& parameters) { if (is_first_run && !first_run_ui_bypass) { OpenFirstRunDialog(profile, &process_singleton); } +#endif // OS_WIN // Sets things up so that if we crash from this point on, a dialog will // popup asking the user to restart chrome. It is done this late to avoid diff --git a/chrome/browser/cocoa/first_run_dialog.h b/chrome/browser/cocoa/first_run_dialog.h new file mode 100644 index 0000000..6d0f53a --- /dev/null +++ b/chrome/browser/cocoa/first_run_dialog.h @@ -0,0 +1,34 @@ +// 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. + +#ifndef CHROME_BROWSER_FIRST_RUN_DIALOG_H_ +#define CHROME_BROWSER_FIRST_RUN_DIALOG_H_ + +#import <Cocoa/Cocoa.h> + +// Class that acts as a controller for the temporary Modal first run dialog. +// The dialog asks the user's explicit permission for reporting stats to help +// us improve Chromium. +// This code is temporary and while we'd like to avoid modal dialogs at all +// costs, it's important to us, even at this early stage in development to +// to not send any stats back unless the user has explicitly consented. +// TODO: In the final version of this code, if we keep this class around, we +// should probably subclass from NSWindowController. +@interface FirstRunDialogController : NSObject { + IBOutlet NSWindow* first_run_dialog_; + bool stats_enabled_; +} + +// One shot method to show the dialog and return the value of the stats +// enabled/disabled checkbox. +// returns: +// true - stats enabled. +// flase - stats disabled. +- (bool)Show; + +// Called when the OK button is pressed. +- (IBAction)CloseDialog:(id)sender; +@end + +#endif // CHROME_BROWSER_FIRST_RUN_DIALOG_H_ diff --git a/chrome/browser/cocoa/first_run_dialog.mm b/chrome/browser/cocoa/first_run_dialog.mm new file mode 100644 index 0000000..cb4e0c9 --- /dev/null +++ b/chrome/browser/cocoa/first_run_dialog.mm @@ -0,0 +1,52 @@ +// 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 "chrome/browser/cocoa/first_run_dialog.h" + +#include "base/logging.h" +#include "base/mac_util.h" +#import "base/scoped_nsobject.h" + +@implementation FirstRunDialogController + +-(id)init { + self = [super init]; + if (self != nil) { + // Bound to the dialog checkbox, default to true. + stats_enabled_ = true; + } + return self; +} + +- (bool)Show { + // Load and instantiate our NIB + scoped_nsobject<NSNib> nib([[NSNib alloc] + initWithNibNamed:@"FirstRunDialog" + bundle:mac_util::MainAppBundle()]); + CHECK(nib); + [nib.get() instantiateNibWithOwner:self topLevelObjects:nil]; + CHECK(first_run_dialog_); // Should be set by above call. + + // Neat weirdness in the below code - the Application menu stays enabled + // while the window is open but selecting items from it (e.g. Quit) has + // no effect. I'm guessing that this is an artifact of us being a + // background-only application at this stage and displaying a modal + // window. + + // Display dialog. + [NSApp runModalForWindow:first_run_dialog_]; + // First run dialog has "release on close" disabled, otherwise the + // runModalForWindow call above crashes. + [first_run_dialog_ release]; + first_run_dialog_ = nil; + + return stats_enabled_; +} + +- (IBAction)CloseDialog:(id)sender { + [first_run_dialog_ close]; + [NSApp stopModal]; +} + +@end diff --git a/chrome/browser/cocoa/shell_dialogs_mac.mm b/chrome/browser/cocoa/shell_dialogs_mac.mm index 2c5a528..d439a5a 100644 --- a/chrome/browser/cocoa/shell_dialogs_mac.mm +++ b/chrome/browser/cocoa/shell_dialogs_mac.mm @@ -11,7 +11,7 @@ #include "base/logging.h" #include "base/scoped_cftyperef.h" -#include "base/scoped_nsobject.h" +#import "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" static const int kFileTypePopupTag = 1234; diff --git a/chrome/browser/first_run_mac.mm b/chrome/browser/first_run_mac.mm new file mode 100644 index 0000000..41bc9a5 --- /dev/null +++ b/chrome/browser/first_run_mac.mm @@ -0,0 +1,54 @@ +// 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. + +#include "chrome/browser/first_run.h" + +#import "base/scoped_nsobject.h" +#include "base/sys_string_conversions.h" +#import "chrome/app/breakpad_mac.h" +#import "chrome/browser/cocoa/first_run_dialog.h" +#include "chrome/installer/util/google_update_constants.h" +#include "chrome/installer/util/google_update_settings.h" + +// static +bool FirstRun::IsChromeFirstRun() { + // Use presence of kRegUsageStatsField key as an indicator of whether or not + // this is the first run. + // See chrome/browser/google_update_settings_mac.mm for details on why we use + // the defualts dictionary here. + NSUserDefaults* std_defaults = [NSUserDefaults standardUserDefaults]; + NSDictionary* defaults_dict = [std_defaults dictionaryRepresentation]; + NSString* collect_stats_key = base::SysWideToNSString( + google_update::kRegUsageStatsField); + + bool not_in_dict = [defaults_dict objectForKey:collect_stats_key] == nil; + return not_in_dict; +} + +void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { +// OpenFirstRunDialog is a no-op on non-branded builds. +#if defined(GOOGLE_CHROME_BUILD) + // Breakpad should not be enabled on first run until the user has explicitly + // opted-into stats. + // TODO: The behavior we probably want here is to enable Breakpad on first run + // but display a confirmation dialog before sending a crash report so we + // respect a user's privacy while still getting any crashes that might happen + // before this point. Then remove the need for that dialog here. + DCHECK(!IsCrashReporterEnabled()); + + scoped_nsobject<FirstRunDialogController> dialog( + [[FirstRunDialogController alloc] init]); + + bool stats_enabled = [dialog.get() Show]; + + GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); + + // Breakpad is normally enabled very early in the startup process, + // however, on the first run it's off by default. If the user opts-in to + // stats, enable breakpad. + if (stats_enabled) { + InitCrashReporter(); + } +#endif // defined(GOOGLE_CHROME_BUILD) +} diff --git a/chrome/browser/google_update_settings_mac.mm b/chrome/browser/google_update_settings_mac.mm index a246803..95ca90e 100644 --- a/chrome/browser/google_update_settings_mac.mm +++ b/chrome/browser/google_update_settings_mac.mm @@ -23,14 +23,14 @@ namespace google_update { const wchar_t kRegUsageStatsField[] = L"usagestats"; // Declared in a public namespace for testing purposes. -// If pref not set, assume true. +// If pref not set, assume false. bool GetCollectStatsConsentFromDictionary(NSDictionary* dict) { NSString* collect_stats_key = base::SysWideToNSString( google_update::kRegUsageStatsField); NSNumber* val = [dict objectForKey:collect_stats_key]; if (![val respondsToSelector:@selector(boolValue)]) { - return true; + return false; } return ([val boolValue] == YES); @@ -52,8 +52,12 @@ bool GoogleUpdateSettings::GetCollectStatsConsent() { // static bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { - NOTIMPLEMENTED(); - return false; + NSString* collect_stats_key = base::SysWideToNSString( + google_update::kRegUsageStatsField); + NSUserDefaults* std_defaults = [NSUserDefaults standardUserDefaults]; + BOOL val_to_store = consented ? YES : NO; + [std_defaults setBool:val_to_store forKey:collect_stats_key]; + return [std_defaults synchronize]; } // static diff --git a/chrome/browser/google_update_settings_mac_unittest.mm b/chrome/browser/google_update_settings_mac_unittest.mm index 89bd8f2..d24c843 100644 --- a/chrome/browser/google_update_settings_mac_unittest.mm +++ b/chrome/browser/google_update_settings_mac_unittest.mm @@ -24,9 +24,9 @@ class GoogleUpdateTest : public PlatformTest { TEST_F(GoogleUpdateTest, StatsConstent) { using google_update::GetCollectStatsConsentFromDictionary; - // Stats are on by default. + // Stats are off by default. NSDictionary* empty_dict = [NSDictionary dictionary]; - ASSERT_TRUE(GetCollectStatsConsentFromDictionary(empty_dict)); + ASSERT_FALSE(GetCollectStatsConsentFromDictionary(empty_dict)); NSString* collect_stats_key = base::SysWideToNSString( google_update::kRegUsageStatsField); @@ -49,5 +49,5 @@ TEST_F(GoogleUpdateTest, StatsConstent) { NSDictionary* wrong_type_dict = [NSDictionary dictionaryWithObject:empty_dict forKey:collect_stats_key]; - ASSERT_TRUE(GetCollectStatsConsentFromDictionary(wrong_type_dict)); + ASSERT_FALSE(GetCollectStatsConsentFromDictionary(wrong_type_dict)); } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 39f32cc..273f871 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -657,6 +657,8 @@ 'browser/cocoa/find_bar_cocoa_controller.mm', 'browser/cocoa/find_bar_view.h', 'browser/cocoa/find_bar_view.mm', + 'browser/cocoa/first_run_dialog.h', + 'browser/cocoa/first_run_dialog.mm', 'browser/cocoa/grow_box_view.h', 'browser/cocoa/grow_box_view.m', 'browser/cocoa/location_bar_cell.h', @@ -846,6 +848,7 @@ 'browser/find_notification_details.h', 'browser/first_run.cc', 'browser/first_run.h', + 'browser/first_run_mac.mm', 'browser/gears_integration.cc', 'browser/gears_integration.h', 'browser/google_update.cc', @@ -1928,6 +1931,7 @@ 'app/nibs/en.lproj/About.xib', 'app/nibs/en.lproj/BrowserWindow.xib', 'app/nibs/en.lproj/FindBar.xib', + 'app/nibs/en.lproj/FirstRunDialog.xib', 'app/nibs/en.lproj/MainMenu.xib', 'app/nibs/en.lproj/Preferences.xib', 'app/nibs/en.lproj/SaveAccessoryView.xib', diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc index 938398a..63f27da 100644 --- a/chrome/common/temp_scaffolding_stubs.cc +++ b/chrome/common/temp_scaffolding_stubs.cc @@ -135,12 +135,18 @@ bool ShellIntegration::IsDefaultBrowser() { //-------------------------------------------------------------------------- +#if defined(OS_LINUX) // static bool FirstRun::IsChromeFirstRun() { // http://code.google.com/p/chromium/issues/detail?id=11971 return false; } +void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { + NOTIMPLEMENTED(); +} +#endif // defined(OS_LINUX) + // static bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, const FilePath& master_prefs_path, @@ -174,10 +180,6 @@ bool Upgrade::SwapNewChromeExeIfPresent() { return true; } -void OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { - NOTIMPLEMENTED(); -} - //-------------------------------------------------------------------------- void InstallJankometer(const CommandLine&) { |