Chromium Code Reviews| 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 7 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 8 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 8 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 9 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h" | 9 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 10 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 void PerformClose(OneClickSigninBubbleController* controller) { | 14 void PerformClose(OneClickSigninBubbleController* controller) { |
| 15 [controller close]; | 15 [controller close]; |
| 16 } | 16 } |
| 17 | 17 |
| 18 } // namespace | 18 } // namespace |
| 19 | 19 |
| 20 @implementation OneClickSigninBubbleController | 20 @implementation OneClickSigninBubbleController |
| 21 | 21 |
| 22 - (id)initWithBrowserWindowController:(BrowserWindowController*)controller | 22 - (id)initWithBrowserWindowController:(BrowserWindowController*)controller |
| 23 webContents:(content::WebContents*)webContents | |
| 24 errorMessage:(const string16&)errorMessage | |
| 23 callback:(const BrowserWindow::StartSyncCallback&) | 25 callback:(const BrowserWindow::StartSyncCallback&) |
| 24 syncCallback { | 26 syncCallback { |
| 25 viewController_.reset([[OneClickSigninViewController alloc] | 27 viewController_.reset([[OneClickSigninViewController alloc] |
| 26 initWithNibName:@"OneClickSigninBubble" | 28 initWithNibName:@"OneClickSigninBubble" |
| 27 webContents:NULL | 29 webContents:webContents |
| 28 syncCallback:syncCallback | 30 syncCallback:syncCallback |
| 29 closeCallback:base::Bind(PerformClose, self)]); | 31 closeCallback:base::Bind(PerformClose, self) |
| 32 isSyncDialog:false | |
|
Alexei Svitkine (slow)
2013/04/19 19:54:15
false -> NO
noms (inactive)
2013/04/22 15:28:07
Done.
| |
| 33 errorMessage:errorMessage]); | |
| 34 | |
| 30 NSWindow* parentWindow = [controller window]; | 35 NSWindow* parentWindow = [controller window]; |
| 31 | 36 |
| 32 // Set the anchor point to right below the wrench menu. | 37 // Set the anchor point to right below the wrench menu. |
| 33 NSView* wrenchButton = [[controller toolbarController] wrenchButton]; | 38 NSView* wrenchButton = [[controller toolbarController] wrenchButton]; |
| 34 const NSRect bounds = [wrenchButton bounds]; | 39 const NSRect bounds = [wrenchButton bounds]; |
| 35 NSPoint anchorPoint = NSMakePoint(NSMidX(bounds), NSMaxY(bounds)); | 40 NSPoint anchorPoint = NSMakePoint(NSMidX(bounds), NSMaxY(bounds)); |
| 36 anchorPoint = [wrenchButton convertPoint:anchorPoint toView:nil]; | 41 anchorPoint = [wrenchButton convertPoint:anchorPoint toView:nil]; |
| 37 anchorPoint = [parentWindow convertBaseToScreen:anchorPoint]; | 42 anchorPoint = [parentWindow convertBaseToScreen:anchorPoint]; |
| 38 | 43 |
| 39 // Create an empty window into which content is placed. | 44 // Create an empty window into which content is placed. |
| 40 NSRect viewBounds = [[viewController_ view] bounds]; | 45 NSRect viewBounds = [[viewController_ view] bounds]; |
| 41 scoped_nsobject<InfoBubbleWindow> window( | 46 scoped_nsobject<InfoBubbleWindow> window( |
| 42 [[InfoBubbleWindow alloc] initWithContentRect:viewBounds | 47 [[InfoBubbleWindow alloc] initWithContentRect:viewBounds |
| 43 styleMask:NSBorderlessWindowMask | 48 styleMask:NSBorderlessWindowMask |
| 44 backing:NSBackingStoreBuffered | 49 backing:NSBackingStoreBuffered |
| 45 defer:NO]); | 50 defer:NO]); |
| 46 if (self = [super initWithWindow:window | 51 if (self = [super initWithWindow:window |
| 47 parentWindow:parentWindow | 52 parentWindow:parentWindow |
| 48 anchoredAt:anchorPoint]) { | 53 anchoredAt:anchorPoint]) { |
| 49 [[window contentView] addSubview:[viewController_ view]]; | 54 [[window contentView] addSubview:[viewController_ view]]; |
| 50 // This class will release itself when the bubble closes. See | 55 // This class will release itself when the bubble closes. See |
| 51 // -[BaseBubbleController windowWillClose:]. | 56 // -[BaseBubbleController windowWillClose:]. |
| 52 [self retain]; | 57 [self retain]; |
| 53 } | 58 } |
| 59 | |
| 60 | |
|
Alexei Svitkine (slow)
2013/04/19 19:54:15
Nit: Remove extra blank line. One blank line here
noms (inactive)
2013/04/22 15:28:07
Done.
| |
| 54 return self; | 61 return self; |
| 55 } | 62 } |
| 56 | 63 |
| 57 - (OneClickSigninViewController*)viewController { | 64 - (OneClickSigninViewController*)viewController { |
| 58 return viewController_; | 65 return viewController_; |
| 59 } | 66 } |
| 60 | 67 |
| 61 - (void)windowWillClose:(NSNotification*)notification { | 68 - (void)windowWillClose:(NSNotification*)notification { |
| 62 [viewController_ viewWillClose]; | 69 [viewController_ viewWillClose]; |
| 63 [super windowWillClose:notification]; | 70 [super windowWillClose:notification]; |
| 64 } | 71 } |
| 65 | 72 |
| 66 @end // OneClickSigninBubbleController | 73 @end // OneClickSigninBubbleController |
| OLD | NEW |