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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/card_unmask_prompt_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: Address groby@ comments for patch set 7. Created 5 years, 10 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_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
groby-ooo-7-16 2015/02/13 01:53:40 Kill a newline, save a whitespace;) (Here and at e
bondd 2015/02/13 02:37:13 Done.
18 const CGFloat kButtonGap = 6.0f;
19
20 } // namespace
21
22 namespace autofill {
23
24 // static
25 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
26 CardUnmaskPromptController* controller) {
27 return new CardUnmaskPromptBridge(controller);
28 }
29
30 CardUnmaskPromptBridge::CardUnmaskPromptBridge(
31 CardUnmaskPromptController* controller)
32 : controller_(controller) {
33 sheet_controller_.reset([[CardUnmaskPromptCocoa 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 CardUnmaskPromptBridge::~CardUnmaskPromptBridge() {
44 }
45
46 void CardUnmaskPromptBridge::ControllerGone() {
47 }
48
49 void CardUnmaskPromptBridge::DisableAndWaitForVerification() {
50 }
51
52 void CardUnmaskPromptBridge::GotVerificationResult(bool success) {
53 }
54
55 void CardUnmaskPromptBridge::CancelForTesting() {
56 PerformClose();
57 }
58
59 void CardUnmaskPromptBridge::OnConstrainedWindowClosed(
60 ConstrainedWindowMac* window) {
61 constrained_window_.reset();
62 controller_->OnUnmaskDialogClosed();
63 }
64
65 void CardUnmaskPromptBridge::PerformClose() {
66 constrained_window_->CloseWebContentsModalDialog();
67 }
68
69 } // autofill
70
71 #pragma mark CardUnmaskPromptCocoa
groby-ooo-7-16 2015/02/13 01:53:40 Only #pragma mark if it actually helps you editing
bondd 2015/02/13 02:37:13 Done. Added #pragma CardUnmaskPromptBridge as well
72
73 @implementation CardUnmaskPromptCocoa
74
75 - (id)initWithWebContents:(content::WebContents*)webContents
76 bridge:(autofill::CardUnmaskPromptBridge*)bridge {
77 DCHECK(webContents);
78
79 NSRect frame = NSMakeRect(0, 0, 550, 600);
80 base::scoped_nsobject<ConstrainedWindowCustomWindow> window(
81 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]);
82 if ((self = [super initWithWindow:window])) {
83 webContents_ = webContents;
84 cardUnmaskPromptBridge_ = bridge;
85
86 [self buildWindowButtons];
87 }
88 return self;
89 }
90
91 - (IBAction)closeSheet:(id)sender {
92 cardUnmaskPromptBridge_->PerformClose();
93 }
94
95 - (void)buildWindowButtons {
96 buttonContainer_.reset([[NSView alloc] initWithFrame:NSZeroRect]);
97
98 base::scoped_nsobject<NSButton> button(
99 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
100 [button setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)];
101 [button setKeyEquivalent:kKeyEquivalentEscape];
102 [button setTarget:self];
103 [button setAction:@selector(closeSheet:)];
104 [button sizeToFit];
105 [buttonContainer_ addSubview:button];
106
107 CGFloat nextX = NSMaxX([button frame]) + kButtonGap;
108 button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
109 [button setFrameOrigin:NSMakePoint(nextX, 0)];
110 [button setTitle:l10n_util::GetNSStringWithFixup(
111 IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON)];
112 [button setKeyEquivalent:kKeyEquivalentReturn];
113 [button setTarget:self];
114 [button setAction:@selector(closeSheet:)];
115 [button sizeToFit];
116 [buttonContainer_ addSubview:button];
117
118 const CGFloat dialogOffset = NSWidth([[self window] frame]) -
119 chrome_style::kHorizontalPadding -
120 NSMaxX([button frame]);
121 [buttonContainer_
122 setFrame:NSMakeRect(dialogOffset, chrome_style::kClientBottomPadding,
123 NSMaxX([button frame]), NSMaxY([button frame]))];
124
125 [[[self window] contentView] addSubview:buttonContainer_];
126 }
127
128 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698