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

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

Issue 12016031: Add 'save details in chrome' checkbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change symbol names Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/autofill_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/wallet/wallet_service_url.h" 10 #include "chrome/browser/autofill/wallet/wallet_service_url.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 did_submit_(false), 250 did_submit_(false),
251 window_(NULL), 251 window_(NULL),
252 contents_(NULL), 252 contents_(NULL),
253 notification_label_(NULL), 253 notification_label_(NULL),
254 use_billing_for_shipping_(NULL), 254 use_billing_for_shipping_(NULL),
255 sign_in_link_(NULL), 255 sign_in_link_(NULL),
256 sign_in_container_(NULL), 256 sign_in_container_(NULL),
257 cancel_sign_in_(NULL), 257 cancel_sign_in_(NULL),
258 sign_in_webview_(NULL), 258 sign_in_webview_(NULL),
259 main_container_(NULL), 259 main_container_(NULL),
260 button_strip_extra_view_(NULL),
261 save_in_chrome_checkbox_(NULL),
260 focus_manager_(NULL) { 262 focus_manager_(NULL) {
261 DCHECK(controller); 263 DCHECK(controller);
262 detail_groups_.insert(std::make_pair(SECTION_EMAIL, 264 detail_groups_.insert(std::make_pair(SECTION_EMAIL,
263 DetailsGroup(SECTION_EMAIL))); 265 DetailsGroup(SECTION_EMAIL)));
264 detail_groups_.insert(std::make_pair(SECTION_CC, 266 detail_groups_.insert(std::make_pair(SECTION_CC,
265 DetailsGroup(SECTION_CC))); 267 DetailsGroup(SECTION_CC)));
266 detail_groups_.insert(std::make_pair(SECTION_BILLING, 268 detail_groups_.insert(std::make_pair(SECTION_BILLING,
267 DetailsGroup(SECTION_BILLING))); 269 DetailsGroup(SECTION_BILLING)));
268 detail_groups_.insert(std::make_pair(SECTION_SHIPPING, 270 detail_groups_.insert(std::make_pair(SECTION_SHIPPING,
269 DetailsGroup(SECTION_SHIPPING))); 271 DetailsGroup(SECTION_SHIPPING)));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 for (TextfieldMap::iterator it = group->textfields.begin(); 310 for (TextfieldMap::iterator it = group->textfields.begin();
309 it != group->textfields.end(); ++it) { 311 it != group->textfields.end(); ++it) {
310 output->insert(std::make_pair(it->first, it->second->textfield()->text())); 312 output->insert(std::make_pair(it->first, it->second->textfield()->text()));
311 } 313 }
312 } 314 }
313 315
314 bool AutofillDialogViews::UseBillingForShipping() { 316 bool AutofillDialogViews::UseBillingForShipping() {
315 return use_billing_for_shipping_->checked(); 317 return use_billing_for_shipping_->checked();
316 } 318 }
317 319
320 bool AutofillDialogViews::SaveDetailsLocally() {
321 return save_in_chrome_checkbox_->checked();
322 }
323
318 const content::NavigationController& AutofillDialogViews::ShowSignIn() { 324 const content::NavigationController& AutofillDialogViews::ShowSignIn() {
319 // TODO(abodenha) Also hide Submit and Cancel buttons. 325 // TODO(abodenha) Also hide Submit and Cancel buttons.
320 // See http://crbug.com/165193 326 // See http://crbug.com/165193
321 // TODO(abodenha) We should be able to use the WebContents of the WebView 327 // TODO(abodenha) We should be able to use the WebContents of the WebView
322 // to navigate instead of LoadInitialURL. Figure out why it doesn't work. 328 // to navigate instead of LoadInitialURL. Figure out why it doesn't work.
323 329
324 sign_in_webview_->LoadInitialURL(wallet::GetSignInUrl()); 330 sign_in_webview_->LoadInitialURL(wallet::GetSignInUrl());
325 // TODO(abodenha) Resize the dialog to avoid the need for a scroll bar on 331 // TODO(abodenha) Resize the dialog to avoid the need for a scroll bar on
326 // sign in. See http://crbug.com/169286 332 // sign in. See http://crbug.com/169286
327 sign_in_webview_->SetPreferredSize(contents_->GetPreferredSize()); 333 sign_in_webview_->SetPreferredSize(contents_->GetPreferredSize());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 string16 AutofillDialogViews::GetDialogButtonLabel(ui::DialogButton button) 371 string16 AutofillDialogViews::GetDialogButtonLabel(ui::DialogButton button)
366 const { 372 const {
367 return button == ui::DIALOG_BUTTON_OK ? 373 return button == ui::DIALOG_BUTTON_OK ?
368 controller_->ConfirmButtonText() : controller_->CancelButtonText(); 374 controller_->ConfirmButtonText() : controller_->CancelButtonText();
369 } 375 }
370 376
371 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { 377 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const {
372 return true; 378 return true;
373 } 379 }
374 380
381 views::View* AutofillDialogViews::GetExtraView() {
382 return button_strip_extra_view_;
383 }
384
375 bool AutofillDialogViews::Cancel() { 385 bool AutofillDialogViews::Cancel() {
376 return true; 386 return true;
377 } 387 }
378 388
379 bool AutofillDialogViews::Accept() { 389 bool AutofillDialogViews::Accept() {
380 if (!ValidateForm()) 390 if (!ValidateForm())
381 return false; 391 return false;
382 392
383 did_submit_ = true; 393 did_submit_ = true;
384 return true; 394 return true;
385 } 395 }
386 396
387 void AutofillDialogViews::ButtonPressed(views::Button* sender, 397 void AutofillDialogViews::ButtonPressed(views::Button* sender,
388 const ui::Event& event) { 398 const ui::Event& event) {
389 if (sender == use_billing_for_shipping_) { 399 if (sender == use_billing_for_shipping_) {
390 UpdateDetailsGroupState(*GroupForSection(SECTION_SHIPPING)); 400 UpdateDetailsGroupState(*GroupForSection(SECTION_SHIPPING));
391 } else if (sender == cancel_sign_in_) { 401 } else if (sender == cancel_sign_in_) {
392 controller_->EndSignInFlow(); 402 controller_->EndSignInFlow();
393 } else { 403 } else {
394 // TODO(estade): Should the menu be shown on mouse down? 404 // TODO(estade): Should the menu be shown on mouse down?
395 DetailsGroup* group = NULL; 405 DetailsGroup* group = NULL;
396 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 406 for (DetailGroupMap::iterator iter = detail_groups_.begin();
397 iter != detail_groups_.end(); ++iter) { 407 iter != detail_groups_.end(); ++iter) {
398 if (sender == iter->second.suggested_button) { 408 if (sender == iter->second.suggested_button) {
399 group = &iter->second; 409 group = &iter->second;
400 break; 410 break;
401 } 411 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 470 for (DetailGroupMap::iterator iter = detail_groups_.begin();
461 iter != detail_groups_.end(); ++iter) { 471 iter != detail_groups_.end(); ++iter) {
462 if (iter->second.suggested_info->Contains(source)) { 472 if (iter->second.suggested_info->Contains(source)) {
463 controller_->EditClickedForSection(iter->first); 473 controller_->EditClickedForSection(iter->first);
464 return; 474 return;
465 } 475 }
466 } 476 }
467 } 477 }
468 478
469 void AutofillDialogViews::InitChildViews() { 479 void AutofillDialogViews::InitChildViews() {
480 button_strip_extra_view_ = new views::View();
481 button_strip_extra_view_->SetLayoutManager(
482 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
483
484 // TODO(estade): i18n.
485 save_in_chrome_checkbox_ =
486 new views::Checkbox(controller_->SaveLocallyText());
487 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_);
488 // TODO(estade): add other views, like the Autocheckout progress bar.
489
470 contents_ = new views::View(); 490 contents_ = new views::View();
471 contents_->SetLayoutManager( 491 contents_->SetLayoutManager(
472 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 492 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
473 contents_->AddChildView(CreateMainContainer()); 493 contents_->AddChildView(CreateMainContainer());
474 contents_->AddChildView(CreateSignInContainer()); 494 contents_->AddChildView(CreateSignInContainer());
475 } 495 }
476 496
477 views::View* AutofillDialogViews::CreateSignInContainer() { 497 views::View* AutofillDialogViews::CreateSignInContainer() {
478 sign_in_container_ = new views::View(); 498 sign_in_container_ = new views::View();
479 sign_in_container_->SetLayoutManager( 499 sign_in_container_->SetLayoutManager(
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (show_checkbox && !use_billing_for_shipping_->visible()) 727 if (show_checkbox && !use_billing_for_shipping_->visible())
708 use_billing_for_shipping_->SetChecked(false); 728 use_billing_for_shipping_->SetChecked(false);
709 729
710 use_billing_for_shipping_->SetVisible(show_checkbox); 730 use_billing_for_shipping_->SetVisible(show_checkbox);
711 group.manual_input->SetVisible( 731 group.manual_input->SetVisible(
712 show_checkbox && !use_billing_for_shipping_->checked()); 732 show_checkbox && !use_billing_for_shipping_->checked());
713 } else { 733 } else {
714 group.manual_input->SetVisible(!show_suggestions); 734 group.manual_input->SetVisible(!show_suggestions);
715 } 735 }
716 736
737 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode,
738 // hide.
739 save_in_chrome_checkbox_->SetVisible(AtLeastOneSectionIsEditing());
740
717 if (group.container) 741 if (group.container)
718 group.container->SetForwardMouseEvents(show_suggestions); 742 group.container->SetForwardMouseEvents(show_suggestions);
719 743
720 if (GetWidget()) 744 if (GetWidget())
721 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); 745 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
722 } 746 }
723 747
748 bool AutofillDialogViews::AtLeastOneSectionIsEditing() {
749 for (DetailGroupMap::iterator iter = detail_groups_.begin();
750 iter != detail_groups_.end(); ++iter) {
751 if (iter->second.manual_input && iter->second.manual_input->visible())
752 return true;
753 }
754
755 return false;
756 }
757
724 bool AutofillDialogViews::ValidateForm() { 758 bool AutofillDialogViews::ValidateForm() {
725 bool all_valid = true; 759 bool all_valid = true;
726 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 760 for (DetailGroupMap::iterator iter = detail_groups_.begin();
727 iter != detail_groups_.end(); ++iter) { 761 iter != detail_groups_.end(); ++iter) {
728 DetailsGroup* group = &iter->second; 762 DetailsGroup* group = &iter->second;
729 if (group->manual_input->visible()) { 763 if (group->manual_input->visible()) {
730 for (TextfieldMap::iterator iter = group->textfields.begin(); 764 for (TextfieldMap::iterator iter = group->textfields.begin();
731 iter != group->textfields.end(); ++iter) { 765 iter != group->textfields.end(); ++iter) {
732 if (!controller_->InputIsValid(iter->first, 766 if (!controller_->InputIsValid(iter->first,
733 iter->second->textfield()->text())) { 767 iter->second->textfield()->text())) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 820 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
787 : section(section), 821 : section(section),
788 container(NULL), 822 container(NULL),
789 manual_input(NULL), 823 manual_input(NULL),
790 suggested_info(NULL), 824 suggested_info(NULL),
791 suggested_button(NULL) {} 825 suggested_button(NULL) {}
792 826
793 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 827 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
794 828
795 } // namespace autofill 829 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698