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

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: Make GTK ok and undo buttons the same size horizontally 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 BrowserWindow::StartSyncCallback&)
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(
54 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
55 [self close]; 55 [self close];
56 } 56 }
57 57
58 - (IBAction)onClickLearnMoreLink:(id)sender { 58 - (IBAction)onClickLearnMoreLink:(id)sender {
59 learnMoreCallback_.Run(); 59 // TODO(akalin): this method should be removed once the UI elements is
Peter Kasting 2012/05/24 22:25:18 Nit: is -> are
Roger Tawa OOO till Jul 10th 2012/05/25 16:04:08 Done.
60 // removed.
60 } 61 }
61 62
62 - (IBAction)onClickAdvancedLink:(id)sender { 63 - (IBAction)onClickAdvancedLink:(id)sender {
63 advancedCallback_.Run(); 64 start_sync_callback_.Run(
65 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
66 [self close];
64 } 67 }
65 68
69 // TODO(rogerta): if the bubble is closed without interaction, need to call
70 // the callback with argument set to SYNC_WITH_DEFAULT_SETTINGS.
71
66 - (void)awakeFromNib { 72 - (void)awakeFromNib {
67 [super awakeFromNib]; 73 [super awakeFromNib];
68 74
69 // Set the message text manually, since we have to interpolate the 75 // Set the message text manually, since we have to interpolate the
70 // product name. 76 // product name.
71 NSString* message = 77 NSString* message =
72 l10n_util::GetNSStringF( 78 l10n_util::GetNSStringF(
73 IDS_SYNC_PROMO_NTP_BUBBLE_MESSAGE, 79 IDS_SYNC_PROMO_NTP_BUBBLE_MESSAGE,
74 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); 80 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
75 [messageField_ setStringValue:message]; 81 [messageField_ setStringValue:message];
(...skipping 18 matching lines...) Expand all
94 // Resize bubble and window to hold the controls. 100 // Resize bubble and window to hold the controls.
95 [GTMUILocalizerAndLayoutTweaker 101 [GTMUILocalizerAndLayoutTweaker
96 resizeViewWithoutAutoResizingSubViews:[self bubble] 102 resizeViewWithoutAutoResizingSubViews:[self bubble]
97 delta:delta]; 103 delta:delta];
98 [GTMUILocalizerAndLayoutTweaker 104 [GTMUILocalizerAndLayoutTweaker
99 resizeWindowWithoutAutoResizingSubViews:[self window] 105 resizeWindowWithoutAutoResizingSubViews:[self window]
100 delta:delta]; 106 delta:delta];
101 } 107 }
102 108
103 @end // OneClickSigninBubbleController 109 @end // OneClickSigninBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698