OLD | NEW |
---|---|
1 // Copyright (c) 2012 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/one_click_signin_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
9 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 9 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
10 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 10 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 NSPoint origin = [view frame].origin; | 22 NSPoint origin = [view frame].origin; |
23 origin.y += amount; | 23 origin.y += amount; |
24 [view setFrameOrigin:origin]; | 24 [view setFrameOrigin:origin]; |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 @implementation OneClickSigninBubbleController | 29 @implementation OneClickSigninBubbleController |
30 | 30 |
31 - (id)initWithBrowserWindowController:(BrowserWindowController*)controller | 31 - (id)initWithBrowserWindowController:(BrowserWindowController*)controller |
32 learnMoreCallback:(const base::Closure&)learnMoreCallback | 32 start_sync_callback:(const base::Callback<void(bool)>&) |
akalin
2012/05/17 00:39:24
line up : here too
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
Done.
| |
33 advancedCallback:(const base::Closure&)advancedCallback { | 33 start_sync_callback { |
34 NSWindow* parentWindow = [controller window]; | 34 NSWindow* parentWindow = [controller window]; |
35 | 35 |
36 // Set the anchor point to right below the wrench menu. | 36 // Set the anchor point to right below the wrench menu. |
37 NSView* wrenchButton = [[controller toolbarController] wrenchButton]; | 37 NSView* wrenchButton = [[controller toolbarController] wrenchButton]; |
38 const NSRect bounds = [wrenchButton bounds]; | 38 const NSRect bounds = [wrenchButton bounds]; |
39 NSPoint anchorPoint = NSMakePoint(NSMidX(bounds), NSMaxY(bounds)); | 39 NSPoint anchorPoint = NSMakePoint(NSMidX(bounds), NSMaxY(bounds)); |
40 anchorPoint = [wrenchButton convertPoint:anchorPoint toView:nil]; | 40 anchorPoint = [wrenchButton convertPoint:anchorPoint toView:nil]; |
41 anchorPoint = [parentWindow convertBaseToScreen:anchorPoint]; | 41 anchorPoint = [parentWindow convertBaseToScreen:anchorPoint]; |
42 | 42 |
43 if (self = [super initWithWindowNibPath:@"OneClickSigninBubble" | 43 if (self = [super initWithWindowNibPath:@"OneClickSigninBubble" |
44 parentWindow:parentWindow | 44 parentWindow:parentWindow |
45 anchoredAt:anchorPoint]) { | 45 anchoredAt:anchorPoint]) { |
46 learnMoreCallback_ = learnMoreCallback; | 46 start_sync_callback_ = start_sync_callback; |
47 advancedCallback_ = advancedCallback; | 47 DCHECK(!start_sync_callback_.is_null()); |
48 DCHECK(!learnMoreCallback_.is_null()); | |
49 DCHECK(!advancedCallback_.is_null()); | |
50 } | 48 } |
51 return self; | 49 return self; |
52 } | 50 } |
53 | 51 |
54 - (IBAction)ok:(id)sender { | 52 - (IBAction)ok:(id)sender { |
53 start_sync_callback_.Run(true); | |
55 [self close]; | 54 [self close]; |
56 } | 55 } |
57 | 56 |
58 - (IBAction)onClickLearnMoreLink:(id)sender { | 57 - (IBAction)undo:(id)sender { |
59 learnMoreCallback_.Run(); | 58 [self close]; |
60 } | 59 } |
61 | 60 |
62 - (IBAction)onClickAdvancedLink:(id)sender { | 61 - (IBAction)onClickAdvancedLink:(id)sender { |
63 advancedCallback_.Run(); | 62 start_sync_callback_.Run(false); |
63 // TODO(rogerta): why not close bubble now? | |
akalin
2012/05/17 00:39:24
Navigating to a page already closes the infobar on
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
Will close explicitly then. The advanced page com
| |
64 } | 64 } |
65 | 65 |
66 // TODO(rogerta): if the bubble is closed without interaction, need to call | |
67 // the callback with argument set to true. | |
68 | |
66 - (void)awakeFromNib { | 69 - (void)awakeFromNib { |
67 [super awakeFromNib]; | 70 [super awakeFromNib]; |
68 | 71 |
69 // Set the message text manually, since we have to interpolate the | 72 // Set the message text manually, since we have to interpolate the |
70 // product name. | 73 // product name. |
71 NSString* message = | 74 NSString* message = |
72 l10n_util::GetNSStringF( | 75 l10n_util::GetNSStringF( |
73 IDS_SYNC_PROMO_NTP_BUBBLE_MESSAGE, | 76 IDS_SYNC_PROMO_NTP_BUBBLE_MESSAGE, |
74 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 77 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
75 [messageField_ setStringValue:message]; | 78 [messageField_ setStringValue:message]; |
76 | 79 |
77 // Lay out the text controls from the bottom up. | 80 // Lay out the text controls from the bottom up. |
78 CGFloat totalYOffset = 0.0; | 81 CGFloat totalYOffset = 0.0; |
79 | 82 |
80 totalYOffset += | 83 totalYOffset += |
81 [GTMUILocalizerAndLayoutTweaker sizeToFitView:advancedLink_].height; | 84 [GTMUILocalizerAndLayoutTweaker sizeToFitView:advancedLink_].height; |
82 | 85 |
83 ShiftOriginY(learnMoreLink_, totalYOffset); | |
84 totalYOffset += | |
akalin
2012/05/17 00:39:24
why did you remove this?
Roger Tawa OOO till Jul 10th
2012/05/17 21:17:37
I removed this because the learn more link is no l
| |
85 [GTMUILocalizerAndLayoutTweaker sizeToFitView:learnMoreLink_].height; | |
86 | |
87 ShiftOriginY(messageField_, totalYOffset); | 86 ShiftOriginY(messageField_, totalYOffset); |
88 totalYOffset += | 87 totalYOffset += |
89 [GTMUILocalizerAndLayoutTweaker | 88 [GTMUILocalizerAndLayoutTweaker |
90 sizeToFitFixedWidthTextField:messageField_]; | 89 sizeToFitFixedWidthTextField:messageField_]; |
91 | 90 |
92 NSSize delta = NSMakeSize(0.0, totalYOffset); | 91 NSSize delta = NSMakeSize(0.0, totalYOffset); |
93 | 92 |
94 // Resize bubble and window to hold the controls. | 93 // Resize bubble and window to hold the controls. |
95 [GTMUILocalizerAndLayoutTweaker | 94 [GTMUILocalizerAndLayoutTweaker |
96 resizeViewWithoutAutoResizingSubViews:[self bubble] | 95 resizeViewWithoutAutoResizingSubViews:[self bubble] |
97 delta:delta]; | 96 delta:delta]; |
98 [GTMUILocalizerAndLayoutTweaker | 97 [GTMUILocalizerAndLayoutTweaker |
99 resizeWindowWithoutAutoResizingSubViews:[self window] | 98 resizeWindowWithoutAutoResizingSubViews:[self window] |
100 delta:delta]; | 99 delta:delta]; |
101 } | 100 } |
102 | 101 |
103 @end // OneClickSigninBubbleController | 102 @end // OneClickSigninBubbleController |
OLD | NEW |