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

Side by Side Diff: chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc

Issue 910043002: Add checkbox to card unmasking prompt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix dbg compile 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 unified diff | Download patch
OLDNEW
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/card_unmask_prompt_controller.h" 8 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
9 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" 9 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h"
10 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" 10 #include "chrome/browser/ui/views/autofill/decorated_textfield.h"
11 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
12 #include "components/constrained_window/constrained_window_views.h" 12 #include "components/constrained_window/constrained_window_views.h"
13 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/views/controls/button/checkbox.h"
16 #include "ui/views/controls/combobox/combobox.h" 17 #include "ui/views/controls/combobox/combobox.h"
17 #include "ui/views/controls/combobox/combobox_listener.h" 18 #include "ui/views/controls/combobox/combobox_listener.h"
18 #include "ui/views/controls/image_view.h" 19 #include "ui/views/controls/image_view.h"
19 #include "ui/views/controls/label.h" 20 #include "ui/views/controls/label.h"
20 #include "ui/views/controls/textfield/textfield_controller.h" 21 #include "ui/views/controls/textfield/textfield_controller.h"
21 #include "ui/views/layout/box_layout.h" 22 #include "ui/views/layout/box_layout.h"
22 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
23 #include "ui/views/window/dialog_client_view.h" 24 #include "ui/views/window/dialog_client_view.h"
24 #include "ui/views/window/dialog_delegate.h" 25 #include "ui/views/window/dialog_delegate.h"
25 26
26 namespace autofill { 27 namespace autofill {
27 28
28 namespace { 29 namespace {
29 30
30 class CardUnmaskPromptViews : public CardUnmaskPromptView, 31 class CardUnmaskPromptViews : public CardUnmaskPromptView,
31 views::ComboboxListener, 32 views::ComboboxListener,
32 views::DialogDelegateView, 33 views::DialogDelegateView,
33 views::TextfieldController { 34 views::TextfieldController {
34 public: 35 public:
35 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller) 36 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller)
36 : controller_(controller), 37 : controller_(controller),
37 cvc_input_(nullptr), 38 cvc_input_(nullptr),
38 month_input_(nullptr), 39 month_input_(nullptr),
39 year_input_(nullptr), 40 year_input_(nullptr),
40 message_label_(nullptr) {} 41 message_label_(nullptr),
42 storage_checkbox_(nullptr) {}
41 43
42 ~CardUnmaskPromptViews() override { 44 ~CardUnmaskPromptViews() override {
43 if (controller_) 45 if (controller_)
44 controller_->OnUnmaskDialogClosed(); 46 controller_->OnUnmaskDialogClosed();
45 } 47 }
46 48
47 void Show() { 49 void Show() {
48 constrained_window::ShowWebModalDialogViews(this, 50 constrained_window::ShowWebModalDialogViews(this,
49 controller_->GetWebContents()); 51 controller_->GetWebContents());
50 } 52 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (!controller_) 153 if (!controller_)
152 return true; 154 return true;
153 155
154 controller_->OnUnmaskResponse( 156 controller_->OnUnmaskResponse(
155 cvc_input_->text(), 157 cvc_input_->text(),
156 month_input_ 158 month_input_
157 ? month_combobox_model_.GetItemAt(month_input_->selected_index()) 159 ? month_combobox_model_.GetItemAt(month_input_->selected_index())
158 : base::string16(), 160 : base::string16(),
159 year_input_ 161 year_input_
160 ? year_combobox_model_.GetItemAt(year_input_->selected_index()) 162 ? year_combobox_model_.GetItemAt(year_input_->selected_index())
161 : base::string16()); 163 : base::string16(),
164 storage_checkbox_ ? storage_checkbox_->checked() : false);
162 return false; 165 return false;
163 } 166 }
164 167
165 // views::TextfieldController 168 // views::TextfieldController
166 void ContentsChanged(views::Textfield* sender, 169 void ContentsChanged(views::Textfield* sender,
167 const base::string16& new_contents) override { 170 const base::string16& new_contents) override {
168 GetDialogClientView()->UpdateDialogButtons(); 171 GetDialogClientView()->UpdateDialogButtons();
169 } 172 }
170 173
171 // views::ComboboxListener 174 // views::ComboboxListener
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 views::ImageView* cvc_image = new views::ImageView(); 214 views::ImageView* cvc_image = new views::ImageView();
212 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 215 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
213 216
214 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid())); 217 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid()));
215 218
216 input_row->AddChildView(cvc_image); 219 input_row->AddChildView(cvc_image);
217 220
218 message_label_ = new views::Label(); 221 message_label_ = new views::Label();
219 input_row->AddChildView(message_label_); 222 input_row->AddChildView(message_label_);
220 message_label_->SetVisible(false); 223 message_label_->SetVisible(false);
224
225 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16(
226 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX));
227 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState());
228 AddChildView(storage_checkbox_);
221 } 229 }
222 230
223 void ClosePrompt() { GetWidget()->Close(); } 231 void ClosePrompt() { GetWidget()->Close(); }
224 232
225 CardUnmaskPromptController* controller_; 233 CardUnmaskPromptController* controller_;
226 234
227 DecoratedTextfield* cvc_input_; 235 DecoratedTextfield* cvc_input_;
228 236
229 // These will be null when expiration date is not required. 237 // These will be null when expiration date is not required.
230 views::Combobox* month_input_; 238 views::Combobox* month_input_;
231 views::Combobox* year_input_; 239 views::Combobox* year_input_;
232 240
233 MonthComboboxModel month_combobox_model_; 241 MonthComboboxModel month_combobox_model_;
234 YearComboboxModel year_combobox_model_; 242 YearComboboxModel year_combobox_model_;
235 243
236 // TODO(estade): this is a temporary standin in place of some spinner UI 244 // TODO(estade): this is a temporary standin in place of some spinner UI
237 // as well as a better error message. 245 // as well as a better error message.
238 views::Label* message_label_; 246 views::Label* message_label_;
239 247
248 views::Checkbox* storage_checkbox_;
249
240 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews); 250 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews);
241 }; 251 };
242 252
243 } // namespace 253 } // namespace
244 254
245 // static 255 // static
246 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( 256 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
247 CardUnmaskPromptController* controller) { 257 CardUnmaskPromptController* controller) {
248 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller); 258 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller);
249 view->Show(); 259 view->Show();
250 return view; 260 return view;
251 } 261 }
252 262
253 } // namespace autofill 263 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.cc ('k') | components/autofill/core/browser/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698