| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 7 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 8 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 9 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | 9 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" |
| 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" | 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "ui/views/window/dialog_delegate.h" | 32 #include "ui/views/window/dialog_delegate.h" |
| 33 | 33 |
| 34 namespace autofill { | 34 namespace autofill { |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // The number of pixels of blank space on the outer horizontal edges of the | 38 // The number of pixels of blank space on the outer horizontal edges of the |
| 39 // dialog. | 39 // dialog. |
| 40 const int kEdgePadding = 19; | 40 const int kEdgePadding = 19; |
| 41 | 41 |
| 42 #if !defined(OS_LINUX) |
| 42 // From AutofillDialogViews. TODO(estade): share. | 43 // From AutofillDialogViews. TODO(estade): share. |
| 43 SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0); | 44 SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0); |
| 44 SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0); | 45 SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0); |
| 46 #endif |
| 45 | 47 |
| 46 class CardUnmaskPromptViews : public CardUnmaskPromptView, | 48 class CardUnmaskPromptViews : public CardUnmaskPromptView, |
| 47 views::ComboboxListener, | 49 views::ComboboxListener, |
| 48 views::DialogDelegateView, | 50 views::DialogDelegateView, |
| 49 views::TextfieldController { | 51 views::TextfieldController { |
| 50 public: | 52 public: |
| 51 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller) | 53 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller) |
| 52 : controller_(controller), | 54 : controller_(controller), |
| 53 main_contents_(nullptr), | 55 main_contents_(nullptr), |
| 54 permanent_error_label_(nullptr), | 56 permanent_error_label_(nullptr), |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (year_input_) | 150 if (year_input_) |
| 149 year_input_->SetEnabled(enabled); | 151 year_input_->SetEnabled(enabled); |
| 150 } | 152 } |
| 151 | 153 |
| 152 // views::DialogDelegateView | 154 // views::DialogDelegateView |
| 153 View* GetContentsView() override { | 155 View* GetContentsView() override { |
| 154 InitIfNecessary(); | 156 InitIfNecessary(); |
| 155 return this; | 157 return this; |
| 156 } | 158 } |
| 157 | 159 |
| 160 #if !defined(OS_LINUX) |
| 158 views::View* CreateFootnoteView() override { | 161 views::View* CreateFootnoteView() override { |
| 159 // Local storage checkbox and (?) tooltip. | 162 // Local storage checkbox and (?) tooltip. |
| 160 views::View* storage_row = new views::View(); | 163 views::View* storage_row = new views::View(); |
| 161 views::BoxLayout* storage_row_layout = new views::BoxLayout( | 164 views::BoxLayout* storage_row_layout = new views::BoxLayout( |
| 162 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); | 165 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); |
| 163 storage_row->SetLayoutManager(storage_row_layout); | 166 storage_row->SetLayoutManager(storage_row_layout); |
| 164 storage_row->SetBorder( | 167 storage_row->SetBorder( |
| 165 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); | 168 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); |
| 166 storage_row->set_background( | 169 storage_row->set_background( |
| 167 views::Background::CreateSolidBackground(kShadingColor)); | 170 views::Background::CreateSolidBackground(kShadingColor)); |
| 168 | 171 |
| 169 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( | 172 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( |
| 170 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); | 173 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); |
| 171 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); | 174 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); |
| 172 storage_row->AddChildView(storage_checkbox_); | 175 storage_row->AddChildView(storage_checkbox_); |
| 173 storage_row_layout->SetFlexForView(storage_checkbox_, 1); | 176 storage_row_layout->SetFlexForView(storage_checkbox_, 1); |
| 174 | 177 |
| 175 storage_row->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( | 178 storage_row->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( |
| 176 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))); | 179 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))); |
| 177 | 180 |
| 178 return storage_row; | 181 return storage_row; |
| 179 } | 182 } |
| 183 #endif |
| 180 | 184 |
| 181 // views::View | 185 // views::View |
| 182 gfx::Size GetPreferredSize() const override { | 186 gfx::Size GetPreferredSize() const override { |
| 183 // Must hardcode a width so the label knows where to wrap. TODO(estade): | 187 // Must hardcode a width so the label knows where to wrap. TODO(estade): |
| 184 // This can lead to a weird looking dialog if we end up getting allocated | 188 // This can lead to a weird looking dialog if we end up getting allocated |
| 185 // more width than we ask for, e.g. if the title is super long. | 189 // more width than we ask for, e.g. if the title is super long. |
| 186 const int kWidth = 375; | 190 const int kWidth = 375; |
| 187 return gfx::Size(kWidth, GetHeightForWidth(kWidth)); | 191 return gfx::Size(kWidth, GetHeightForWidth(kWidth)); |
| 188 } | 192 } |
| 189 | 193 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // These will be null when expiration date is not required. | 411 // These will be null when expiration date is not required. |
| 408 views::Combobox* month_input_; | 412 views::Combobox* month_input_; |
| 409 views::Combobox* year_input_; | 413 views::Combobox* year_input_; |
| 410 | 414 |
| 411 MonthComboboxModel month_combobox_model_; | 415 MonthComboboxModel month_combobox_model_; |
| 412 YearComboboxModel year_combobox_model_; | 416 YearComboboxModel year_combobox_model_; |
| 413 | 417 |
| 414 // The error label for most errors, which lives beneath the inputs. | 418 // The error label for most errors, which lives beneath the inputs. |
| 415 views::Label* error_label_; | 419 views::Label* error_label_; |
| 416 | 420 |
| 421 // Will be null on platforms that don't support saving locally. |
| 417 views::Checkbox* storage_checkbox_; | 422 views::Checkbox* storage_checkbox_; |
| 418 | 423 |
| 419 views::View* progress_overlay_; | 424 views::View* progress_overlay_; |
| 420 views::Label* progress_label_; | 425 views::Label* progress_label_; |
| 421 | 426 |
| 422 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews); | 427 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews); |
| 423 }; | 428 }; |
| 424 | 429 |
| 425 } // namespace | 430 } // namespace |
| 426 | 431 |
| 427 // static | 432 // static |
| 428 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( | 433 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( |
| 429 CardUnmaskPromptController* controller) { | 434 CardUnmaskPromptController* controller) { |
| 430 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller); | 435 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller); |
| 431 view->Show(); | 436 view->Show(); |
| 432 return view; | 437 return view; |
| 433 } | 438 } |
| 434 | 439 |
| 435 } // namespace autofill | 440 } // namespace autofill |
| OLD | NEW |