| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/card_unmask_prompt_views.h" | 5 #include "chrome/browser/ui/views/autofill/card_unmask_prompt_views.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 month_input_->SetEnabled(enabled); | 196 month_input_->SetEnabled(enabled); |
| 197 year_input_->SetEnabled(enabled); | 197 year_input_->SetEnabled(enabled); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void CardUnmaskPromptViews::ShowNewCardLink() { | 200 void CardUnmaskPromptViews::ShowNewCardLink() { |
| 201 if (new_card_link_) | 201 if (new_card_link_) |
| 202 return; | 202 return; |
| 203 | 203 |
| 204 new_card_link_ = new views::Link( | 204 new_card_link_ = new views::Link( |
| 205 l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_NEW_CARD_LINK)); | 205 l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_NEW_CARD_LINK)); |
| 206 new_card_link_->SetBorder(views::Border::CreateEmptyBorder(0, 7, 0, 0)); | 206 new_card_link_->SetBorder(views::CreateEmptyBorder(0, 7, 0, 0)); |
| 207 new_card_link_->SetUnderline(false); | 207 new_card_link_->SetUnderline(false); |
| 208 new_card_link_->set_listener(this); | 208 new_card_link_->set_listener(this); |
| 209 input_row_->AddChildView(new_card_link_); | 209 input_row_->AddChildView(new_card_link_); |
| 210 } | 210 } |
| 211 | 211 |
| 212 views::View* CardUnmaskPromptViews::GetContentsView() { | 212 views::View* CardUnmaskPromptViews::GetContentsView() { |
| 213 InitIfNecessary(); | 213 InitIfNecessary(); |
| 214 return this; | 214 return this; |
| 215 } | 215 } |
| 216 | 216 |
| 217 views::View* CardUnmaskPromptViews::CreateFootnoteView() { | 217 views::View* CardUnmaskPromptViews::CreateFootnoteView() { |
| 218 if (!controller_->CanStoreLocally()) | 218 if (!controller_->CanStoreLocally()) |
| 219 return nullptr; | 219 return nullptr; |
| 220 | 220 |
| 221 // Local storage checkbox and (?) tooltip. | 221 // Local storage checkbox and (?) tooltip. |
| 222 storage_row_ = new FadeOutView(); | 222 storage_row_ = new FadeOutView(); |
| 223 views::BoxLayout* storage_row_layout = new views::BoxLayout( | 223 views::BoxLayout* storage_row_layout = new views::BoxLayout( |
| 224 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); | 224 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); |
| 225 storage_row_->SetLayoutManager(storage_row_layout); | 225 storage_row_->SetLayoutManager(storage_row_layout); |
| 226 storage_row_->SetBorder( | 226 storage_row_->SetBorder( |
| 227 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); | 227 views::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); |
| 228 storage_row_->set_background( | 228 storage_row_->set_background( |
| 229 views::Background::CreateSolidBackground(kLightShadingColor)); | 229 views::Background::CreateSolidBackground(kLightShadingColor)); |
| 230 | 230 |
| 231 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( | 231 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( |
| 232 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); | 232 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); |
| 233 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); | 233 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); |
| 234 storage_row_->AddChildView(storage_checkbox_); | 234 storage_row_->AddChildView(storage_checkbox_); |
| 235 storage_row_layout->SetFlexForView(storage_checkbox_, 1); | 235 storage_row_layout->SetFlexForView(storage_checkbox_, 1); |
| 236 | 236 |
| 237 storage_row_->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( | 237 storage_row_->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 12)); | 383 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 12)); |
| 384 AddChildView(main_contents_); | 384 AddChildView(main_contents_); |
| 385 | 385 |
| 386 permanent_error_label_ = new views::Label(); | 386 permanent_error_label_ = new views::Label(); |
| 387 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 387 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 388 permanent_error_label_->SetFontList( | 388 permanent_error_label_->SetFontList( |
| 389 rb.GetFontList(ui::ResourceBundle::BoldFont)); | 389 rb.GetFontList(ui::ResourceBundle::BoldFont)); |
| 390 permanent_error_label_->set_background( | 390 permanent_error_label_->set_background( |
| 391 views::Background::CreateSolidBackground(kWarningColor)); | 391 views::Background::CreateSolidBackground(kWarningColor)); |
| 392 permanent_error_label_->SetBorder( | 392 permanent_error_label_->SetBorder( |
| 393 views::Border::CreateEmptyBorder(12, kEdgePadding, 12, kEdgePadding)); | 393 views::CreateEmptyBorder(12, kEdgePadding, 12, kEdgePadding)); |
| 394 permanent_error_label_->SetEnabledColor(SK_ColorWHITE); | 394 permanent_error_label_->SetEnabledColor(SK_ColorWHITE); |
| 395 permanent_error_label_->SetAutoColorReadabilityEnabled(false); | 395 permanent_error_label_->SetAutoColorReadabilityEnabled(false); |
| 396 permanent_error_label_->SetVisible(false); | 396 permanent_error_label_->SetVisible(false); |
| 397 permanent_error_label_->SetMultiLine(true); | 397 permanent_error_label_->SetMultiLine(true); |
| 398 permanent_error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 398 permanent_error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 399 main_contents_->AddChildView(permanent_error_label_); | 399 main_contents_->AddChildView(permanent_error_label_); |
| 400 | 400 |
| 401 views::View* controls_container = new views::View(); | 401 views::View* controls_container = new views::View(); |
| 402 controls_container->SetLayoutManager( | 402 controls_container->SetLayoutManager( |
| 403 new views::BoxLayout(views::BoxLayout::kVertical, kEdgePadding, 0, 0)); | 403 new views::BoxLayout(views::BoxLayout::kVertical, kEdgePadding, 0, 0)); |
| 404 main_contents_->AddChildView(controls_container); | 404 main_contents_->AddChildView(controls_container); |
| 405 | 405 |
| 406 instructions_ = new views::Label(controller_->GetInstructionsMessage()); | 406 instructions_ = new views::Label(controller_->GetInstructionsMessage()); |
| 407 instructions_->SetEnabledColor(kGreyTextColor); | 407 instructions_->SetEnabledColor(kGreyTextColor); |
| 408 instructions_->SetMultiLine(true); | 408 instructions_->SetMultiLine(true); |
| 409 instructions_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 409 instructions_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 410 instructions_->SetBorder(views::Border::CreateEmptyBorder(0, 0, 16, 0)); | 410 instructions_->SetBorder(views::CreateEmptyBorder(0, 0, 16, 0)); |
| 411 controls_container->AddChildView(instructions_); | 411 controls_container->AddChildView(instructions_); |
| 412 | 412 |
| 413 input_row_ = new views::View(); | 413 input_row_ = new views::View(); |
| 414 input_row_->SetLayoutManager( | 414 input_row_->SetLayoutManager( |
| 415 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5)); | 415 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5)); |
| 416 controls_container->AddChildView(input_row_); | 416 controls_container->AddChildView(input_row_); |
| 417 | 417 |
| 418 month_input_ = new views::Combobox(&month_combobox_model_); | 418 month_input_ = new views::Combobox(&month_combobox_model_); |
| 419 month_input_->set_listener(this); | 419 month_input_->set_listener(this); |
| 420 input_row_->AddChildView(month_input_); | 420 input_row_->AddChildView(month_input_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 442 views::ImageView* cvc_image = new views::ImageView(); | 442 views::ImageView* cvc_image = new views::ImageView(); |
| 443 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid())); | 443 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid())); |
| 444 input_row_->AddChildView(cvc_image); | 444 input_row_->AddChildView(cvc_image); |
| 445 | 445 |
| 446 views::View* temporary_error = new views::View(); | 446 views::View* temporary_error = new views::View(); |
| 447 views::BoxLayout* temporary_error_layout = | 447 views::BoxLayout* temporary_error_layout = |
| 448 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 4); | 448 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 4); |
| 449 temporary_error->SetLayoutManager(temporary_error_layout); | 449 temporary_error->SetLayoutManager(temporary_error_layout); |
| 450 temporary_error_layout->set_cross_axis_alignment( | 450 temporary_error_layout->set_cross_axis_alignment( |
| 451 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 451 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 452 temporary_error->SetBorder(views::Border::CreateEmptyBorder(8, 0, 0, 0)); | 452 temporary_error->SetBorder(views::CreateEmptyBorder(8, 0, 0, 0)); |
| 453 controls_container->AddChildView(temporary_error); | 453 controls_container->AddChildView(temporary_error); |
| 454 | 454 |
| 455 error_icon_ = new views::ImageView(); | 455 error_icon_ = new views::ImageView(); |
| 456 error_icon_->SetVisible(false); | 456 error_icon_->SetVisible(false); |
| 457 error_icon_->SetImage( | 457 error_icon_->SetImage( |
| 458 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 16, kWarningColor)); | 458 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 16, kWarningColor)); |
| 459 temporary_error->AddChildView(error_icon_); | 459 temporary_error->AddChildView(error_icon_); |
| 460 | 460 |
| 461 // Reserve vertical space for the error label, assuming it's one line. | 461 // Reserve vertical space for the error label, assuming it's one line. |
| 462 error_label_ = new views::Label(base::ASCIIToUTF16(" ")); | 462 error_label_ = new views::Label(base::ASCIIToUTF16(" ")); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 views::View::OnPaint(canvas); | 521 views::View::OnPaint(canvas); |
| 522 canvas->Restore(); | 522 canvas->Restore(); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void CardUnmaskPromptViews::FadeOutView::SetAlpha(uint8_t alpha) { | 525 void CardUnmaskPromptViews::FadeOutView::SetAlpha(uint8_t alpha) { |
| 526 alpha_ = alpha; | 526 alpha_ = alpha; |
| 527 SchedulePaint(); | 527 SchedulePaint(); |
| 528 } | 528 } |
| 529 | 529 |
| 530 } // namespace autofill | 530 } // namespace autofill |
| OLD | NEW |