diff options
Diffstat (limited to 'chrome/browser/cocoa')
-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 |
3 files changed, 87 insertions, 1 deletions
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; |