From 8240e999612351e82d797a3274111241b5d99419 Mon Sep 17 00:00:00 2001 From: "jeremy@chromium.org" Date: Tue, 28 Jul 2009 15:56:12 +0000 Subject: Nice looking First-Run dialogs. * Switch NIB. * Use NSWindowController. * "Make default browser" button hooked up. * Import bookmarks still not implemented. Review URL: http://codereview.chromium.org/149512 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21844 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/nibs/FirstRunDialog.xib | 980 ++++++++++++++++++++----------- chrome/browser/cocoa/first_run_dialog.h | 39 +- chrome/browser/cocoa/first_run_dialog.mm | 53 +- chrome/browser/first_run_mac.mm | 23 +- 4 files changed, 712 insertions(+), 383 deletions(-) diff --git a/chrome/app/nibs/FirstRunDialog.xib b/chrome/app/nibs/FirstRunDialog.xib index 4c127a7..0ef319c 100644 --- a/chrome/app/nibs/FirstRunDialog.xib +++ b/chrome/app/nibs/FirstRunDialog.xib @@ -37,9 +37,9 @@ 1 2 - {{196, 240}, {507, 270}} - 1610613760 - Welcome to Google Chrome for Mac OS X + {{196, 215}, {480, 295}} + 536871936 + Welcome to Google Chrome NSWindow {3.40282e+38, 3.40282e+38} @@ -48,67 +48,65 @@ 256 YES - + 268 - {{17, 131}, {483, 119}} + {{63, 93}, {372, 39}} YES - + 67239424 - 1346371584 - V2VsY29tZSB0byBHb29nbGUgQ2hyb21lIGZvciBNYWMgT1MgWCAtIERldmVsb3BlciBSZWxlYXNlIE9u -bHkKClRoaXMgcmVsZWFzZSBpcyBub3QgYXBwcm9wcmlhdGUgZm9yIGdlbmVyYWwgY29uc3VtZXIgdXNl -LiBTZXZlcmFsIGZlYXR1cmVzLCBzdWNoIGFzIGJvb2ttYXJrIGFuZCBwYXNzd29yZCBpbXBvcnQgYW5k -IGNlcnRhaW4gcHJpdmFjeSBmZWF0dXJlcywgYXJlIHVuYXZhaWxhYmxlIGF0IHRoaXMgdGltZS4gIFBs -ZWFzZSBzZWUgb3VyIHByaXZhY3kgcG9saWN5IGZvciBmdXJ0aGVyIGRldGFpbHMgOiBodHRwOi8vd3d3 -Lmdvb2dsZS5jb20vY2hyb21lL2ludGwvZW4vcHJpdmFjeV9tYWMuaHRtbCAuICBZb3VyIGRlZmF1bHQg -YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 - + 272629760 + Help make Google Chrome better by automatically sending usage statistics and crash reports to Google + LucidaGrande 1.300000e+01 - 1044 + 16 - - + + 6 System controlColor - + 3 MC42NjY2NjY2OQA - + 6 System controlTextColor - + 3 MAA - + 268 - {{18, 86}, {22, 25}} + {{45, 139}, {235, 18}} YES - - -2080244224 + + 67239424 0 - - - + Make Chrome my default browser + + LucidaGrande + 1.300000e+01 + 1044 + + 1211912703 130 - + NSImage NSSwitch - + NSSwitch @@ -117,276 +115,332 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 25 - + 268 - {{201, 12}, {96, 32}} + {{45, 166}, {174, 18}} YES - - 67239424 - 134217728 - OK - - - -2038284033 - 129 + + -2080244224 + 0 + Import bookmarks from + + + 1211912703 + 130 + + - DQ + 200 25 - + + + 268 + {{222, 161}, {113, 26}} + + YES + + -2076049856 + 2048 + + + 109199615 + 129 + + + 400 + 75 + + + Safari + + 1048576 + 2147483647 + 1 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + YES + + + + Firefox + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + 1 + YES + YES + 2 + + + - 256 + 12 YES - - - 2304 + + + 256 YES - - - 2322 - {433, 31} - - - - - - Optional: Help make Google Chrome better by automatically sending usage statistics and crash reports to Google. Learn more - - - YES - - YES - - YES - NSFont - NSParagraphStyle - - - YES - - LucidaGrande-Bold - 1.300000e+01 - 16 - - - 4 - - YES - - 3.600000e+01 - - - 7.200000e+01 - - - 1.080000e+02 - - - 1.440000e+02 - - - 1.800000e+02 - - - 2.160000e+02 - - - 2.520000e+02 - - - 2.880000e+02 - - - 3.240000e+02 - - - 3.600000e+02 - - - 3.960000e+02 - - - 4.320000e+02 - - - - - - - YES - - YES - NSFont - NSParagraphStyle - - - YES - - LucidaGrande - 1.300000e+01 - 16 - - - - - - YES - - YES - NSFont - NSLink - NSParagraphStyle - - - YES - - - - http://www.google.com/support/chrome/go/mac_usage_stats - - - 4 - - YES - - - - - - - - - - - - - - - - - - - CQBoAQoCA - - - - - YES - - - 6 - - - - 4.330000e+02 - 1 + + + 268 + {{13, 25}, {342, 17}} + + YES + + 68288064 + 272630784 + Google Chrome is ready to complete your installation + + + + - - 2053 - - 3 - MSAwAA - - - + + + + 256 + + YES + YES - - YES - NSBackgroundColor - NSColor - - - YES - - 6 - System - selectedTextBackgroundColor - - - - 6 - System - selectedTextColor - - - + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type - - - YES - - YES - NSColor - NSUnderline - - - YES - - 1 - MCAwIDEAA - - - + + {{408, -25}, {96, 96}} + + YES + + 130560 + 33554432 + + NSImage + NSApplicationIcon - + 0 + 0 + 0 + YES - 6 - {866, 1e+07} - {223, 0} - + YES - {433, 50} - - - - + {480, 55} + + + + {{0, 244}, {480, 55}} + + {0, 0} + + 67239424 + 0 + Box + + LucidaGrande + 1.100000e+01 + 3100 + + + 6 + System + textBackgroundColor + 3 - MSAwAA + MQA - - {4, -5} - 1 - - 2 - - - 256 - {{-100, -100}, {15, 133}} - - - _doScroller: - 7.388889e-01 + + 3 + MCAwLjgwMDAwMDAxAA - - - 256 - {{-100, -100}, {87, 18}} - - 1 - - _doScroller: - 1.000000e+00 - 9.456522e-01 + + + 0 + 4 + 2 + NO + + + + + 12 + {{0, 241}, {480, 5}} + + {0, 0} + + 67239424 + 0 + Box + + + + 3 + MCAwLjgwMDAwMDAxAA - {{33, 60}, {433, 50}} + 3 + 2 + 0 + NO + + + + 268 + {{28, 199}, {228, 17}} - - 0 - - - + YES + + 68288064 + 272630784 + Google Chrome will do these tasks: + + + + + + + + + 268 + {{198, 12}, {96, 32}} + + YES + + 67239424 + 134217728 + Cancel + + + -2038284033 + 129 + + Gw + 200 + 25 + + + + + 268 + {{294, 12}, {172, 32}} + + YES + + 67239424 + 134217728 + Start Google Chrome + + + -2038284033 + 129 + + DQ + 200 + 25 + + + + + 12 + {{0, 58}, {480, 5}} + + {0, 0} + + 67239424 + 0 + Box + + + + 3 + MCAwLjgwMDAwMDAxAA + + + 3 + 2 + 0 + NO + + + + 268 + {{45, 109}, {322, 27}} + + YES + + -2080244224 + 134217728 + + + + 1211912703 + 130 + + + + + 200 + 25 + + + + + 268 + {{54, 76}, {86, 19}} + + YES + + -2080244224 + 134217728 + Learn more + + LucidaGrande + 1.200000e+01 + 16 + + + -2046541569 + 164 + + + 400 + 75 + - {507, 270} + {480, 295} {{0, 0}, {1680, 1028}} @@ -398,47 +452,99 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 YES - initialFirstResponder - - + window + + - 9 + 65 - - CloseDialog: - - + + value: importBookmarks + + + + + + value: importBookmarks + value + importBookmarks + 2 + - 16 + 66 - - first_run_dialog_ - - + + selectedIndex: browserImportSelectedIndex + + + + + + selectedIndex: browserImportSelectedIndex + selectedIndex + browserImportSelectedIndex + 2 + - 17 + 67 - value: stats_enabled_ - + value: makeDefaultBrowser + - + - value: stats_enabled_ + value: makeDefaultBrowser value - stats_enabled_ - - NSAllowsEditingMultipleValuesSelection - - + makeDefaultBrowser + 2 + + + 68 + + + + value: statsEnabled + + + + + + value: statsEnabled + value + statsEnabled 2 - 22 + 69 + + + + cancel: + + + + 71 + + + + ok: + + + + 72 + + + + learnMore: + + + + 73 @@ -484,80 +590,218 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 YES - - - - + + + + + + + + + + + + - 3 - + 11 + YES - + + 12 + + + + + 13 + + + YES + + + + + + 14 + + + + + 15 + + + YES + + + + + + 16 + + + YES + + + + + + 17 + + + YES + + + + + + + 18 + + + + + 19 + + + + + 21 + + + YES + + + + + + + 22 + + + + + 3 + + + YES + + + + + 4 - - + + + + + 9 + + + YES + + + - 5 - + 10 + + + + + 23 + YES - + - 6 - - + 24 + + - 7 - + 25 + YES - + - 8 - - + 26 + + + + + 27 + + + YES + + + + + + 28 + + 29 - + + + + + 30 + YES - - - + + 31 + + + + 32 - - + + + YES + + + - 31 - - + 33 + + - 30 - - + 36 + + + YES + + + + + + 37 + + @@ -574,27 +818,44 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 1.NSWindowTemplate.visibleAtLaunch 1.WindowOrigin 1.editorWindowContentRectSynchronizationRect + 11.IBPluginDependency + 12.IBPluginDependency + 13.IBPluginDependency + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBEditorWindowLastContentRect + 17.IBPluginDependency + 18.IBPluginDependency + 19.IBPluginDependency 2.IBPluginDependency + 21.IBPluginDependency + 22.IBPluginDependency + 23.IBPluginDependency + 24.IBPluginDependency + 25.IBPluginDependency + 26.IBPluginDependency + 27.IBPluginDependency + 28.IBPluginDependency 29.IBPluginDependency 3.IBPluginDependency 30.IBPluginDependency 31.IBPluginDependency 32.IBPluginDependency + 33.IBPluginDependency + 36.IBPluginDependency + 37.IBPluginDependency 4.IBPluginDependency - 5.IBPluginDependency - 6.IBPluginDependency - 7.IBPluginDependency - 8.IBPluginDependency YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{-1478, 664}, {507, 270}} + {{638, 518}, {480, 295}} com.apple.InterfaceBuilder.CocoaPlugin - {{-1478, 664}, {507, 270}} - + {{638, 518}, {480, 295}} + {196, 240} {{357, 418}, {480, 270}} com.apple.InterfaceBuilder.CocoaPlugin @@ -603,6 +864,23 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{336, 475}, {172, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -630,21 +908,30 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 - 34 + 73 YES FirstRunDialogController - NSObject + NSWindowController - CloseDialog: - id - - - first_run_dialog_ - NSWindow + YES + + YES + cancel: + learnMore: + ok: + showWindow: + + + YES + id + id + id + id + IBProjectSource @@ -655,13 +942,20 @@ YnJvd3NlciB3aWxsIHJlbWFpbiB0aGUgZGVmYXVsdC4 NSObject IBProjectSource + browser/cocoa/status_bubble_mac.h + + + + NSObject + + IBProjectSource browser/cocoa/tab_strip_model_observer_bridge.h 0 - ../../../chrome.xcodeproj + ../../chrome.xcodeproj 3 diff --git a/chrome/browser/cocoa/first_run_dialog.h b/chrome/browser/cocoa/first_run_dialog.h index 6d0f53a..f7f2a11 100644 --- a/chrome/browser/cocoa/first_run_dialog.h +++ b/chrome/browser/cocoa/first_run_dialog.h @@ -7,28 +7,33 @@ #import -// Class that acts as a controller for the temporary Modal first run dialog. +// Class that acts as a controller for the 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_; +@interface FirstRunDialogController : NSWindowController { + BOOL user_did_cancel_; + BOOL stats_enabled_; + BOOL make_default_browser_; + BOOL import_bookmarks_; + int browser_import_selected_index_; } -// 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 "Start Google Chrome" button is pressed. +- (IBAction)ok:(id)sender; + +// Cancel button calls this. +- (IBAction)cancel:(id)sender; + +// Called when the "Learn More" button is pressed. +- (IBAction)learnMore:(id)sender; + +// Properties for bindings +@property(assign) BOOL userDidCancel; +@property(assign) BOOL statsEnabled; +@property(assign) BOOL makeDefaultBrowser; +@property(assign) BOOL importBookmarks; +@property(assign) int browserImportSelectedIndex; -// 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 index cb4e0c9..7af9bcd 100644 --- a/chrome/browser/cocoa/first_run_dialog.mm +++ b/chrome/browser/cocoa/first_run_dialog.mm @@ -10,24 +10,23 @@ @implementation FirstRunDialogController --(id)init { - self = [super init]; +@synthesize userDidCancel = user_did_cancel_; +@synthesize statsEnabled = stats_enabled_; +@synthesize makeDefaultBrowser = make_default_browser_; +@synthesize importBookmarks = import_bookmarks_; +@synthesize browserImportSelectedIndex = browser_import_selected_index_; + +- (id)init { + self = [super initWithWindowNibName:@"FirstRunDialog"]; if (self != nil) { // Bound to the dialog checkbox, default to true. - stats_enabled_ = true; + stats_enabled_ = YES; + import_bookmarks_ = YES; } return self; } -- (bool)Show { - // Load and instantiate our NIB - scoped_nsobject 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. - +- (IBAction)showWindow:(id)sender { // 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 @@ -35,18 +34,30 @@ // 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_; + NSWindow* win = [self window]; + [NSApp runModalForWindow:win]; } -- (IBAction)CloseDialog:(id)sender { - [first_run_dialog_ close]; +- (void)closeDialog { + [[self window] close]; [NSApp stopModal]; } +- (IBAction)ok:(id)sender { + [self closeDialog]; +} + +- (IBAction)cancel:(id)sender { + [self closeDialog]; + [self setUserDidCancel:YES]; +} + +- (IBAction)learnMore:(id)sender { + // TODO(jeremy): Rather than always using English, set the language that + // Chrome is running in. + NSURL* learnMoreUrl = [NSURL URLWithString:@"http://www.google.com/support/" + "chrome/bin/answer.py?answer=96817&hl=en"]; + [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; +} + @end diff --git a/chrome/browser/first_run_mac.mm b/chrome/browser/first_run_mac.mm index 7292e9d..2764a31 100644 --- a/chrome/browser/first_run_mac.mm +++ b/chrome/browser/first_run_mac.mm @@ -8,6 +8,8 @@ #include "base/sys_string_conversions.h" #import "chrome/app/breakpad_mac.h" #import "chrome/browser/cocoa/first_run_dialog.h" +#include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/shell_integration.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_settings.h" @@ -44,9 +46,15 @@ bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { scoped_nsobject dialog( [[FirstRunDialogController alloc] init]); - bool stats_enabled = [dialog.get() Show]; + // FirstRunDialogController will call exit if "Cancel" is clicked. + [dialog.get() showWindow:nil]; - GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); + // If user clicked cancel, bail. + if ([dialog.get() userDidCancel]) { + return false; + } + + BOOL stats_enabled = [dialog.get() statsEnabled]; // 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 @@ -55,6 +63,17 @@ bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { InitCrashReporter(); InitCrashProcessInfo(); } + + GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); + + BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; + if (make_default_browser) { + bool success = ShellIntegration::SetAsDefaultBrowser(); + DCHECK(success); + } + + // TODO(jeremy): Import Bookmarks. + #endif // defined(GOOGLE_CHROME_BUILD) return true; } -- cgit v1.1