| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/views/autofill/save_card_bubble_views.h" | 5 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view, | 54 SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view, |
| 55 content::WebContents* web_contents, | 55 content::WebContents* web_contents, |
| 56 SaveCardBubbleController* controller) | 56 SaveCardBubbleController* controller) |
| 57 : LocationBarBubbleDelegateView(anchor_view, web_contents), | 57 : LocationBarBubbleDelegateView(anchor_view, web_contents), |
| 58 controller_(controller) { | 58 controller_(controller) { |
| 59 DCHECK(controller); | 59 DCHECK(controller); |
| 60 views::BubbleDialogDelegateView::CreateBubble(this); | 60 views::BubbleDialogDelegateView::CreateBubble(this); |
| 61 chrome::RecordDialogCreation(chrome::DialogIdentifier::SAVE_CARD); | 61 chrome::RecordDialogCreation(chrome::DialogIdentifier::SAVE_CARD); |
| 62 } | 62 } |
| 63 | 63 |
| 64 SaveCardBubbleViews::~SaveCardBubbleViews() {} | |
| 65 | |
| 66 void SaveCardBubbleViews::Show(DisplayReason reason) { | 64 void SaveCardBubbleViews::Show(DisplayReason reason) { |
| 67 ShowForReason(reason); | 65 ShowForReason(reason); |
| 68 } | 66 } |
| 69 | 67 |
| 70 void SaveCardBubbleViews::Hide() { | 68 void SaveCardBubbleViews::Hide() { |
| 71 controller_ = nullptr; | 69 controller_ = nullptr; |
| 72 CloseBubble(); | 70 CloseBubble(); |
| 73 } | 71 } |
| 74 | 72 |
| 75 views::View* SaveCardBubbleViews::CreateExtraView() { | 73 views::View* SaveCardBubbleViews::CreateExtraView() { |
| 74 if (GetCurrentFlowStep() != LOCAL_SAVE_ONLY_STEP) |
| 75 return nullptr; |
| 76 // Learn More link is only shown on local save bubble. |
| 76 DCHECK(!learn_more_link_); | 77 DCHECK(!learn_more_link_); |
| 77 learn_more_link_ = new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 78 learn_more_link_ = new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 78 learn_more_link_->SetUnderline(false); | 79 learn_more_link_->SetUnderline(false); |
| 79 learn_more_link_->set_listener(this); | 80 learn_more_link_->set_listener(this); |
| 80 return learn_more_link_; | 81 return learn_more_link_; |
| 81 } | 82 } |
| 82 | 83 |
| 83 views::View* SaveCardBubbleViews::CreateFootnoteView() { | 84 views::View* SaveCardBubbleViews::CreateFootnoteView() { |
| 84 if (controller_->GetLegalMessageLines().empty()) | 85 if (controller_->GetLegalMessageLines().empty()) |
| 85 return nullptr; | 86 return nullptr; |
| 86 | 87 |
| 87 // Use BoxLayout to provide insets around the label. | 88 // Use BoxLayout to provide insets around the label. |
| 88 View* view = new View(); | 89 footnote_view_ = new View(); |
| 89 view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical)); | 90 footnote_view_->SetLayoutManager( |
| 91 new views::BoxLayout(views::BoxLayout::kVertical)); |
| 90 | 92 |
| 91 // Add a StyledLabel for each line of the legal message. | 93 // Add a StyledLabel for each line of the legal message. |
| 92 for (const LegalMessageLine& line : controller_->GetLegalMessageLines()) | 94 for (const LegalMessageLine& line : controller_->GetLegalMessageLines()) { |
| 93 view->AddChildView(CreateLegalMessageLineLabel(line, this).release()); | 95 footnote_view_->AddChildView( |
| 96 CreateLegalMessageLineLabel(line, this).release()); |
| 97 } |
| 94 | 98 |
| 95 return view; | 99 // If on the first step of the 2-step upload flow, hide the footer area until |
| 100 // it's time to actually accept the dialog and ToS. |
| 101 if (GetCurrentFlowStep() == UPLOAD_SAVE_CVC_FIX_FLOW_STEP_1_OFFER_UPLOAD) |
| 102 footnote_view_->SetVisible(false); |
| 103 |
| 104 return footnote_view_; |
| 96 } | 105 } |
| 97 | 106 |
| 98 bool SaveCardBubbleViews::Accept() { | 107 bool SaveCardBubbleViews::Accept() { |
| 99 // The main content ViewStack for local save and happy-path upload save should | 108 // The main content ViewStack for local save and happy-path upload save should |
| 100 // only ever have 1 View on it. Upload save can have a second View if CVC | 109 // only ever have 1 View on it. Upload save can have a second View if CVC |
| 101 // needs to be requested. Assert that the ViewStack has no more than 2 Views | 110 // needs to be requested. Assert that the ViewStack has no more than 2 Views |
| 102 // and that if it *does* have 2, it's because CVC is being requested. | 111 // and that if it *does* have 2, it's because CVC is being requested. |
| 103 DCHECK_LE(view_stack_->size(), 2U); | 112 DCHECK_LE(view_stack_->size(), 2U); |
| 104 DCHECK(view_stack_->size() == 1 || controller_->ShouldRequestCvcFromUser()); | 113 DCHECK(view_stack_->size() == 1 || controller_->ShouldRequestCvcFromUser()); |
| 105 if (controller_->ShouldRequestCvcFromUser() && view_stack_->size() == 1) { | 114 if (GetCurrentFlowStep() == UPLOAD_SAVE_CVC_FIX_FLOW_STEP_1_OFFER_UPLOAD) { |
| 106 // If user accepted upload but more info is needed, push the next view onto | 115 // If user accepted upload but more info is needed, push the next view onto |
| 107 // the stack. | 116 // the stack and update the bubble. |
| 117 DCHECK(controller_); |
| 118 controller_->SetShowUploadConfirmTitle(true); |
| 119 GetWidget()->UpdateWindowTitle(); |
| 108 view_stack_->Push(CreateRequestCvcView(), /*animate=*/true); | 120 view_stack_->Push(CreateRequestCvcView(), /*animate=*/true); |
| 109 // Disable the Save button until a valid CVC is entered: | 121 // Disable the Save button until a valid CVC is entered: |
| 110 GetDialogClientView()->UpdateDialogButtons(); | 122 GetDialogClientView()->UpdateDialogButtons(); |
| 123 // Make the legal messaging footer appear: |
| 124 DCHECK(footnote_view_); |
| 125 footnote_view_->SetVisible(true); |
| 111 // Resize the bubble if it's grown larger: | 126 // Resize the bubble if it's grown larger: |
| 112 SizeToContents(); | 127 SizeToContents(); |
| 113 return false; | 128 return false; |
| 114 } | 129 } |
| 115 // Otherwise, close the bubble as normal. | 130 // Otherwise, close the bubble as normal. |
| 116 if (controller_) | 131 if (controller_) |
| 117 controller_->OnSaveButton(cvc_textfield_ ? cvc_textfield_->text() | 132 controller_->OnSaveButton(cvc_textfield_ ? cvc_textfield_->text() |
| 118 : base::string16()); | 133 : base::string16()); |
| 119 return true; | 134 return true; |
| 120 } | 135 } |
| 121 | 136 |
| 122 bool SaveCardBubbleViews::Cancel() { | 137 bool SaveCardBubbleViews::Cancel() { |
| 123 if (controller_) | 138 if (controller_) |
| 124 controller_->OnCancelButton(); | 139 controller_->OnCancelButton(); |
| 125 return true; | 140 return true; |
| 126 } | 141 } |
| 127 | 142 |
| 128 bool SaveCardBubbleViews::Close() { | 143 bool SaveCardBubbleViews::Close() { |
| 129 // Cancel is logged as a different user action than closing, so override | 144 // Cancel is logged as a different user action than closing, so override |
| 130 // Close() to prevent the superclass' implementation from calling Cancel(). | 145 // Close() to prevent the superclass' implementation from calling Cancel(). |
| 131 // Return true to indicate that the bubble can be closed. | 146 // Return true to indicate that the bubble can be closed. |
| 132 return true; | 147 return true; |
| 133 } | 148 } |
| 134 | 149 |
| 150 int SaveCardBubbleViews::GetDialogButtons() const { |
| 151 if (GetCurrentFlowStep() == LOCAL_SAVE_ONLY_STEP) |
| 152 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 153 // For upload save, don't show the [No thanks] cancel option; use the |
| 154 // top-right [X] close button for that. |
| 155 return ui::DIALOG_BUTTON_OK; |
| 156 } |
| 157 |
| 135 base::string16 SaveCardBubbleViews::GetDialogButtonLabel( | 158 base::string16 SaveCardBubbleViews::GetDialogButtonLabel( |
| 136 ui::DialogButton button) const { | 159 ui::DialogButton button) const { |
| 137 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK | 160 switch (GetCurrentFlowStep()) { |
| 138 ? IDS_AUTOFILL_SAVE_CARD_PROMPT_ACCEPT | 161 // Local save has two buttons: |
| 139 : IDS_NO_THANKS); | 162 case LOCAL_SAVE_ONLY_STEP: |
| 163 return l10n_util::GetStringUTF16( |
| 164 button == ui::DIALOG_BUTTON_OK ? IDS_AUTOFILL_SAVE_CARD_PROMPT_ACCEPT |
| 165 : IDS_NO_THANKS); |
| 166 // Upload save has one button but it can say three different things: |
| 167 case UPLOAD_SAVE_ONLY_STEP: |
| 168 DCHECK(button == ui::DIALOG_BUTTON_OK); |
| 169 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_ACCEPT); |
| 170 case UPLOAD_SAVE_CVC_FIX_FLOW_STEP_1_OFFER_UPLOAD: |
| 171 DCHECK(button == ui::DIALOG_BUTTON_OK); |
| 172 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_NEXT); |
| 173 case UPLOAD_SAVE_CVC_FIX_FLOW_STEP_2_REQUEST_CVC: |
| 174 DCHECK(button == ui::DIALOG_BUTTON_OK); |
| 175 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_CONFIRM); |
| 176 default: |
| 177 NOTREACHED(); |
| 178 return base::string16(); |
| 179 } |
| 180 } |
| 181 |
| 182 bool SaveCardBubbleViews::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 183 if (button == ui::DIALOG_BUTTON_CANCEL) |
| 184 return true; |
| 185 |
| 186 DCHECK_EQ(ui::DIALOG_BUTTON_OK, button); |
| 187 return !cvc_textfield_ || |
| 188 controller_->InputCvcIsValid(cvc_textfield_->text()); |
| 140 } | 189 } |
| 141 | 190 |
| 142 gfx::Size SaveCardBubbleViews::CalculatePreferredSize() const { | 191 gfx::Size SaveCardBubbleViews::CalculatePreferredSize() const { |
| 143 return gfx::Size(kBubbleWidth, GetHeightForWidth(kBubbleWidth)); | 192 return gfx::Size(kBubbleWidth, GetHeightForWidth(kBubbleWidth)); |
| 144 } | 193 } |
| 145 | 194 |
| 195 bool SaveCardBubbleViews::ShouldShowCloseButton() const { |
| 196 // Local save should have a [No thanks] button, but Upload save should surface |
| 197 // the top-right [X] close button instead. |
| 198 return GetCurrentFlowStep() != LOCAL_SAVE_ONLY_STEP; |
| 199 } |
| 200 |
| 146 base::string16 SaveCardBubbleViews::GetWindowTitle() const { | 201 base::string16 SaveCardBubbleViews::GetWindowTitle() const { |
| 147 return controller_ ? controller_->GetWindowTitle() : base::string16(); | 202 return controller_ ? controller_->GetWindowTitle() : base::string16(); |
| 148 } | 203 } |
| 149 | 204 |
| 150 void SaveCardBubbleViews::WindowClosing() { | 205 void SaveCardBubbleViews::WindowClosing() { |
| 151 if (controller_) | 206 if (controller_) |
| 152 controller_->OnBubbleClosed(); | 207 controller_->OnBubbleClosed(); |
| 153 } | 208 } |
| 154 | 209 |
| 155 void SaveCardBubbleViews::LinkClicked(views::Link* source, int event_flags) { | 210 void SaveCardBubbleViews::LinkClicked(views::Link* source, int event_flags) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 177 if (link.range == range) { | 232 if (link.range == range) { |
| 178 controller_->OnLegalMessageLinkClicked(link.url); | 233 controller_->OnLegalMessageLinkClicked(link.url); |
| 179 return; | 234 return; |
| 180 } | 235 } |
| 181 } | 236 } |
| 182 | 237 |
| 183 // |range| was not found. | 238 // |range| was not found. |
| 184 NOTREACHED(); | 239 NOTREACHED(); |
| 185 } | 240 } |
| 186 | 241 |
| 242 void SaveCardBubbleViews::ContentsChanged(views::Textfield* sender, |
| 243 const base::string16& new_contents) { |
| 244 DCHECK_EQ(cvc_textfield_, sender); |
| 245 GetDialogClientView()->UpdateDialogButtons(); |
| 246 } |
| 247 |
| 248 SaveCardBubbleViews::~SaveCardBubbleViews() {} |
| 249 |
| 250 SaveCardBubbleViews::CurrentFlowStep SaveCardBubbleViews::GetCurrentFlowStep() |
| 251 const { |
| 252 // No legal messages means this is not upload save. |
| 253 if (controller_->GetLegalMessageLines().empty()) |
| 254 return LOCAL_SAVE_ONLY_STEP; |
| 255 // If we're not requesting CVC, this is the only step on the upload path. |
| 256 if (!controller_->ShouldRequestCvcFromUser()) |
| 257 return UPLOAD_SAVE_ONLY_STEP; |
| 258 // Must be on the CVC fix flow on the upload path. |
| 259 if (view_stack_->size() == 1) |
| 260 return UPLOAD_SAVE_CVC_FIX_FLOW_STEP_1_OFFER_UPLOAD; |
| 261 if (view_stack_->size() == 2) |
| 262 return UPLOAD_SAVE_CVC_FIX_FLOW_STEP_2_REQUEST_CVC; |
| 263 // CVC fix flow should never have more than 3 views on the stack. |
| 264 NOTREACHED(); |
| 265 return UNKNOWN_STEP; |
| 266 } |
| 267 |
| 187 // Create view containing everything except for the footnote. | 268 // Create view containing everything except for the footnote. |
| 188 std::unique_ptr<views::View> SaveCardBubbleViews::CreateMainContentView() { | 269 std::unique_ptr<views::View> SaveCardBubbleViews::CreateMainContentView() { |
| 189 auto view = base::MakeUnique<views::View>(); | 270 auto view = base::MakeUnique<views::View>(); |
| 190 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); | 271 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 191 | 272 |
| 192 view->SetLayoutManager(new views::BoxLayout( | 273 view->SetLayoutManager(new views::BoxLayout( |
| 193 views::BoxLayout::kVertical, gfx::Insets(), | 274 views::BoxLayout::kVertical, gfx::Insets(), |
| 194 provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL))); | 275 provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL))); |
| 195 | 276 |
| 277 // If applicable, add the upload explanation label. |
| 278 base::string16 explanation = controller_->GetExplanatoryMessage(); |
| 279 if (!explanation.empty()) { |
| 280 views::Label* explanation_label = new views::Label(explanation); |
| 281 explanation_label->SetMultiLine(true); |
| 282 explanation_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 283 view->AddChildView(explanation_label); |
| 284 } |
| 285 |
| 196 // Add the card type icon, last four digits and expiration date. | 286 // Add the card type icon, last four digits and expiration date. |
| 197 views::View* description_view = new views::View(); | 287 views::View* description_view = new views::View(); |
| 198 description_view->SetLayoutManager(new views::BoxLayout( | 288 description_view->SetLayoutManager(new views::BoxLayout( |
| 199 views::BoxLayout::kHorizontal, gfx::Insets(), | 289 views::BoxLayout::kHorizontal, gfx::Insets(), |
| 200 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL))); | 290 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL))); |
| 201 view->AddChildView(description_view); | 291 view->AddChildView(description_view); |
| 202 | 292 |
| 203 const CreditCard& card = controller_->GetCard(); | 293 const CreditCard& card = controller_->GetCard(); |
| 204 views::ImageView* card_type_icon = new views::ImageView(); | 294 views::ImageView* card_type_icon = new views::ImageView(); |
| 205 card_type_icon->SetImage( | 295 card_type_icon->SetImage( |
| 206 ResourceBundle::GetSharedInstance() | 296 ResourceBundle::GetSharedInstance() |
| 207 .GetImageNamed(CreditCard::IconResourceId(card.network())) | 297 .GetImageNamed(CreditCard::IconResourceId(card.network())) |
| 208 .AsImageSkia()); | 298 .AsImageSkia()); |
| 209 card_type_icon->SetTooltipText(card.NetworkForDisplay()); | 299 card_type_icon->SetTooltipText(card.NetworkForDisplay()); |
| 210 card_type_icon->SetBorder( | 300 card_type_icon->SetBorder( |
| 211 views::CreateSolidBorder(1, SkColorSetA(SK_ColorBLACK, 10))); | 301 views::CreateSolidBorder(1, SkColorSetA(SK_ColorBLACK, 10))); |
| 212 description_view->AddChildView(card_type_icon); | 302 description_view->AddChildView(card_type_icon); |
| 213 | 303 |
| 214 description_view->AddChildView(new views::Label( | |
| 215 base::string16(kMidlineEllipsis) + card.LastFourDigits())); | |
| 216 description_view->AddChildView( | 304 description_view->AddChildView( |
| 217 new views::Label(card.AbbreviatedExpirationDateForDisplay())); | 305 new views::Label(card.NetworkAndLastFourDigits())); |
| 218 | |
| 219 // Optionally add label that will contain an explanation for upload. | |
| 220 base::string16 explanation = controller_->GetExplanatoryMessage(); | |
| 221 if (!explanation.empty()) { | |
| 222 views::Label* explanation_label = new views::Label(explanation); | |
| 223 explanation_label->SetMultiLine(true); | |
| 224 explanation_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 225 view->AddChildView(explanation_label); | |
| 226 } | |
| 227 | 306 |
| 228 return view; | 307 return view; |
| 229 } | 308 } |
| 230 | 309 |
| 231 std::unique_ptr<views::View> SaveCardBubbleViews::CreateRequestCvcView() { | 310 std::unique_ptr<views::View> SaveCardBubbleViews::CreateRequestCvcView() { |
| 232 auto request_cvc_view = base::MakeUnique<views::View>(); | 311 auto request_cvc_view = base::MakeUnique<views::View>(); |
| 312 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 313 |
| 314 request_cvc_view->SetLayoutManager(new views::BoxLayout( |
| 315 views::BoxLayout::kVertical, gfx::Insets(), |
| 316 provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL))); |
| 233 request_cvc_view->SetBackground(views::CreateThemedSolidBackground( | 317 request_cvc_view->SetBackground(views::CreateThemedSolidBackground( |
| 234 request_cvc_view.get(), ui::NativeTheme::kColorId_BubbleBackground)); | 318 request_cvc_view.get(), ui::NativeTheme::kColorId_BubbleBackground)); |
| 235 views::BoxLayout* layout = | 319 |
| 236 new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(), | 320 views::Label* explanation_label = new views::Label(l10n_util::GetStringUTF16( |
| 237 ChromeLayoutProvider::Get()->GetDistanceMetric( | 321 IDS_AUTOFILL_SAVE_CARD_PROMPT_ENTER_CVC_EXPLANATION)); |
| 238 views::DISTANCE_RELATED_BUTTON_HORIZONTAL)); | 322 explanation_label->SetMultiLine(true); |
| 323 explanation_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 324 request_cvc_view->AddChildView(explanation_label); |
| 325 |
| 326 views::View* cvc_entry_view = new views::View(); |
| 327 views::BoxLayout* layout = new views::BoxLayout( |
| 328 views::BoxLayout::kHorizontal, gfx::Insets(), |
| 329 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL)); |
| 239 layout->set_cross_axis_alignment( | 330 layout->set_cross_axis_alignment( |
| 240 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 331 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
| 241 request_cvc_view->SetLayoutManager(layout); | 332 cvc_entry_view->SetLayoutManager(layout); |
| 242 | 333 |
| 243 DCHECK(!cvc_textfield_); | 334 DCHECK(!cvc_textfield_); |
| 244 cvc_textfield_ = CreateCvcTextfield(); | 335 cvc_textfield_ = CreateCvcTextfield(); |
| 245 cvc_textfield_->set_controller(this); | 336 cvc_textfield_->set_controller(this); |
| 246 request_cvc_view->AddChildView(cvc_textfield_); | 337 cvc_entry_view->AddChildView(cvc_textfield_); |
| 247 | 338 |
| 248 views::ImageView* cvc_image = new views::ImageView(); | 339 views::ImageView* cvc_image = new views::ImageView(); |
| 249 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 340 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 250 cvc_image->SetImage( | 341 cvc_image->SetImage( |
| 251 rb.GetImageSkiaNamed(controller_->GetCvcImageResourceId())); | 342 rb.GetImageSkiaNamed(controller_->GetCvcImageResourceId())); |
| 252 request_cvc_view->AddChildView(cvc_image); | 343 cvc_entry_view->AddChildView(cvc_image); |
| 253 | 344 |
| 254 request_cvc_view->AddChildView(new views::Label( | 345 request_cvc_view->AddChildView(cvc_entry_view); |
| 255 l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_ENTER_CVC))); | |
| 256 | |
| 257 return request_cvc_view; | 346 return request_cvc_view; |
| 258 } | 347 } |
| 259 | 348 |
| 260 bool SaveCardBubbleViews::IsDialogButtonEnabled(ui::DialogButton button) const { | |
| 261 if (button == ui::DIALOG_BUTTON_CANCEL) | |
| 262 return true; | |
| 263 | |
| 264 DCHECK_EQ(ui::DIALOG_BUTTON_OK, button); | |
| 265 return !cvc_textfield_ || | |
| 266 controller_->InputCvcIsValid(cvc_textfield_->text()); | |
| 267 } | |
| 268 | |
| 269 void SaveCardBubbleViews::ContentsChanged(views::Textfield* sender, | |
| 270 const base::string16& new_contents) { | |
| 271 DCHECK_EQ(cvc_textfield_, sender); | |
| 272 GetDialogClientView()->UpdateDialogButtons(); | |
| 273 } | |
| 274 | |
| 275 void SaveCardBubbleViews::Init() { | 349 void SaveCardBubbleViews::Init() { |
| 276 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical)); | 350 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical)); |
| 277 view_stack_ = new ViewStack(); | 351 view_stack_ = new ViewStack(); |
| 278 view_stack_->SetBackground(views::CreateThemedSolidBackground( | 352 view_stack_->SetBackground(views::CreateThemedSolidBackground( |
| 279 view_stack_, ui::NativeTheme::kColorId_BubbleBackground)); | 353 view_stack_, ui::NativeTheme::kColorId_BubbleBackground)); |
| 280 view_stack_->Push(CreateMainContentView(), /*animate=*/false); | 354 view_stack_->Push(CreateMainContentView(), /*animate=*/false); |
| 281 AddChildView(view_stack_); | 355 AddChildView(view_stack_); |
| 282 } | 356 } |
| 283 | 357 |
| 284 } // namespace autofill | 358 } // namespace autofill |
| OLD | NEW |