summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/first_run_dialog.mm
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 21:49:05 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 21:49:05 +0000
commit1d8e4ce0743eed37a143d99e568c28abbe3202f1 (patch)
treece8c850b2fa6d8a87f419255c368817c02f23a4f /chrome/browser/cocoa/first_run_dialog.mm
parentf59a9c06d5cc9b7e0faace2b76582d3a12c3ec6c (diff)
downloadchromium_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/browser/cocoa/first_run_dialog.mm')
-rw-r--r--chrome/browser/cocoa/first_run_dialog.mm52
1 files changed, 52 insertions, 0 deletions
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