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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.mm

Issue 904613006: Autofill: First step toward CVC unmask prompt dialog on OSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove view_tester files and don't return WeakPtrs. Created 5 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
6 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h"
7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
8 #include "chrome/browser/ui/chrome_style.h"
9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h"
11 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h"
12 #include "grit/generated_resources.h"
13 #include "ui/base/cocoa/window_size_constants.h"
14 #include "ui/base/l10n/l10n_util.h"
15
16 namespace {
17 const CGFloat kButtonGap = 6.0f;
18 } // namespace
19
20 namespace autofill {
21
22 // static
23 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
24 CardUnmaskPromptController* controller) {
25 return new CardUnmaskPromptViewBridge(controller);
26 }
27
28 #pragma mark CardUnmaskPromptViewBridge
29
30 CardUnmaskPromptViewBridge::CardUnmaskPromptViewBridge(
31 CardUnmaskPromptController* controller)
32 : controller_(controller) {
33 sheet_controller_.reset([[CardUnmaskPromptViewCocoa alloc]
34 initWithWebContents:controller_->GetWebContents()
35 bridge:this]);
36 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
37 [[CustomConstrainedWindowSheet alloc]
38 initWithCustomWindow:[sheet_controller_ window]]);
39 constrained_window_.reset(
40 new ConstrainedWindowMac(this, controller_->GetWebContents(), sheet));
41 }
42
43 CardUnmaskPromptViewBridge::~CardUnmaskPromptViewBridge() {
44 }
45
46 void CardUnmaskPromptViewBridge::ControllerGone() {
47 }
48
49 void CardUnmaskPromptViewBridge::DisableAndWaitForVerification() {
50 }
51
52 void CardUnmaskPromptViewBridge::GotVerificationResult(bool success) {
53 }
54
55 void CardUnmaskPromptViewBridge::OnConstrainedWindowClosed(
56 ConstrainedWindowMac* window) {
57 constrained_window_.reset();
58 controller_->OnUnmaskDialogClosed();
59 }
60
61 void CardUnmaskPromptViewBridge::PerformClose() {
62 constrained_window_->CloseWebContentsModalDialog();
63 }
64
65 } // autofill
66
67 #pragma mark CardUnmaskPromptViewCocoa
68
69 @implementation CardUnmaskPromptViewCocoa
70
71 - (id)initWithWebContents:(content::WebContents*)webContents
72 bridge:(autofill::CardUnmaskPromptViewBridge*)bridge {
73 DCHECK(webContents);
74 DCHECK(bridge);
75
76 NSRect frame = NSMakeRect(0, 0, 550, 600);
77 base::scoped_nsobject<ConstrainedWindowCustomWindow> window(
78 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]);
79 if ((self = [super initWithWindow:window])) {
80 webContents_ = webContents;
81 bridge_ = bridge;
82
83 [self buildWindowButtons];
84 }
85 return self;
86 }
87
88 - (IBAction)closeSheet:(id)sender {
89 bridge_->PerformClose();
90 }
91
92 - (void)buildWindowButtons {
93 base::scoped_nsobject<NSView> buttonContainer(
94 [[NSView alloc] initWithFrame:NSZeroRect]);
95
96 base::scoped_nsobject<NSButton> button(
97 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
98 [button setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)];
99 [button setKeyEquivalent:kKeyEquivalentEscape];
100 [button setTarget:self];
101 [button setAction:@selector(closeSheet:)];
102 [button sizeToFit];
103 [buttonContainer addSubview:button];
104
105 CGFloat nextX = NSMaxX([button frame]) + kButtonGap;
106 button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
107 [button setFrameOrigin:NSMakePoint(nextX, 0)];
108 [button setTitle:l10n_util::GetNSStringWithFixup(
109 IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON)];
110 [button setKeyEquivalent:kKeyEquivalentReturn];
111 [button setTarget:self];
112 [button setAction:@selector(closeSheet:)];
113 [button sizeToFit];
114 [buttonContainer addSubview:button];
115
116 const CGFloat dialogOffset = NSWidth([[self window] frame]) -
117 chrome_style::kHorizontalPadding -
118 NSMaxX([button frame]);
119 [buttonContainer
120 setFrame:NSMakeRect(dialogOffset, chrome_style::kClientBottomPadding,
121 NSMaxX([button frame]), NSMaxY([button frame]))];
122
123 [[[self window] contentView] addSubview:buttonContainer];
124 }
125
126 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698