| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "base/strings/sys_string_conversions.h" | 5 #include "base/strings/sys_string_conversions.h" |
| 6 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 6 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 7 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | 7 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" |
| 8 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" | 8 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" |
| 9 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" | 9 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" |
| 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( | 31 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( |
| 32 CardUnmaskPromptController* controller) { | 32 CardUnmaskPromptController* controller) { |
| 33 return new CardUnmaskPromptViewBridge(controller); | 33 return new CardUnmaskPromptViewBridge(controller); |
| 34 } | 34 } |
| 35 | 35 |
| 36 #pragma mark CardUnmaskPromptViewBridge | 36 #pragma mark CardUnmaskPromptViewBridge |
| 37 | 37 |
| 38 CardUnmaskPromptViewBridge::CardUnmaskPromptViewBridge( | 38 CardUnmaskPromptViewBridge::CardUnmaskPromptViewBridge( |
| 39 CardUnmaskPromptController* controller) | 39 CardUnmaskPromptController* controller) |
| 40 : controller_(controller) { | 40 : controller_(controller) { |
| 41 view_controller_.reset([[CardUnmaskPromptViewCocoa alloc] | 41 view_controller_.reset( |
| 42 initWithWebContents:controller_->GetWebContents() | 42 [[CardUnmaskPromptViewCocoa alloc] initWithBridge:this]); |
| 43 bridge:this]); | |
| 44 | 43 |
| 45 // Setup the constrained window that will show the view. | 44 // Setup the constrained window that will show the view. |
| 46 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] | 45 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] |
| 47 initWithContentRect:[[view_controller_ view] bounds]]); | 46 initWithContentRect:[[view_controller_ view] bounds]]); |
| 48 [window setContentView:[view_controller_ view]]; | 47 [window setContentView:[view_controller_ view]]; |
| 49 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 48 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
| 50 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); | 49 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); |
| 51 constrained_window_.reset( | 50 constrained_window_.reset( |
| 52 new ConstrainedWindowMac(this, controller_->GetWebContents(), sheet)); | 51 new ConstrainedWindowMac(this, controller_->GetWebContents(), sheet)); |
| 53 } | 52 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 111 |
| 113 + (void)verticallyCenterSubviewsInView:(NSView*)view { | 112 + (void)verticallyCenterSubviewsInView:(NSView*)view { |
| 114 CGFloat height = NSHeight([view frame]); | 113 CGFloat height = NSHeight([view frame]); |
| 115 for (NSView* child in [view subviews]) { | 114 for (NSView* child in [view subviews]) { |
| 116 [child setFrameOrigin:NSMakePoint( | 115 [child setFrameOrigin:NSMakePoint( |
| 117 NSMinX([child frame]), | 116 NSMinX([child frame]), |
| 118 ceil((height - NSHeight([child frame])) * 0.5))]; | 117 ceil((height - NSHeight([child frame])) * 0.5))]; |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 | 120 |
| 122 - (id)initWithWebContents:(content::WebContents*)webContents | 121 - (id)initWithBridge:(autofill::CardUnmaskPromptViewBridge*)bridge { |
| 123 bridge:(autofill::CardUnmaskPromptViewBridge*)bridge { | |
| 124 DCHECK(webContents); | |
| 125 DCHECK(bridge); | 122 DCHECK(bridge); |
| 126 | 123 |
| 127 if ((self = [super initWithNibName:nil bundle:nil])) { | 124 if ((self = [super initWithNibName:nil bundle:nil])) |
| 128 webContents_ = webContents; | |
| 129 bridge_ = bridge; | 125 bridge_ = bridge; |
| 130 } | 126 |
| 131 return self; | 127 return self; |
| 132 } | 128 } |
| 133 | 129 |
| 134 - (IBAction)closeSheet:(id)sender { | 130 - (IBAction)closeSheet:(id)sender { |
| 135 bridge_->PerformClose(); | 131 bridge_->PerformClose(); |
| 136 } | 132 } |
| 137 | 133 |
| 138 - (void)loadView { | 134 - (void)loadView { |
| 139 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); | 135 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); |
| 140 DCHECK(controller); | 136 DCHECK(controller); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // Dialog size. | 278 // Dialog size. |
| 283 [mainView | 279 [mainView |
| 284 setFrameSize:NSMakeSize( | 280 setFrameSize:NSMakeSize( |
| 285 contentWidth + [mainView contentViewMargins].width * 2.0, | 281 contentWidth + [mainView contentViewMargins].width * 2.0, |
| 286 NSMaxY([title frame]) + chrome_style::kTitleTopPadding)]; | 282 NSMaxY([title frame]) + chrome_style::kTitleTopPadding)]; |
| 287 | 283 |
| 288 [self setView:mainView]; | 284 [self setView:mainView]; |
| 289 } | 285 } |
| 290 | 286 |
| 291 @end | 287 @end |
| OLD | NEW |