blob: cb4e0c9a4a90ff8a05464c7c0b040b4adc2b1815 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
|