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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/autofill/card_unmask_prompt_bridge.mm
diff --git a/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_bridge.mm b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_bridge.mm
new file mode 100644
index 0000000000000000000000000000000000000000..242e1f6717b8fa94462afbd925ad678ceda36ec9
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/card_unmask_prompt_bridge.mm
@@ -0,0 +1,128 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
+#include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_bridge.h"
+#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
+#include "chrome/browser/ui/chrome_style.h"
+#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.h"
+#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h"
+#import "chrome/browser/ui/cocoa/key_equivalent_constants.h"
+#include "grit/generated_resources.h"
+#include "ui/base/cocoa/window_size_constants.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
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.
+const CGFloat kButtonGap = 6.0f;
+
+} // namespace
+
+namespace autofill {
+
+// static
+CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
+ CardUnmaskPromptController* controller) {
+ return new CardUnmaskPromptBridge(controller);
+}
+
+CardUnmaskPromptBridge::CardUnmaskPromptBridge(
+ CardUnmaskPromptController* controller)
+ : controller_(controller) {
+ sheet_controller_.reset([[CardUnmaskPromptCocoa alloc]
+ initWithWebContents:controller_->GetWebContents()
+ bridge:this]);
+ base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
+ [[CustomConstrainedWindowSheet alloc]
+ initWithCustomWindow:[sheet_controller_ window]]);
+ constrained_window_.reset(
+ new ConstrainedWindowMac(this, controller_->GetWebContents(), sheet));
+}
+
+CardUnmaskPromptBridge::~CardUnmaskPromptBridge() {
+}
+
+void CardUnmaskPromptBridge::ControllerGone() {
+}
+
+void CardUnmaskPromptBridge::DisableAndWaitForVerification() {
+}
+
+void CardUnmaskPromptBridge::GotVerificationResult(bool success) {
+}
+
+void CardUnmaskPromptBridge::CancelForTesting() {
+ PerformClose();
+}
+
+void CardUnmaskPromptBridge::OnConstrainedWindowClosed(
+ ConstrainedWindowMac* window) {
+ constrained_window_.reset();
+ controller_->OnUnmaskDialogClosed();
+}
+
+void CardUnmaskPromptBridge::PerformClose() {
+ constrained_window_->CloseWebContentsModalDialog();
+}
+
+} // autofill
+
+#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
+
+@implementation CardUnmaskPromptCocoa
+
+- (id)initWithWebContents:(content::WebContents*)webContents
+ bridge:(autofill::CardUnmaskPromptBridge*)bridge {
+ DCHECK(webContents);
+
+ NSRect frame = NSMakeRect(0, 0, 550, 600);
+ base::scoped_nsobject<ConstrainedWindowCustomWindow> window(
+ [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]);
+ if ((self = [super initWithWindow:window])) {
+ webContents_ = webContents;
+ cardUnmaskPromptBridge_ = bridge;
+
+ [self buildWindowButtons];
+ }
+ return self;
+}
+
+- (IBAction)closeSheet:(id)sender {
+ cardUnmaskPromptBridge_->PerformClose();
+}
+
+- (void)buildWindowButtons {
+ buttonContainer_.reset([[NSView alloc] initWithFrame:NSZeroRect]);
+
+ base::scoped_nsobject<NSButton> button(
+ [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
+ [button setTitle:l10n_util::GetNSStringWithFixup(IDS_CANCEL)];
+ [button setKeyEquivalent:kKeyEquivalentEscape];
+ [button setTarget:self];
+ [button setAction:@selector(closeSheet:)];
+ [button sizeToFit];
+ [buttonContainer_ addSubview:button];
+
+ CGFloat nextX = NSMaxX([button frame]) + kButtonGap;
+ button.reset([[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
+ [button setFrameOrigin:NSMakePoint(nextX, 0)];
+ [button setTitle:l10n_util::GetNSStringWithFixup(
+ IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON)];
+ [button setKeyEquivalent:kKeyEquivalentReturn];
+ [button setTarget:self];
+ [button setAction:@selector(closeSheet:)];
+ [button sizeToFit];
+ [buttonContainer_ addSubview:button];
+
+ const CGFloat dialogOffset = NSWidth([[self window] frame]) -
+ chrome_style::kHorizontalPadding -
+ NSMaxX([button frame]);
+ [buttonContainer_
+ setFrame:NSMakeRect(dialogOffset, chrome_style::kClientBottomPadding,
+ NSMaxX([button frame]), NSMaxY([button frame]))];
+
+ [[[self window] contentView] addSubview:buttonContainer_];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698