OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/ui/browser_list.h" | |
Miranda Callahan
2012/01/10 22:25:47
nit: alphaordering
msw
2012/01/11 00:27:10
Done.
| |
9 #include "chrome/browser/search_engines/util.h" | 10 #include "chrome/browser/search_engines/util.h" |
10 #import "chrome/browser/ui/cocoa/l10n_util.h" | 11 #import "chrome/browser/ui/cocoa/l10n_util.h" |
11 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 12 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 | 15 |
15 @interface FirstRunBubbleController(Private) | 16 @interface FirstRunBubbleController(Private) |
16 - (id)initRelativeToView:(NSView*)view | 17 - (id)initRelativeToView:(NSView*)view |
17 offset:(NSPoint)offset | 18 offset:(NSPoint)offset |
18 profile:(Profile*)profile; | 19 profile:(Profile*)profile; |
(...skipping 28 matching lines...) Expand all Loading... | |
47 [self performSelector:@selector(closeIfNotKey) withObject:nil afterDelay:3]; | 48 [self performSelector:@selector(closeIfNotKey) withObject:nil afterDelay:3]; |
48 } | 49 } |
49 return self; | 50 return self; |
50 } | 51 } |
51 | 52 |
52 - (void)awakeFromNib { | 53 - (void)awakeFromNib { |
53 DCHECK(header_); | 54 DCHECK(header_); |
54 [header_ setStringValue:cocoa_l10n_util::ReplaceNSStringPlaceholders( | 55 [header_ setStringValue:cocoa_l10n_util::ReplaceNSStringPlaceholders( |
55 [header_ stringValue], GetDefaultSearchEngineName(profile_), NULL)]; | 56 [header_ stringValue], GetDefaultSearchEngineName(profile_), NULL)]; |
56 | 57 |
57 // Adapt window size to bottom buttons. Do this before all other layouting. | 58 // Adapt window size to contents. Do this before all other layouting. |
58 CGFloat dy = cocoa_l10n_util::VerticallyReflowGroup([[self bubble] subviews]); | 59 CGFloat dy = cocoa_l10n_util::VerticallyReflowGroup([[self bubble] subviews]); |
59 NSSize ds = NSMakeSize(0, dy); | 60 NSSize ds = NSMakeSize(0, dy); |
60 ds = [[self bubble] convertSize:ds toView:nil]; | 61 ds = [[self bubble] convertSize:ds toView:nil]; |
61 | 62 |
62 NSRect frame = [[self window] frame]; | 63 NSRect frame = [[self window] frame]; |
63 frame.origin.y -= ds.height; | 64 frame.origin.y -= ds.height; |
64 frame.size.height += ds.height; | 65 frame.size.height += ds.height; |
65 [[self window] setFrame:frame display:YES]; | 66 [[self window] setFrame:frame display:YES]; |
66 } | 67 } |
67 | 68 |
68 - (void)close { | 69 - (void)close { |
69 // If the window is closed before the timer is fired, cancel the timer, since | 70 // If the window is closed before the timer is fired, cancel the timer, since |
70 // it retains the controller. | 71 // it retains the controller. |
71 [NSObject cancelPreviousPerformRequestsWithTarget:self | 72 [NSObject cancelPreviousPerformRequestsWithTarget:self |
72 selector:@selector(closeIfNotKey) | 73 selector:@selector(closeIfNotKey) |
73 object:nil]; | 74 object:nil]; |
74 [super close]; | 75 [super close]; |
75 } | 76 } |
76 | 77 |
77 - (void)closeIfNotKey { | 78 - (void)closeIfNotKey { |
78 if (![[self window] isKeyWindow]) | 79 if (![[self window] isKeyWindow]) |
79 [self close]; | 80 [self close]; |
80 } | 81 } |
81 | 82 |
83 - (IBAction)onChange:(id)sender { | |
84 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | |
85 [self close]; | |
86 if (browser) | |
87 browser->OpenSearchEngineOptionsDialog(); | |
88 } | |
89 | |
82 @end // FirstRunBubbleController | 90 @end // FirstRunBubbleController |
OLD | NEW |