Chromium Code Reviews| 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" | |
| 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| 11 #include "chrome/browser/ui/chrome_style.h" | 10 #include "chrome/browser/ui/chrome_style.h" |
| 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" | 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" |
| 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" |
| 14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" | 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" |
| 15 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" | 14 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" |
| 16 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 17 #include "ui/base/cocoa/window_size_constants.h" | 16 #include "ui/base/cocoa/window_size_constants.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 | 18 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 void CardUnmaskPromptViewBridge::PerformClose() { | 79 void CardUnmaskPromptViewBridge::PerformClose() { |
| 81 constrained_window_->CloseWebContentsModalDialog(); | 80 constrained_window_->CloseWebContentsModalDialog(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // autofill | 83 } // autofill |
| 85 | 84 |
| 86 #pragma mark CardUnmaskPromptViewCocoa | 85 #pragma mark CardUnmaskPromptViewCocoa |
| 87 | 86 |
| 88 @implementation CardUnmaskPromptViewCocoa | 87 @implementation CardUnmaskPromptViewCocoa |
| 89 | 88 |
| 90 + (AutofillPopUpButton*)buildDatePopupWithModel:(ui::ComboboxModel&)model { | 89 + (NSPopUpButton*)buildDatePopupWithModel:(ui::ComboboxModel&)model { |
| 91 AutofillPopUpButton* popup = | 90 NSPopUpButton* popup = |
| 92 [[AutofillPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO]; | 91 [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO]; |
| 93 | 92 |
| 94 for (int i = 0; i < model.GetItemCount(); ++i) { | 93 for (int i = 0; i < model.GetItemCount(); ++i) { |
| 95 [popup addItemWithTitle:base::SysUTF16ToNSString(model.GetItemAt(i))]; | 94 [popup addItemWithTitle:base::SysUTF16ToNSString(model.GetItemAt(i))]; |
| 96 } | 95 } |
| 97 [popup setDefaultValue:base::SysUTF16ToNSString( | |
| 98 model.GetItemAt(model.GetDefaultIndex()))]; | |
|
bondd
2015/03/05 23:51:06
defaultValue is not currently used so it's safe to
| |
| 99 [popup sizeToFit]; | 96 [popup sizeToFit]; |
| 100 return popup; | 97 return popup; |
| 101 } | 98 } |
| 102 | 99 |
| 103 // Set |view|'s frame to the minimum dimensions required to contain all of its | 100 // Set |view|'s frame to the minimum dimensions required to contain all of its |
| 104 // subviews. | 101 // subviews. |
| 105 + (void)sizeToFitView:(NSView*)view { | 102 + (void)sizeToFitView:(NSView*)view { |
| 106 NSRect frame = NSZeroRect; | 103 NSRect frame = NSZeroRect; |
| 107 for (NSView* child in [view subviews]) { | 104 for (NSView* child in [view subviews]) { |
| 108 frame = NSUnionRect(frame, [child frame]); | 105 frame = NSUnionRect(frame, [child frame]); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 [instructions setAttributedStringValue:instructionsString]; | 169 [instructions setAttributedStringValue:instructionsString]; |
| 173 [mainView addSubview:instructions]; | 170 [mainView addSubview:instructions]; |
| 174 | 171 |
| 175 // Expiration date. | 172 // Expiration date. |
| 176 base::scoped_nsobject<NSView> expirationView; | 173 base::scoped_nsobject<NSView> expirationView; |
| 177 if (controller->ShouldRequestExpirationDate()) { | 174 if (controller->ShouldRequestExpirationDate()) { |
| 178 expirationView.reset([[NSView alloc] initWithFrame:NSZeroRect]); | 175 expirationView.reset([[NSView alloc] initWithFrame:NSZeroRect]); |
| 179 | 176 |
| 180 // Month. | 177 // Month. |
| 181 autofill::MonthComboboxModel monthModel; | 178 autofill::MonthComboboxModel monthModel; |
| 182 base::scoped_nsobject<AutofillPopUpButton> monthPopup( | 179 base::scoped_nsobject<NSPopUpButton> monthPopup( |
| 183 [CardUnmaskPromptViewCocoa buildDatePopupWithModel:monthModel]); | 180 [CardUnmaskPromptViewCocoa buildDatePopupWithModel:monthModel]); |
| 184 [expirationView addSubview:monthPopup]; | 181 [expirationView addSubview:monthPopup]; |
| 185 | 182 |
| 186 // Year. | 183 // Year. |
| 187 autofill::YearComboboxModel yearModel; | 184 autofill::YearComboboxModel yearModel; |
| 188 base::scoped_nsobject<AutofillPopUpButton> yearPopup( | 185 base::scoped_nsobject<NSPopUpButton> yearPopup( |
| 189 [CardUnmaskPromptViewCocoa buildDatePopupWithModel:yearModel]); | 186 [CardUnmaskPromptViewCocoa buildDatePopupWithModel:yearModel]); |
| 190 [expirationView addSubview:yearPopup]; | 187 [expirationView addSubview:yearPopup]; |
| 191 | 188 |
| 192 // Layout month and year within expirationView. | 189 // Layout month and year within expirationView. |
| 193 [yearPopup | 190 [yearPopup |
| 194 setFrameOrigin:NSMakePoint(NSMaxX([monthPopup frame]) + kButtonGap, 0)]; | 191 setFrameOrigin:NSMakePoint(NSMaxX([monthPopup frame]) + kButtonGap, 0)]; |
| 195 NSRect expirationFrame = NSUnionRect([monthPopup frame], [yearPopup frame]); | 192 NSRect expirationFrame = NSUnionRect([monthPopup frame], [yearPopup frame]); |
| 196 expirationFrame.size.width += kButtonGap; | 193 expirationFrame.size.width += kButtonGap; |
| 197 [expirationView setFrame:expirationFrame]; | 194 [expirationView setFrame:expirationFrame]; |
| 198 [inputRowView addSubview:expirationView]; | 195 [inputRowView addSubview:expirationView]; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 // Dialog size. | 279 // Dialog size. |
| 283 [mainView | 280 [mainView |
| 284 setFrameSize:NSMakeSize( | 281 setFrameSize:NSMakeSize( |
| 285 contentWidth + [mainView contentViewMargins].width * 2.0, | 282 contentWidth + [mainView contentViewMargins].width * 2.0, |
| 286 NSMaxY([title frame]) + chrome_style::kTitleTopPadding)]; | 283 NSMaxY([title frame]) + chrome_style::kTitleTopPadding)]; |
| 287 | 284 |
| 288 [self setView:mainView]; | 285 [self setView:mainView]; |
| 289 } | 286 } |
| 290 | 287 |
| 291 @end | 288 @end |
| OLD | NEW |