Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(719)

Side by Side Diff: chrome/browser/ui/cocoa/one_click_signin_bubble_controller.mm

Issue 10332185: Update behavior of one-click infobar to remove modal dialog, add "undo". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor comment fixes Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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)>&)
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 {
akalin 2012/05/18 17:57:03 remove this, too, since nothing is calling it yet
Roger Tawa OOO till Jul 10th 2012/05/23 17:13:02 Done.
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 [self close];
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];
(...skipping 18 matching lines...) Expand all
94 // Resize bubble and window to hold the controls. 97 // Resize bubble and window to hold the controls.
95 [GTMUILocalizerAndLayoutTweaker 98 [GTMUILocalizerAndLayoutTweaker
96 resizeViewWithoutAutoResizingSubViews:[self bubble] 99 resizeViewWithoutAutoResizingSubViews:[self bubble]
97 delta:delta]; 100 delta:delta];
98 [GTMUILocalizerAndLayoutTweaker 101 [GTMUILocalizerAndLayoutTweaker
99 resizeWindowWithoutAutoResizingSubViews:[self window] 102 resizeWindowWithoutAutoResizingSubViews:[self window]
100 delta:delta]; 103 delta:delta];
101 } 104 }
102 105
103 @end // OneClickSigninBubbleController 106 @end // OneClickSigninBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698