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

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

Issue 21692002: Rename AutofillDialogController to AutofillDialogViewDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 4 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') | chrome/chrome_browser_ui.gypi » ('j') | 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/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.h" 12 #include "chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
14 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" 14 #include "chrome/browser/ui/views/autofill/decorated_textfield.h"
15 #include "chrome/browser/ui/views/constrained_window_views.h" 15 #include "chrome/browser/ui/views/constrained_window_views.h"
16 #include "components/autofill/content/browser/wallet/wallet_service_url.h" 16 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
17 #include "components/autofill/core/browser/autofill_type.h" 17 #include "components/autofill/core/browser/autofill_type.h"
18 #include "components/web_modal/web_contents_modal_dialog_manager.h" 18 #include "components/web_modal/web_contents_modal_dialog_manager.h"
19 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 19 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
20 #include "content/public/browser/native_web_keyboard_event.h" 20 #include "content/public/browser/native_web_keyboard_event.h"
21 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_view.h" 23 #include "content/public/browser/web_contents_view.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 (anchor_bounds.width() + bubble_bounds.width()) / 2); 484 (anchor_bounds.width() + bubble_bounds.width()) / 2);
485 const int kErrorBubbleOverlap = 3; 485 const int kErrorBubbleOverlap = 3;
486 bubble_bounds.set_y(anchor_bounds.bottom() - kErrorBubbleOverlap); 486 bubble_bounds.set_y(anchor_bounds.bottom() - kErrorBubbleOverlap);
487 487
488 return bubble_bounds; 488 return bubble_bounds;
489 } 489 }
490 490
491 // AutofillDialogViews::AccountChooser ----------------------------------------- 491 // AutofillDialogViews::AccountChooser -----------------------------------------
492 492
493 AutofillDialogViews::AccountChooser::AccountChooser( 493 AutofillDialogViews::AccountChooser::AccountChooser(
494 AutofillDialogController* controller) 494 AutofillDialogViewDelegate* delegate)
495 : image_(new views::ImageView()), 495 : image_(new views::ImageView()),
496 label_(new views::Label()), 496 label_(new views::Label()),
497 arrow_(new views::ImageView()), 497 arrow_(new views::ImageView()),
498 link_(new views::Link()), 498 link_(new views::Link()),
499 controller_(controller) { 499 delegate_(delegate) {
500 SetLayoutManager( 500 SetLayoutManager(
501 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 501 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
502 kAroundTextPadding)); 502 kAroundTextPadding));
503 AddChildView(image_); 503 AddChildView(image_);
504 AddChildView(label_); 504 AddChildView(label_);
505 505
506 arrow_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageNamed( 506 arrow_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
507 IDR_MENU_DROPARROW).ToImageSkia()); 507 IDR_MENU_DROPARROW).ToImageSkia());
508 AddChildView(arrow_); 508 AddChildView(arrow_);
509 509
510 link_->set_listener(this); 510 link_->set_listener(this);
511 AddChildView(link_); 511 AddChildView(link_);
512 } 512 }
513 513
514 AutofillDialogViews::AccountChooser::~AccountChooser() {} 514 AutofillDialogViews::AccountChooser::~AccountChooser() {}
515 515
516 void AutofillDialogViews::AccountChooser::Update() { 516 void AutofillDialogViews::AccountChooser::Update() {
517 SetVisible(!controller_->ShouldShowSpinner()); 517 SetVisible(!delegate_->ShouldShowSpinner());
518 518
519 gfx::Image icon = controller_->AccountChooserImage(); 519 gfx::Image icon = delegate_->AccountChooserImage();
520 image_->SetImage(icon.AsImageSkia()); 520 image_->SetImage(icon.AsImageSkia());
521 label_->SetText(controller_->AccountChooserText()); 521 label_->SetText(delegate_->AccountChooserText());
522 522
523 bool show_link = !controller_->MenuModelForAccountChooser(); 523 bool show_link = !delegate_->MenuModelForAccountChooser();
524 label_->SetVisible(!show_link); 524 label_->SetVisible(!show_link);
525 arrow_->SetVisible(!show_link); 525 arrow_->SetVisible(!show_link);
526 link_->SetText(controller_->SignInLinkText()); 526 link_->SetText(delegate_->SignInLinkText());
527 link_->SetVisible(show_link); 527 link_->SetVisible(show_link);
528 528
529 menu_runner_.reset(); 529 menu_runner_.reset();
530 530
531 PreferredSizeChanged(); 531 PreferredSizeChanged();
532 } 532 }
533 533
534 bool AutofillDialogViews::AccountChooser::OnMousePressed( 534 bool AutofillDialogViews::AccountChooser::OnMousePressed(
535 const ui::MouseEvent& event) { 535 const ui::MouseEvent& event) {
536 // Return true so we get the release event. 536 // Return true so we get the release event.
537 if (controller_->MenuModelForAccountChooser()) 537 if (delegate_->MenuModelForAccountChooser())
538 return event.IsOnlyLeftMouseButton(); 538 return event.IsOnlyLeftMouseButton();
539 539
540 return false; 540 return false;
541 } 541 }
542 542
543 void AutofillDialogViews::AccountChooser::OnMouseReleased( 543 void AutofillDialogViews::AccountChooser::OnMouseReleased(
544 const ui::MouseEvent& event) { 544 const ui::MouseEvent& event) {
545 if (!HitTestPoint(event.location())) 545 if (!HitTestPoint(event.location()))
546 return; 546 return;
547 547
548 ui::MenuModel* model = controller_->MenuModelForAccountChooser(); 548 ui::MenuModel* model = delegate_->MenuModelForAccountChooser();
549 if (!model) 549 if (!model)
550 return; 550 return;
551 551
552 menu_runner_.reset(new views::MenuRunner(model)); 552 menu_runner_.reset(new views::MenuRunner(model));
553 ignore_result( 553 ignore_result(
554 menu_runner_->RunMenuAt(GetWidget(), 554 menu_runner_->RunMenuAt(GetWidget(),
555 NULL, 555 NULL,
556 GetBoundsInScreen(), 556 GetBoundsInScreen(),
557 views::MenuItemView::TOPRIGHT, 557 views::MenuItemView::TOPRIGHT,
558 ui::MENU_SOURCE_MOUSE, 558 ui::MENU_SOURCE_MOUSE,
559 0)); 559 0));
560 } 560 }
561 561
562 void AutofillDialogViews::AccountChooser::LinkClicked(views::Link* source, 562 void AutofillDialogViews::AccountChooser::LinkClicked(views::Link* source,
563 int event_flags) { 563 int event_flags) {
564 controller_->SignInLinkClicked(); 564 delegate_->SignInLinkClicked();
565 } 565 }
566 566
567 // AutofillDialogViews::OverlayView -------------------------------------------- 567 // AutofillDialogViews::OverlayView --------------------------------------------
568 568
569 AutofillDialogViews::OverlayView::OverlayView(views::ButtonListener* listener) 569 AutofillDialogViews::OverlayView::OverlayView(views::ButtonListener* listener)
570 : image_view_(new views::ImageView()), 570 : image_view_(new views::ImageView()),
571 message_stack_(new views::View()), 571 message_stack_(new views::View()),
572 button_(new views::BlueButton(listener, base::string16())) { 572 button_(new views::BlueButton(listener, base::string16())) {
573 set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> 573 set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
574 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); 574 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 int bubble_width = 5; 771 int bubble_width = 5;
772 if (GetBubbleBorder()) 772 if (GetBubbleBorder())
773 bubble_width = GetBubbleBorder()->GetBorderThickness(); 773 bubble_width = GetBubbleBorder()->GetBorderThickness();
774 bounds.Inset(bubble_width, bubble_width, bubble_width, bubble_width); 774 bounds.Inset(bubble_width, bubble_width, bubble_width, bubble_width);
775 return bounds; 775 return bounds;
776 } 776 }
777 777
778 // AutofillDialogViews::NotificationArea --------------------------------------- 778 // AutofillDialogViews::NotificationArea ---------------------------------------
779 779
780 AutofillDialogViews::NotificationArea::NotificationArea( 780 AutofillDialogViews::NotificationArea::NotificationArea(
781 AutofillDialogController* controller) 781 AutofillDialogViewDelegate* delegate)
782 : controller_(controller), 782 : delegate_(delegate),
783 checkbox_(NULL) { 783 checkbox_(NULL) {
784 // Reserve vertical space for the arrow (regardless of whether one exists). 784 // Reserve vertical space for the arrow (regardless of whether one exists).
785 // The -1 accounts for the border. 785 // The -1 accounts for the border.
786 set_border(views::Border::CreateEmptyBorder(kArrowHeight - 1, 0, 0, 0)); 786 set_border(views::Border::CreateEmptyBorder(kArrowHeight - 1, 0, 0, 0));
787 787
788 views::BoxLayout* box_layout = 788 views::BoxLayout* box_layout =
789 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 789 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
790 SetLayoutManager(box_layout); 790 SetLayoutManager(box_layout);
791 } 791 }
792 792
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } 849 }
850 850
851 void AutofillDialogViews::OnWidgetBoundsChanged(views::Widget* widget, 851 void AutofillDialogViews::OnWidgetBoundsChanged(views::Widget* widget,
852 const gfx::Rect& new_bounds) { 852 const gfx::Rect& new_bounds) {
853 ContentsPreferredSizeChanged(); 853 ContentsPreferredSizeChanged();
854 } 854 }
855 855
856 void AutofillDialogViews::NotificationArea::ButtonPressed( 856 void AutofillDialogViews::NotificationArea::ButtonPressed(
857 views::Button* sender, const ui::Event& event) { 857 views::Button* sender, const ui::Event& event) {
858 DCHECK_EQ(sender, checkbox_); 858 DCHECK_EQ(sender, checkbox_);
859 controller_->NotificationCheckboxStateChanged(notifications_.front().type(), 859 delegate_->NotificationCheckboxStateChanged(notifications_.front().type(),
860 checkbox_->checked()); 860 checkbox_->checked());
861 } 861 }
862 862
863 bool AutofillDialogViews::NotificationArea::HasArrow() { 863 bool AutofillDialogViews::NotificationArea::HasArrow() {
864 return !notifications_.empty() && notifications_[0].HasArrow() && 864 return !notifications_.empty() && notifications_[0].HasArrow() &&
865 arrow_centering_anchor_.get(); 865 arrow_centering_anchor_.get();
866 } 866 }
867 867
868 // AutofillDialogViews::SectionContainer --------------------------------------- 868 // AutofillDialogViews::SectionContainer ---------------------------------------
869 869
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 1090
1091 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() { 1091 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() {
1092 return gfx::Size(kAutocheckoutProgressBarWidth, 1092 return gfx::Size(kAutocheckoutProgressBarWidth,
1093 kAutocheckoutProgressBarHeight); 1093 kAutocheckoutProgressBarHeight);
1094 } 1094 }
1095 1095
1096 // AutofillDialogView ---------------------------------------------------------- 1096 // AutofillDialogView ----------------------------------------------------------
1097 1097
1098 // static 1098 // static
1099 AutofillDialogView* AutofillDialogView::Create( 1099 AutofillDialogView* AutofillDialogView::Create(
1100 AutofillDialogController* controller) { 1100 AutofillDialogViewDelegate* delegate) {
1101 return new AutofillDialogViews(controller); 1101 return new AutofillDialogViews(delegate);
1102 } 1102 }
1103 1103
1104 // AutofillDialogViews --------------------------------------------------------- 1104 // AutofillDialogViews ---------------------------------------------------------
1105 1105
1106 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) 1106 AutofillDialogViews::AutofillDialogViews(AutofillDialogViewDelegate* delegate)
1107 : controller_(controller), 1107 : delegate_(delegate),
1108 window_(NULL), 1108 window_(NULL),
1109 notification_area_(NULL), 1109 notification_area_(NULL),
1110 account_chooser_(NULL), 1110 account_chooser_(NULL),
1111 sign_in_webview_(NULL), 1111 sign_in_webview_(NULL),
1112 scrollable_area_(NULL), 1112 scrollable_area_(NULL),
1113 details_container_(NULL), 1113 details_container_(NULL),
1114 loading_shield_(NULL), 1114 loading_shield_(NULL),
1115 overlay_view_(NULL), 1115 overlay_view_(NULL),
1116 button_strip_extra_view_(NULL), 1116 button_strip_extra_view_(NULL),
1117 save_in_chrome_checkbox_(NULL), 1117 save_in_chrome_checkbox_(NULL),
1118 button_strip_image_(NULL), 1118 button_strip_image_(NULL),
1119 autocheckout_steps_area_(NULL), 1119 autocheckout_steps_area_(NULL),
1120 autocheckout_progress_bar_view_(NULL), 1120 autocheckout_progress_bar_view_(NULL),
1121 autocheckout_progress_bar_(NULL), 1121 autocheckout_progress_bar_(NULL),
1122 footnote_view_(NULL), 1122 footnote_view_(NULL),
1123 legal_document_view_(NULL), 1123 legal_document_view_(NULL),
1124 focus_manager_(NULL), 1124 focus_manager_(NULL),
1125 observer_(this) { 1125 observer_(this) {
1126 DCHECK(controller); 1126 DCHECK(delegate);
1127 detail_groups_.insert(std::make_pair(SECTION_EMAIL, 1127 detail_groups_.insert(std::make_pair(SECTION_EMAIL,
1128 DetailsGroup(SECTION_EMAIL))); 1128 DetailsGroup(SECTION_EMAIL)));
1129 detail_groups_.insert(std::make_pair(SECTION_CC, 1129 detail_groups_.insert(std::make_pair(SECTION_CC,
1130 DetailsGroup(SECTION_CC))); 1130 DetailsGroup(SECTION_CC)));
1131 detail_groups_.insert(std::make_pair(SECTION_BILLING, 1131 detail_groups_.insert(std::make_pair(SECTION_BILLING,
1132 DetailsGroup(SECTION_BILLING))); 1132 DetailsGroup(SECTION_BILLING)));
1133 detail_groups_.insert(std::make_pair(SECTION_CC_BILLING, 1133 detail_groups_.insert(std::make_pair(SECTION_CC_BILLING,
1134 DetailsGroup(SECTION_CC_BILLING))); 1134 DetailsGroup(SECTION_CC_BILLING)));
1135 detail_groups_.insert(std::make_pair(SECTION_SHIPPING, 1135 detail_groups_.insert(std::make_pair(SECTION_SHIPPING,
1136 DetailsGroup(SECTION_SHIPPING))); 1136 DetailsGroup(SECTION_SHIPPING)));
1137 } 1137 }
1138 1138
1139 AutofillDialogViews::~AutofillDialogViews() { 1139 AutofillDialogViews::~AutofillDialogViews() {
1140 DCHECK(!window_); 1140 DCHECK(!window_);
1141 } 1141 }
1142 1142
1143 void AutofillDialogViews::Show() { 1143 void AutofillDialogViews::Show() {
1144 InitChildViews(); 1144 InitChildViews();
1145 UpdateAccountChooser(); 1145 UpdateAccountChooser();
1146 UpdateNotificationArea(); 1146 UpdateNotificationArea();
1147 UpdateButtonStripExtraView(); 1147 UpdateButtonStripExtraView();
1148 1148
1149 // Ownership of |contents_| is handed off by this call. The widget will take 1149 // Ownership of |contents_| is handed off by this call. The widget will take
1150 // care of deleting itself after calling DeleteDelegate(). 1150 // care of deleting itself after calling DeleteDelegate().
1151 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 1151 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
1152 WebContentsModalDialogManager::FromWebContents( 1152 WebContentsModalDialogManager::FromWebContents(
1153 controller_->web_contents()); 1153 delegate_->web_contents());
1154 window_ = CreateWebContentsModalDialogViews( 1154 window_ = CreateWebContentsModalDialogViews(
1155 this, 1155 this,
1156 controller_->web_contents()->GetView()->GetNativeView(), 1156 delegate_->web_contents()->GetView()->GetNativeView(),
1157 web_contents_modal_dialog_manager->delegate()-> 1157 web_contents_modal_dialog_manager->delegate()->
1158 GetWebContentsModalDialogHost()); 1158 GetWebContentsModalDialogHost());
1159 web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView()); 1159 web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView());
1160 focus_manager_ = window_->GetFocusManager(); 1160 focus_manager_ = window_->GetFocusManager();
1161 focus_manager_->AddFocusChangeListener(this); 1161 focus_manager_->AddFocusChangeListener(this);
1162 1162
1163 // Listen for size changes on the browser. 1163 // Listen for size changes on the browser.
1164 views::Widget* browser_widget = 1164 views::Widget* browser_widget =
1165 views::Widget::GetTopLevelWidgetForNativeView( 1165 views::Widget::GetTopLevelWidgetForNativeView(
1166 controller_->web_contents()->GetView()->GetNativeView()); 1166 delegate_->web_contents()->GetView()->GetNativeView());
1167 observer_.Add(browser_widget); 1167 observer_.Add(browser_widget);
1168 1168
1169 gfx::Image splash_image = controller_->SplashPageImage(); 1169 gfx::Image splash_image = delegate_->SplashPageImage();
1170 if (!splash_image.IsEmpty()) { 1170 if (!splash_image.IsEmpty()) {
1171 DialogOverlayState state; 1171 DialogOverlayState state;
1172 state.image = splash_image; 1172 state.image = splash_image;
1173 overlay_view_->SetState(state, NULL); 1173 overlay_view_->SetState(state, NULL);
1174 overlay_view_->BeginFadeOut(); 1174 overlay_view_->BeginFadeOut();
1175 } 1175 }
1176 } 1176 }
1177 1177
1178 void AutofillDialogViews::Hide() { 1178 void AutofillDialogViews::Hide() {
1179 if (window_) 1179 if (window_)
1180 window_->Close(); 1180 window_->Close();
1181 } 1181 }
1182 1182
1183 void AutofillDialogViews::UpdateAccountChooser() { 1183 void AutofillDialogViews::UpdateAccountChooser() {
1184 account_chooser_->Update(); 1184 account_chooser_->Update();
1185 // TODO(estade): replace this with a better loading image/animation. 1185 // TODO(estade): replace this with a better loading image/animation.
1186 // See http://crbug.com/230932 1186 // See http://crbug.com/230932
1187 base::string16 new_loading_message = (controller_->ShouldShowSpinner() ? 1187 base::string16 new_loading_message = (delegate_->ShouldShowSpinner() ?
1188 ASCIIToUTF16("Loading...") : base::string16()); 1188 ASCIIToUTF16("Loading...") : base::string16());
1189 if (new_loading_message != loading_shield_->text()) { 1189 if (new_loading_message != loading_shield_->text()) {
1190 loading_shield_->SetText(new_loading_message); 1190 loading_shield_->SetText(new_loading_message);
1191 loading_shield_->SetVisible(!new_loading_message.empty()); 1191 loading_shield_->SetVisible(!new_loading_message.empty());
1192 Layout(); 1192 Layout();
1193 } 1193 }
1194 1194
1195 // Update legal documents for the account. 1195 // Update legal documents for the account.
1196 if (footnote_view_) { 1196 if (footnote_view_) {
1197 const base::string16 text = controller_->LegalDocumentsText(); 1197 const base::string16 text = delegate_->LegalDocumentsText();
1198 legal_document_view_->SetText(text); 1198 legal_document_view_->SetText(text);
1199 1199
1200 if (!text.empty()) { 1200 if (!text.empty()) {
1201 const std::vector<ui::Range>& link_ranges = 1201 const std::vector<ui::Range>& link_ranges =
1202 controller_->LegalDocumentLinks(); 1202 delegate_->LegalDocumentLinks();
1203 for (size_t i = 0; i < link_ranges.size(); ++i) { 1203 for (size_t i = 0; i < link_ranges.size(); ++i) {
1204 legal_document_view_->AddStyleRange( 1204 legal_document_view_->AddStyleRange(
1205 link_ranges[i], 1205 link_ranges[i],
1206 views::StyledLabel::RangeStyleInfo::CreateForLink()); 1206 views::StyledLabel::RangeStyleInfo::CreateForLink());
1207 } 1207 }
1208 } 1208 }
1209 1209
1210 footnote_view_->SetVisible(!text.empty()); 1210 footnote_view_->SetVisible(!text.empty());
1211 ContentsPreferredSizeChanged(); 1211 ContentsPreferredSizeChanged();
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 void AutofillDialogViews::UpdateAutocheckoutStepsArea() { 1215 void AutofillDialogViews::UpdateAutocheckoutStepsArea() {
1216 autocheckout_steps_area_->SetSteps(controller_->CurrentAutocheckoutSteps()); 1216 autocheckout_steps_area_->SetSteps(delegate_->CurrentAutocheckoutSteps());
1217 ContentsPreferredSizeChanged(); 1217 ContentsPreferredSizeChanged();
1218 } 1218 }
1219 1219
1220 void AutofillDialogViews::UpdateButtonStrip() { 1220 void AutofillDialogViews::UpdateButtonStrip() {
1221 button_strip_extra_view_->SetVisible( 1221 button_strip_extra_view_->SetVisible(
1222 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); 1222 GetDialogButtons() != ui::DIALOG_BUTTON_NONE);
1223 UpdateButtonStripExtraView(); 1223 UpdateButtonStripExtraView();
1224 GetDialogClientView()->UpdateDialogButtons(); 1224 GetDialogClientView()->UpdateDialogButtons();
1225 1225
1226 overlay_view_->SetState(controller_->GetDialogOverlay(), this); 1226 overlay_view_->SetState(delegate_->GetDialogOverlay(), this);
1227 1227
1228 ContentsPreferredSizeChanged(); 1228 ContentsPreferredSizeChanged();
1229 } 1229 }
1230 1230
1231 void AutofillDialogViews::UpdateDetailArea() { 1231 void AutofillDialogViews::UpdateDetailArea() {
1232 scrollable_area_->SetVisible(controller_->ShouldShowDetailArea()); 1232 scrollable_area_->SetVisible(delegate_->ShouldShowDetailArea());
1233 ContentsPreferredSizeChanged(); 1233 ContentsPreferredSizeChanged();
1234 } 1234 }
1235 1235
1236 void AutofillDialogViews::UpdateForErrors() { 1236 void AutofillDialogViews::UpdateForErrors() {
1237 ValidateForm(); 1237 ValidateForm();
1238 } 1238 }
1239 1239
1240 void AutofillDialogViews::UpdateNotificationArea() { 1240 void AutofillDialogViews::UpdateNotificationArea() {
1241 DCHECK(notification_area_); 1241 DCHECK(notification_area_);
1242 notification_area_->SetNotifications(controller_->CurrentNotifications()); 1242 notification_area_->SetNotifications(delegate_->CurrentNotifications());
1243 ContentsPreferredSizeChanged(); 1243 ContentsPreferredSizeChanged();
1244 } 1244 }
1245 1245
1246 void AutofillDialogViews::UpdateSection(DialogSection section) { 1246 void AutofillDialogViews::UpdateSection(DialogSection section) {
1247 UpdateSectionImpl(section, true); 1247 UpdateSectionImpl(section, true);
1248 } 1248 }
1249 1249
1250 void AutofillDialogViews::FillSection(DialogSection section, 1250 void AutofillDialogViews::FillSection(DialogSection section,
1251 const DetailInput& originating_input) { 1251 const DetailInput& originating_input) {
1252 DetailsGroup* group = GroupForSection(section); 1252 DetailsGroup* group = GroupForSection(section);
(...skipping 26 matching lines...) Expand all
1279 output->insert(std::make_pair(it->first, it->second->text())); 1279 output->insert(std::make_pair(it->first, it->second->text()));
1280 } 1280 }
1281 for (ComboboxMap::const_iterator it = group->comboboxes.begin(); 1281 for (ComboboxMap::const_iterator it = group->comboboxes.begin();
1282 it != group->comboboxes.end(); ++it) { 1282 it != group->comboboxes.end(); ++it) {
1283 output->insert(std::make_pair(it->first, 1283 output->insert(std::make_pair(it->first,
1284 it->second->model()->GetItemAt(it->second->selected_index()))); 1284 it->second->model()->GetItemAt(it->second->selected_index())));
1285 } 1285 }
1286 } 1286 }
1287 1287
1288 base::string16 AutofillDialogViews::GetCvc() { 1288 base::string16 AutofillDialogViews::GetCvc() {
1289 DialogSection billing_section = controller_->SectionIsActive(SECTION_CC) ? 1289 DialogSection billing_section = delegate_->SectionIsActive(SECTION_CC) ?
1290 SECTION_CC : SECTION_CC_BILLING; 1290 SECTION_CC : SECTION_CC_BILLING;
1291 return GroupForSection(billing_section)->suggested_info-> 1291 return GroupForSection(billing_section)->suggested_info->
1292 decorated_textfield()->text(); 1292 decorated_textfield()->text();
1293 } 1293 }
1294 1294
1295 bool AutofillDialogViews::SaveDetailsLocally() { 1295 bool AutofillDialogViews::SaveDetailsLocally() {
1296 DCHECK(save_in_chrome_checkbox_->visible()); 1296 DCHECK(save_in_chrome_checkbox_->visible());
1297 return save_in_chrome_checkbox_->checked(); 1297 return save_in_chrome_checkbox_->checked();
1298 } 1298 }
1299 1299
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 gfx::Size preferred_size; 1425 gfx::Size preferred_size;
1426 // When the scroll area isn't visible, it still sets the width but doesn't 1426 // When the scroll area isn't visible, it still sets the width but doesn't
1427 // factor into height. 1427 // factor into height.
1428 if (!scrollable_area_->visible()) { 1428 if (!scrollable_area_->visible()) {
1429 preferred_size.SetSize(width, base_height); 1429 preferred_size.SetSize(width, base_height);
1430 } else { 1430 } else {
1431 // Show as much of the scroll view as is possible without going past the 1431 // Show as much of the scroll view as is possible without going past the
1432 // bottom of the browser window. 1432 // bottom of the browser window.
1433 views::Widget* widget = 1433 views::Widget* widget =
1434 views::Widget::GetTopLevelWidgetForNativeView( 1434 views::Widget::GetTopLevelWidgetForNativeView(
1435 controller_->web_contents()->GetView()->GetNativeView()); 1435 delegate_->web_contents()->GetView()->GetNativeView());
1436 int browser_window_height = 1436 int browser_window_height =
1437 widget ? widget->GetContentsView()->bounds().height() : INT_MAX; 1437 widget ? widget->GetContentsView()->bounds().height() : INT_MAX;
1438 const int kWindowDecorationHeight = 200; 1438 const int kWindowDecorationHeight = 200;
1439 int height = base_height + std::min( 1439 int height = base_height + std::min(
1440 scroll_size.height(), 1440 scroll_size.height(),
1441 std::max(kMinimumContentsHeight, 1441 std::max(kMinimumContentsHeight,
1442 browser_window_height - base_height - 1442 browser_window_height - base_height -
1443 kWindowDecorationHeight)); 1443 kWindowDecorationHeight));
1444 preferred_size.SetSize(width, height); 1444 preferred_size.SetSize(width, height);
1445 } 1445 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1493
1494 if (error_bubble_) 1494 if (error_bubble_)
1495 error_bubble_->UpdatePosition(); 1495 error_bubble_->UpdatePosition();
1496 } 1496 }
1497 1497
1498 void AutofillDialogViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1498 void AutofillDialogViews::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1499 sign_in_delegate_->SetMinWidth(GetContentsBounds().width()); 1499 sign_in_delegate_->SetMinWidth(GetContentsBounds().width());
1500 } 1500 }
1501 1501
1502 base::string16 AutofillDialogViews::GetWindowTitle() const { 1502 base::string16 AutofillDialogViews::GetWindowTitle() const {
1503 return controller_->DialogTitle(); 1503 return delegate_->DialogTitle();
1504 } 1504 }
1505 1505
1506 void AutofillDialogViews::WindowClosing() { 1506 void AutofillDialogViews::WindowClosing() {
1507 focus_manager_->RemoveFocusChangeListener(this); 1507 focus_manager_->RemoveFocusChangeListener(this);
1508 } 1508 }
1509 1509
1510 void AutofillDialogViews::DeleteDelegate() { 1510 void AutofillDialogViews::DeleteDelegate() {
1511 window_ = NULL; 1511 window_ = NULL;
1512 // |this| belongs to |controller_|. 1512 // |this| belongs to the controller (|delegate_|).
1513 controller_->ViewClosed(); 1513 delegate_->ViewClosed();
1514 } 1514 }
1515 1515
1516 int AutofillDialogViews::GetDialogButtons() const { 1516 int AutofillDialogViews::GetDialogButtons() const {
1517 if (sign_in_webview_->visible()) 1517 if (sign_in_webview_->visible())
1518 return ui::DIALOG_BUTTON_NONE; 1518 return ui::DIALOG_BUTTON_NONE;
1519 1519
1520 return controller_->GetDialogButtons(); 1520 return delegate_->GetDialogButtons();
1521 } 1521 }
1522 1522
1523 base::string16 AutofillDialogViews::GetDialogButtonLabel( 1523 base::string16 AutofillDialogViews::GetDialogButtonLabel(
1524 ui::DialogButton button) const { 1524 ui::DialogButton button) const {
1525 return button == ui::DIALOG_BUTTON_OK ? 1525 return button == ui::DIALOG_BUTTON_OK ?
1526 controller_->ConfirmButtonText() : controller_->CancelButtonText(); 1526 delegate_->ConfirmButtonText() : delegate_->CancelButtonText();
1527 } 1527 }
1528 1528
1529 bool AutofillDialogViews::ShouldDefaultButtonBeBlue() const { 1529 bool AutofillDialogViews::ShouldDefaultButtonBeBlue() const {
1530 return true; 1530 return true;
1531 } 1531 }
1532 1532
1533 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { 1533 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const {
1534 return controller_->IsDialogButtonEnabled(button); 1534 return delegate_->IsDialogButtonEnabled(button);
1535 } 1535 }
1536 1536
1537 views::View* AutofillDialogViews::CreateExtraView() { 1537 views::View* AutofillDialogViews::CreateExtraView() {
1538 return button_strip_extra_view_; 1538 return button_strip_extra_view_;
1539 } 1539 }
1540 1540
1541 views::View* AutofillDialogViews::CreateTitlebarExtraView() { 1541 views::View* AutofillDialogViews::CreateTitlebarExtraView() {
1542 return account_chooser_; 1542 return account_chooser_;
1543 } 1543 }
1544 1544
(...skipping 18 matching lines...) Expand all
1563 footnote_view_->SetVisible(false); 1563 footnote_view_->SetVisible(false);
1564 1564
1565 return footnote_view_; 1565 return footnote_view_;
1566 } 1566 }
1567 1567
1568 views::View* AutofillDialogViews::CreateOverlayView() { 1568 views::View* AutofillDialogViews::CreateOverlayView() {
1569 return overlay_view_; 1569 return overlay_view_;
1570 } 1570 }
1571 1571
1572 bool AutofillDialogViews::Cancel() { 1572 bool AutofillDialogViews::Cancel() {
1573 return controller_->OnCancel(); 1573 return delegate_->OnCancel();
1574 } 1574 }
1575 1575
1576 bool AutofillDialogViews::Accept() { 1576 bool AutofillDialogViews::Accept() {
1577 if (ValidateForm()) 1577 if (ValidateForm())
1578 return controller_->OnAccept(); 1578 return delegate_->OnAccept();
1579 1579
1580 if (!validity_map_.empty()) 1580 if (!validity_map_.empty())
1581 validity_map_.begin()->first->RequestFocus(); 1581 validity_map_.begin()->first->RequestFocus();
1582 return false; 1582 return false;
1583 } 1583 }
1584 1584
1585 // TODO(wittman): Remove this override once we move to the new style frame view 1585 // TODO(wittman): Remove this override once we move to the new style frame view
1586 // on all dialogs. 1586 // on all dialogs.
1587 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( 1587 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView(
1588 views::Widget* widget) { 1588 views::Widget* widget) {
1589 return CreateConstrainedStyleNonClientFrameView( 1589 return CreateConstrainedStyleNonClientFrameView(
1590 widget, 1590 widget,
1591 controller_->web_contents()->GetBrowserContext()); 1591 delegate_->web_contents()->GetBrowserContext());
1592 } 1592 }
1593 1593
1594 void AutofillDialogViews::ButtonPressed(views::Button* sender, 1594 void AutofillDialogViews::ButtonPressed(views::Button* sender,
1595 const ui::Event& event) { 1595 const ui::Event& event) {
1596 if (sender->GetAncestorWithClassName(kOverlayViewClassName)) { 1596 if (sender->GetAncestorWithClassName(kOverlayViewClassName)) {
1597 controller_->OverlayButtonPressed(); 1597 delegate_->OverlayButtonPressed();
1598 return; 1598 return;
1599 } 1599 }
1600 1600
1601 // TODO(estade): Should the menu be shown on mouse down? 1601 // TODO(estade): Should the menu be shown on mouse down?
1602 DetailsGroup* group = NULL; 1602 DetailsGroup* group = NULL;
1603 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1603 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1604 iter != detail_groups_.end(); ++iter) { 1604 iter != detail_groups_.end(); ++iter) {
1605 if (sender == iter->second.suggested_button) { 1605 if (sender == iter->second.suggested_button) {
1606 group = &iter->second; 1606 group = &iter->second;
1607 break; 1607 break;
1608 } 1608 }
1609 } 1609 }
1610 DCHECK(group); 1610 DCHECK(group);
1611 1611
1612 if (!group->suggested_button->visible()) 1612 if (!group->suggested_button->visible())
1613 return; 1613 return;
1614 1614
1615 menu_runner_.reset(new views::MenuRunner( 1615 menu_runner_.reset(new views::MenuRunner(
1616 controller_->MenuModelForSection(group->section))); 1616 delegate_->MenuModelForSection(group->section)));
1617 1617
1618 group->container->SetActive(true); 1618 group->container->SetActive(true);
1619 views::Button::ButtonState state = group->suggested_button->state(); 1619 views::Button::ButtonState state = group->suggested_button->state();
1620 group->suggested_button->SetState(views::Button::STATE_PRESSED); 1620 group->suggested_button->SetState(views::Button::STATE_PRESSED);
1621 // Ignore the result since we don't need to handle a deleted menu specially. 1621 // Ignore the result since we don't need to handle a deleted menu specially.
1622 gfx::Rect bounds = group->suggested_button->GetBoundsInScreen(); 1622 gfx::Rect bounds = group->suggested_button->GetBoundsInScreen();
1623 bounds.Inset(group->suggested_button->GetInsets()); 1623 bounds.Inset(group->suggested_button->GetInsets());
1624 ignore_result( 1624 ignore_result(
1625 menu_runner_->RunMenuAt(sender->GetWidget(), 1625 menu_runner_->RunMenuAt(sender->GetWidget(),
1626 NULL, 1626 NULL,
(...skipping 11 matching lines...) Expand all
1638 } 1638 }
1639 1639
1640 bool AutofillDialogViews::HandleKeyEvent(views::Textfield* sender, 1640 bool AutofillDialogViews::HandleKeyEvent(views::Textfield* sender,
1641 const ui::KeyEvent& key_event) { 1641 const ui::KeyEvent& key_event) {
1642 scoped_ptr<ui::KeyEvent> copy(key_event.Copy()); 1642 scoped_ptr<ui::KeyEvent> copy(key_event.Copy());
1643 #if defined(OS_WIN) && !defined(USE_AURA) 1643 #if defined(OS_WIN) && !defined(USE_AURA)
1644 content::NativeWebKeyboardEvent event(copy->native_event()); 1644 content::NativeWebKeyboardEvent event(copy->native_event());
1645 #else 1645 #else
1646 content::NativeWebKeyboardEvent event(copy.get()); 1646 content::NativeWebKeyboardEvent event(copy.get());
1647 #endif 1647 #endif
1648 return controller_->HandleKeyPressEventInInput(event); 1648 return delegate_->HandleKeyPressEventInInput(event);
1649 } 1649 }
1650 1650
1651 bool AutofillDialogViews::HandleMouseEvent(views::Textfield* sender, 1651 bool AutofillDialogViews::HandleMouseEvent(views::Textfield* sender,
1652 const ui::MouseEvent& mouse_event) { 1652 const ui::MouseEvent& mouse_event) {
1653 if (mouse_event.IsLeftMouseButton() && sender->HasFocus()) { 1653 if (mouse_event.IsLeftMouseButton() && sender->HasFocus()) {
1654 TextfieldEditedOrActivated(sender, false); 1654 TextfieldEditedOrActivated(sender, false);
1655 // Show an error bubble if a user clicks on an input that's already focused 1655 // Show an error bubble if a user clicks on an input that's already focused
1656 // (and invalid). 1656 // (and invalid).
1657 ShowErrorBubbleForViewIfNecessary(sender); 1657 ShowErrorBubbleForViewIfNecessary(sender);
1658 } 1658 }
1659 1659
1660 return false; 1660 return false;
1661 } 1661 }
1662 1662
1663 void AutofillDialogViews::OnWillChangeFocus( 1663 void AutofillDialogViews::OnWillChangeFocus(
1664 views::View* focused_before, 1664 views::View* focused_before,
1665 views::View* focused_now) { 1665 views::View* focused_now) {
1666 controller_->FocusMoved(); 1666 delegate_->FocusMoved();
1667 error_bubble_.reset(); 1667 error_bubble_.reset();
1668 } 1668 }
1669 1669
1670 void AutofillDialogViews::OnDidChangeFocus( 1670 void AutofillDialogViews::OnDidChangeFocus(
1671 views::View* focused_before, 1671 views::View* focused_before,
1672 views::View* focused_now) { 1672 views::View* focused_now) {
1673 // If user leaves an edit-field, revalidate the group it belongs to. 1673 // If user leaves an edit-field, revalidate the group it belongs to.
1674 if (focused_before) { 1674 if (focused_before) {
1675 DetailsGroup* group = GroupForView(focused_before); 1675 DetailsGroup* group = GroupForView(focused_before);
1676 if (group && group->container->visible()) 1676 if (group && group->container->visible())
1677 ValidateGroup(*group, VALIDATE_EDIT); 1677 ValidateGroup(*group, VALIDATE_EDIT);
1678 } 1678 }
1679 1679
1680 // Show an error bubble when the user focuses the input. 1680 // Show an error bubble when the user focuses the input.
1681 if (focused_now) 1681 if (focused_now)
1682 ShowErrorBubbleForViewIfNecessary(focused_now); 1682 ShowErrorBubbleForViewIfNecessary(focused_now);
1683 } 1683 }
1684 1684
1685 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { 1685 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) {
1686 DetailsGroup* group = GroupForView(combobox); 1686 DetailsGroup* group = GroupForView(combobox);
1687 ValidateGroup(*group, VALIDATE_EDIT); 1687 ValidateGroup(*group, VALIDATE_EDIT);
1688 } 1688 }
1689 1689
1690 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, 1690 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range,
1691 int event_flags) { 1691 int event_flags) {
1692 controller_->LegalDocumentLinkClicked(range); 1692 delegate_->LegalDocumentLinkClicked(range);
1693 } 1693 }
1694 1694
1695 void AutofillDialogViews::InitChildViews() { 1695 void AutofillDialogViews::InitChildViews() {
1696 button_strip_extra_view_ = new LayoutPropagationView(); 1696 button_strip_extra_view_ = new LayoutPropagationView();
1697 button_strip_extra_view_->SetLayoutManager( 1697 button_strip_extra_view_->SetLayoutManager(
1698 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 1698 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
1699 1699
1700 save_in_chrome_checkbox_ = 1700 save_in_chrome_checkbox_ =
1701 new views::Checkbox(controller_->SaveLocallyText()); 1701 new views::Checkbox(delegate_->SaveLocallyText());
1702 save_in_chrome_checkbox_->SetChecked(true); 1702 save_in_chrome_checkbox_->SetChecked(true);
1703 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); 1703 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_);
1704 1704
1705 button_strip_image_ = new views::ImageView(); 1705 button_strip_image_ = new views::ImageView();
1706 button_strip_extra_view_->AddChildView(button_strip_image_); 1706 button_strip_extra_view_->AddChildView(button_strip_image_);
1707 1707
1708 autocheckout_progress_bar_view_ = new views::View(); 1708 autocheckout_progress_bar_view_ = new views::View();
1709 views::GridLayout* progress_bar_layout = 1709 views::GridLayout* progress_bar_layout =
1710 new views::GridLayout(autocheckout_progress_bar_view_); 1710 new views::GridLayout(autocheckout_progress_bar_view_);
1711 autocheckout_progress_bar_view_->SetLayoutManager(progress_bar_layout); 1711 autocheckout_progress_bar_view_->SetLayoutManager(progress_bar_layout);
1712 const int kColumnSetId = 0; 1712 const int kColumnSetId = 0;
1713 views::ColumnSet* columns = progress_bar_layout->AddColumnSet(kColumnSetId); 1713 views::ColumnSet* columns = progress_bar_layout->AddColumnSet(kColumnSetId);
1714 columns->AddColumn(views::GridLayout::LEADING, 1714 columns->AddColumn(views::GridLayout::LEADING,
1715 views::GridLayout::CENTER, 1715 views::GridLayout::CENTER,
1716 0, 1716 0,
1717 views::GridLayout::USE_PREF, 1717 views::GridLayout::USE_PREF,
1718 0, 1718 0,
1719 0); 1719 0);
1720 progress_bar_layout->StartRow(1.0, kColumnSetId); 1720 progress_bar_layout->StartRow(1.0, kColumnSetId);
1721 1721
1722 autocheckout_progress_bar_ = new AutocheckoutProgressBar(); 1722 autocheckout_progress_bar_ = new AutocheckoutProgressBar();
1723 progress_bar_layout->AddView(autocheckout_progress_bar_); 1723 progress_bar_layout->AddView(autocheckout_progress_bar_);
1724 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_); 1724 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_);
1725 1725
1726 account_chooser_ = new AccountChooser(controller_); 1726 account_chooser_ = new AccountChooser(delegate_);
1727 notification_area_ = new NotificationArea(controller_); 1727 notification_area_ = new NotificationArea(delegate_);
1728 notification_area_->set_arrow_centering_anchor(account_chooser_->AsWeakPtr()); 1728 notification_area_->set_arrow_centering_anchor(account_chooser_->AsWeakPtr());
1729 AddChildView(notification_area_); 1729 AddChildView(notification_area_);
1730 1730
1731 scrollable_area_ = new views::ScrollView(); 1731 scrollable_area_ = new views::ScrollView();
1732 scrollable_area_->set_hide_horizontal_scrollbar(true); 1732 scrollable_area_->set_hide_horizontal_scrollbar(true);
1733 scrollable_area_->SetContents(CreateDetailsContainer()); 1733 scrollable_area_->SetContents(CreateDetailsContainer());
1734 AddChildView(scrollable_area_); 1734 AddChildView(scrollable_area_);
1735 1735
1736 autocheckout_steps_area_ = new AutocheckoutStepsArea(); 1736 autocheckout_steps_area_ = new AutocheckoutStepsArea();
1737 AddChildView(autocheckout_steps_area_); 1737 AddChildView(autocheckout_steps_area_);
1738 1738
1739 loading_shield_ = new views::Label(); 1739 loading_shield_ = new views::Label();
1740 loading_shield_->SetVisible(false); 1740 loading_shield_->SetVisible(false);
1741 loading_shield_->set_background(views::Background::CreateSolidBackground( 1741 loading_shield_->set_background(views::Background::CreateSolidBackground(
1742 GetNativeTheme()->GetSystemColor( 1742 GetNativeTheme()->GetSystemColor(
1743 ui::NativeTheme::kColorId_DialogBackground))); 1743 ui::NativeTheme::kColorId_DialogBackground)));
1744 loading_shield_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( 1744 loading_shield_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont(
1745 ui::ResourceBundle::BaseFont).DeriveFont(15)); 1745 ui::ResourceBundle::BaseFont).DeriveFont(15));
1746 AddChildView(loading_shield_); 1746 AddChildView(loading_shield_);
1747 1747
1748 sign_in_webview_ = new views::WebView(controller_->profile()); 1748 sign_in_webview_ = new views::WebView(delegate_->profile());
1749 sign_in_webview_->SetVisible(false); 1749 sign_in_webview_->SetVisible(false);
1750 AddChildView(sign_in_webview_); 1750 AddChildView(sign_in_webview_);
1751 sign_in_delegate_.reset( 1751 sign_in_delegate_.reset(
1752 new AutofillDialogSignInDelegate(this, 1752 new AutofillDialogSignInDelegate(this,
1753 sign_in_webview_->GetWebContents())); 1753 sign_in_webview_->GetWebContents()));
1754 1754
1755 overlay_view_ = new OverlayView(this); 1755 overlay_view_ = new OverlayView(this);
1756 overlay_view_->SetVisible(false); 1756 overlay_view_->SetVisible(false);
1757 } 1757 }
1758 1758
(...skipping 13 matching lines...) Expand all
1772 return details_container_; 1772 return details_container_;
1773 } 1773 }
1774 1774
1775 void AutofillDialogViews::CreateDetailsSection(DialogSection section) { 1775 void AutofillDialogViews::CreateDetailsSection(DialogSection section) {
1776 // Inputs container (manual inputs + combobox). 1776 // Inputs container (manual inputs + combobox).
1777 views::View* inputs_container = CreateInputsContainer(section); 1777 views::View* inputs_container = CreateInputsContainer(section);
1778 1778
1779 DetailsGroup* group = GroupForSection(section); 1779 DetailsGroup* group = GroupForSection(section);
1780 // Container (holds label + inputs). 1780 // Container (holds label + inputs).
1781 group->container = new SectionContainer( 1781 group->container = new SectionContainer(
1782 controller_->LabelForSection(section), 1782 delegate_->LabelForSection(section),
1783 inputs_container, 1783 inputs_container,
1784 group->suggested_button); 1784 group->suggested_button);
1785 DCHECK(group->suggested_button->parent()); 1785 DCHECK(group->suggested_button->parent());
1786 UpdateDetailsGroupState(*group); 1786 UpdateDetailsGroupState(*group);
1787 } 1787 }
1788 1788
1789 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { 1789 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
1790 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the 1790 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
1791 // dialog to toggle which is shown. 1791 // dialog to toggle which is shown.
1792 views::View* info_view = new views::View(); 1792 views::View* info_view = new views::View();
1793 info_view->SetLayoutManager( 1793 info_view->SetLayoutManager(
1794 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 1794 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
1795 1795
1796 views::View* manual_inputs = InitInputsView(section); 1796 views::View* manual_inputs = InitInputsView(section);
1797 info_view->AddChildView(manual_inputs); 1797 info_view->AddChildView(manual_inputs);
1798 SuggestionView* suggested_info = 1798 SuggestionView* suggested_info =
1799 new SuggestionView(controller_->EditSuggestionText(), this); 1799 new SuggestionView(delegate_->EditSuggestionText(), this);
1800 info_view->AddChildView(suggested_info); 1800 info_view->AddChildView(suggested_info);
1801 1801
1802 // TODO(estade): It might be slightly more OO if this button were created 1802 // TODO(estade): It might be slightly more OO if this button were created
1803 // and listened to by the section container. 1803 // and listened to by the section container.
1804 views::ImageButton* menu_button = new views::ImageButton(this); 1804 views::ImageButton* menu_button = new views::ImageButton(this);
1805 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1805 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1806 menu_button->SetImage(views::Button::STATE_NORMAL, 1806 menu_button->SetImage(views::Button::STATE_NORMAL,
1807 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); 1807 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON));
1808 menu_button->SetImage(views::Button::STATE_PRESSED, 1808 menu_button->SetImage(views::Button::STATE_PRESSED,
1809 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); 1809 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P));
(...skipping 10 matching lines...) Expand all
1820 DetailsGroup* group = GroupForSection(section); 1820 DetailsGroup* group = GroupForSection(section);
1821 group->suggested_button = menu_button; 1821 group->suggested_button = menu_button;
1822 group->manual_input = manual_inputs; 1822 group->manual_input = manual_inputs;
1823 group->suggested_info = suggested_info; 1823 group->suggested_info = suggested_info;
1824 return info_view; 1824 return info_view;
1825 } 1825 }
1826 1826
1827 // TODO(estade): we should be using Chrome-style constrained window padding 1827 // TODO(estade): we should be using Chrome-style constrained window padding
1828 // values. 1828 // values.
1829 views::View* AutofillDialogViews::InitInputsView(DialogSection section) { 1829 views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
1830 const DetailInputs& inputs = controller_->RequestedFieldsForSection(section); 1830 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section);
1831 TextfieldMap* textfields = &GroupForSection(section)->textfields; 1831 TextfieldMap* textfields = &GroupForSection(section)->textfields;
1832 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes; 1832 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes;
1833 1833
1834 views::View* view = new views::View(); 1834 views::View* view = new views::View();
1835 views::GridLayout* layout = new views::GridLayout(view); 1835 views::GridLayout* layout = new views::GridLayout(view);
1836 view->SetLayoutManager(layout); 1836 view->SetLayoutManager(layout);
1837 1837
1838 for (DetailInputs::const_iterator it = inputs.begin(); 1838 for (DetailInputs::const_iterator it = inputs.begin();
1839 it != inputs.end(); ++it) { 1839 it != inputs.end(); ++it) {
1840 const DetailInput& input = *it; 1840 const DetailInput& input = *it;
1841 ui::ComboboxModel* input_model = 1841 ui::ComboboxModel* input_model =
1842 controller_->ComboboxModelForAutofillType(input.type); 1842 delegate_->ComboboxModelForAutofillType(input.type);
1843 scoped_ptr<views::View> view_to_add; 1843 scoped_ptr<views::View> view_to_add;
1844 if (input_model) { 1844 if (input_model) {
1845 views::Combobox* combobox = new views::Combobox(input_model); 1845 views::Combobox* combobox = new views::Combobox(input_model);
1846 combobox->set_listener(this); 1846 combobox->set_listener(this);
1847 comboboxes->insert(std::make_pair(&input, combobox)); 1847 comboboxes->insert(std::make_pair(&input, combobox));
1848 1848
1849 for (int i = 0; i < input_model->GetItemCount(); ++i) { 1849 for (int i = 0; i < input_model->GetItemCount(); ++i) {
1850 if (input.initial_value == input_model->GetItemAt(i)) { 1850 if (input.initial_value == input_model->GetItemAt(i)) {
1851 combobox->SetSelectedIndex(i); 1851 combobox->SetSelectedIndex(i);
1852 break; 1852 break;
1853 } 1853 }
1854 } 1854 }
1855 1855
1856 view_to_add.reset(combobox); 1856 view_to_add.reset(combobox);
1857 } else { 1857 } else {
1858 DecoratedTextfield* field = new DecoratedTextfield( 1858 DecoratedTextfield* field = new DecoratedTextfield(
1859 input.initial_value, 1859 input.initial_value,
1860 l10n_util::GetStringUTF16(input.placeholder_text_rid), 1860 l10n_util::GetStringUTF16(input.placeholder_text_rid),
1861 this); 1861 this);
1862 1862
1863 gfx::Image icon = 1863 gfx::Image icon =
1864 controller_->IconForField(input.type, input.initial_value); 1864 delegate_->IconForField(input.type, input.initial_value);
1865 field->SetIcon(icon); 1865 field->SetIcon(icon);
1866 1866
1867 textfields->insert(std::make_pair(&input, field)); 1867 textfields->insert(std::make_pair(&input, field));
1868 view_to_add.reset(field); 1868 view_to_add.reset(field);
1869 } 1869 }
1870 1870
1871 int kColumnSetId = input.row_id; 1871 int kColumnSetId = input.row_id;
1872 if (kColumnSetId < 0) { 1872 if (kColumnSetId < 0) {
1873 other_owned_views_.push_back(view_to_add.release()); 1873 other_owned_views_.push_back(view_to_add.release());
1874 continue; 1874 continue;
(...skipping 30 matching lines...) Expand all
1905 1, 0); 1905 1, 0);
1906 } 1906 }
1907 1907
1908 return view; 1908 return view;
1909 } 1909 }
1910 1910
1911 void AutofillDialogViews::UpdateSectionImpl( 1911 void AutofillDialogViews::UpdateSectionImpl(
1912 DialogSection section, 1912 DialogSection section,
1913 bool clobber_inputs) { 1913 bool clobber_inputs) {
1914 const DetailInputs& updated_inputs = 1914 const DetailInputs& updated_inputs =
1915 controller_->RequestedFieldsForSection(section); 1915 delegate_->RequestedFieldsForSection(section);
1916 DetailsGroup* group = GroupForSection(section); 1916 DetailsGroup* group = GroupForSection(section);
1917 1917
1918 for (DetailInputs::const_iterator iter = updated_inputs.begin(); 1918 for (DetailInputs::const_iterator iter = updated_inputs.begin();
1919 iter != updated_inputs.end(); ++iter) { 1919 iter != updated_inputs.end(); ++iter) {
1920 const DetailInput& input = *iter; 1920 const DetailInput& input = *iter;
1921 TextfieldMap::iterator text_mapping = group->textfields.find(&input); 1921 TextfieldMap::iterator text_mapping = group->textfields.find(&input);
1922 1922
1923 if (text_mapping != group->textfields.end()) { 1923 if (text_mapping != group->textfields.end()) {
1924 DecoratedTextfield* decorated = text_mapping->second; 1924 DecoratedTextfield* decorated = text_mapping->second;
1925 decorated->SetEnabled(input.editable); 1925 decorated->SetEnabled(input.editable);
1926 if (decorated->text().empty() || clobber_inputs) { 1926 if (decorated->text().empty() || clobber_inputs) {
1927 decorated->SetText(iter->initial_value); 1927 decorated->SetText(iter->initial_value);
1928 decorated->SetIcon( 1928 decorated->SetIcon(
1929 controller_->IconForField(input.type, decorated->text())); 1929 delegate_->IconForField(input.type, decorated->text()));
1930 } 1930 }
1931 } 1931 }
1932 1932
1933 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); 1933 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input);
1934 if (combo_mapping != group->comboboxes.end()) { 1934 if (combo_mapping != group->comboboxes.end()) {
1935 views::Combobox* combobox = combo_mapping->second; 1935 views::Combobox* combobox = combo_mapping->second;
1936 combobox->SetEnabled(input.editable); 1936 combobox->SetEnabled(input.editable);
1937 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || 1937 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() ||
1938 clobber_inputs) { 1938 clobber_inputs) {
1939 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) { 1939 for (int i = 0; i < combobox->model()->GetItemCount(); ++i) {
1940 if (input.initial_value == combobox->model()->GetItemAt(i)) { 1940 if (input.initial_value == combobox->model()->GetItemAt(i)) {
1941 combobox->SetSelectedIndex(i); 1941 combobox->SetSelectedIndex(i);
1942 break; 1942 break;
1943 } 1943 }
1944 } 1944 }
1945 } 1945 }
1946 } 1946 }
1947 } 1947 }
1948 1948
1949 UpdateDetailsGroupState(*group); 1949 UpdateDetailsGroupState(*group);
1950 } 1950 }
1951 1951
1952 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { 1952 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
1953 const SuggestionState& suggestion_state = 1953 const SuggestionState& suggestion_state =
1954 controller_->SuggestionStateForSection(group.section); 1954 delegate_->SuggestionStateForSection(group.section);
1955 bool show_suggestions = !suggestion_state.text.empty(); 1955 bool show_suggestions = !suggestion_state.text.empty();
1956 group.suggested_info->SetVisible(show_suggestions); 1956 group.suggested_info->SetVisible(show_suggestions);
1957 group.suggested_info->SetSuggestionText(suggestion_state.text, 1957 group.suggested_info->SetSuggestionText(suggestion_state.text,
1958 suggestion_state.text_style); 1958 suggestion_state.text_style);
1959 group.suggested_info->SetSuggestionIcon(suggestion_state.icon); 1959 group.suggested_info->SetSuggestionIcon(suggestion_state.icon);
1960 1960
1961 if (!suggestion_state.extra_text.empty()) { 1961 if (!suggestion_state.extra_text.empty()) {
1962 group.suggested_info->ShowTextfield( 1962 group.suggested_info->ShowTextfield(
1963 suggestion_state.extra_text, 1963 suggestion_state.extra_text,
1964 suggestion_state.extra_icon); 1964 suggestion_state.extra_icon);
1965 } 1965 }
1966 1966
1967 group.manual_input->SetVisible(!show_suggestions); 1967 group.manual_input->SetVisible(!show_suggestions);
1968 1968
1969 UpdateButtonStripExtraView(); 1969 UpdateButtonStripExtraView();
1970 1970
1971 const bool has_menu = !!controller_->MenuModelForSection(group.section); 1971 const bool has_menu = !!delegate_->MenuModelForSection(group.section);
1972 1972
1973 if (group.suggested_button) 1973 if (group.suggested_button)
1974 group.suggested_button->SetVisible(has_menu); 1974 group.suggested_button->SetVisible(has_menu);
1975 1975
1976 if (group.container) { 1976 if (group.container) {
1977 group.container->SetForwardMouseEvents(has_menu && show_suggestions); 1977 group.container->SetForwardMouseEvents(has_menu && show_suggestions);
1978 group.container->SetVisible(controller_->SectionIsActive(group.section)); 1978 group.container->SetVisible(delegate_->SectionIsActive(group.section));
1979 if (group.container->visible()) 1979 if (group.container->visible())
1980 ValidateGroup(group, VALIDATE_EDIT); 1980 ValidateGroup(group, VALIDATE_EDIT);
1981 } 1981 }
1982 1982
1983 ContentsPreferredSizeChanged(); 1983 ContentsPreferredSizeChanged();
1984 } 1984 }
1985 1985
1986 template<class T> 1986 template<class T>
1987 void AutofillDialogViews::SetValidityForInput( 1987 void AutofillDialogViews::SetValidityForInput(
1988 T* input, 1988 T* input,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 detail_outputs[iter->first] = item; 2102 detail_outputs[iter->first] = item;
2103 } 2103 }
2104 } else if (group.section == SECTION_CC) { 2104 } else if (group.section == SECTION_CC) {
2105 DecoratedTextfield* decorated_cvc = 2105 DecoratedTextfield* decorated_cvc =
2106 group.suggested_info->decorated_textfield(); 2106 group.suggested_info->decorated_textfield();
2107 cvc_input.reset(new DetailInput); 2107 cvc_input.reset(new DetailInput);
2108 cvc_input->type = CREDIT_CARD_VERIFICATION_CODE; 2108 cvc_input->type = CREDIT_CARD_VERIFICATION_CODE;
2109 detail_outputs[cvc_input.get()] = decorated_cvc->text(); 2109 detail_outputs[cvc_input.get()] = decorated_cvc->text();
2110 } 2110 }
2111 2111
2112 ValidityData invalid_inputs = controller_->InputsAreValid( 2112 ValidityData invalid_inputs = delegate_->InputsAreValid(
2113 group.section, detail_outputs, validation_type); 2113 group.section, detail_outputs, validation_type);
2114 MarkInputsInvalid(group.section, invalid_inputs); 2114 MarkInputsInvalid(group.section, invalid_inputs);
2115 2115
2116 return invalid_inputs.empty(); 2116 return invalid_inputs.empty();
2117 } 2117 }
2118 2118
2119 bool AutofillDialogViews::ValidateForm() { 2119 bool AutofillDialogViews::ValidateForm() {
2120 bool all_valid = true; 2120 bool all_valid = true;
2121 validity_map_.clear(); 2121 validity_map_.clear();
2122 2122
(...skipping 19 matching lines...) Expand all
2142 // Figure out the AutofillFieldType this textfield represents. 2142 // Figure out the AutofillFieldType this textfield represents.
2143 AutofillFieldType type = UNKNOWN_TYPE; 2143 AutofillFieldType type = UNKNOWN_TYPE;
2144 DecoratedTextfield* decorated = NULL; 2144 DecoratedTextfield* decorated = NULL;
2145 2145
2146 // Look for the input in the manual inputs. 2146 // Look for the input in the manual inputs.
2147 for (TextfieldMap::const_iterator iter = group->textfields.begin(); 2147 for (TextfieldMap::const_iterator iter = group->textfields.begin();
2148 iter != group->textfields.end(); 2148 iter != group->textfields.end();
2149 ++iter) { 2149 ++iter) {
2150 decorated = iter->second; 2150 decorated = iter->second;
2151 if (decorated == textfield) { 2151 if (decorated == textfield) {
2152 controller_->UserEditedOrActivatedInput(group->section, 2152 delegate_->UserEditedOrActivatedInput(group->section,
2153 iter->first, 2153 iter->first,
2154 GetWidget()->GetNativeView(), 2154 GetWidget()->GetNativeView(),
2155 textfield->GetBoundsInScreen(), 2155 textfield->GetBoundsInScreen(),
2156 textfield->text(), 2156 textfield->text(),
2157 was_edit); 2157 was_edit);
2158 type = iter->first->type; 2158 type = iter->first->type;
2159 break; 2159 break;
2160 } 2160 }
2161 } 2161 }
2162 2162
2163 if (textfield == group->suggested_info->decorated_textfield()) { 2163 if (textfield == group->suggested_info->decorated_textfield()) {
2164 decorated = group->suggested_info->decorated_textfield(); 2164 decorated = group->suggested_info->decorated_textfield();
2165 type = CREDIT_CARD_VERIFICATION_CODE; 2165 type = CREDIT_CARD_VERIFICATION_CODE;
2166 } 2166 }
2167 DCHECK_NE(UNKNOWN_TYPE, type); 2167 DCHECK_NE(UNKNOWN_TYPE, type);
2168 2168
2169 // If the field is marked as invalid, check if the text is now valid. 2169 // If the field is marked as invalid, check if the text is now valid.
2170 // Many fields (i.e. CC#) are invalid for most of the duration of editing, 2170 // Many fields (i.e. CC#) are invalid for most of the duration of editing,
2171 // so flagging them as invalid prematurely is not helpful. However, 2171 // so flagging them as invalid prematurely is not helpful. However,
2172 // correcting a minor mistake (i.e. a wrong CC digit) should immediately 2172 // correcting a minor mistake (i.e. a wrong CC digit) should immediately
2173 // result in validation - positive user feedback. 2173 // result in validation - positive user feedback.
2174 if (decorated->invalid() && was_edit) { 2174 if (decorated->invalid() && was_edit) {
2175 SetValidityForInput<DecoratedTextfield>( 2175 SetValidityForInput<DecoratedTextfield>(
2176 decorated, 2176 decorated,
2177 controller_->InputValidityMessage(group->section, type, 2177 delegate_->InputValidityMessage(group->section, type,
2178 textfield->text())); 2178 textfield->text()));
2179 2179
2180 // If the field transitioned from invalid to valid, re-validate the group, 2180 // If the field transitioned from invalid to valid, re-validate the group,
2181 // since inter-field checks become meaningful with valid fields. 2181 // since inter-field checks become meaningful with valid fields.
2182 if (!decorated->invalid()) 2182 if (!decorated->invalid())
2183 ValidateGroup(*group, VALIDATE_EDIT); 2183 ValidateGroup(*group, VALIDATE_EDIT);
2184 } 2184 }
2185 2185
2186 gfx::Image icon = controller_->IconForField(type, textfield->text()); 2186 gfx::Image icon = delegate_->IconForField(type, textfield->text());
2187 decorated->SetIcon(icon); 2187 decorated->SetIcon(icon);
2188 } 2188 }
2189 2189
2190 void AutofillDialogViews::UpdateButtonStripExtraView() { 2190 void AutofillDialogViews::UpdateButtonStripExtraView() {
2191 save_in_chrome_checkbox_->SetVisible( 2191 save_in_chrome_checkbox_->SetVisible(
2192 controller_->ShouldOfferToSaveInChrome()); 2192 delegate_->ShouldOfferToSaveInChrome());
2193 2193
2194 gfx::Image image = controller_->ButtonStripImage(); 2194 gfx::Image image = delegate_->ButtonStripImage();
2195 button_strip_image_->SetVisible(!image.IsEmpty()); 2195 button_strip_image_->SetVisible(!image.IsEmpty());
2196 button_strip_image_->SetImage(image.AsImageSkia()); 2196 button_strip_image_->SetImage(image.AsImageSkia());
2197 2197
2198 autocheckout_progress_bar_view_->SetVisible( 2198 autocheckout_progress_bar_view_->SetVisible(
2199 controller_->ShouldShowProgressBar()); 2199 delegate_->ShouldShowProgressBar());
2200 } 2200 }
2201 2201
2202 void AutofillDialogViews::ContentsPreferredSizeChanged() { 2202 void AutofillDialogViews::ContentsPreferredSizeChanged() {
2203 if (GetWidget()) { 2203 if (GetWidget()) {
2204 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); 2204 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
2205 // If the above line does not cause the dialog's size to change, |contents_| 2205 // If the above line does not cause the dialog's size to change, |contents_|
2206 // may not be laid out. This will trigger a layout only if it's needed. 2206 // may not be laid out. This will trigger a layout only if it's needed.
2207 SetBoundsRect(bounds()); 2207 SetBoundsRect(bounds());
2208 } 2208 }
2209 } 2209 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2271 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2272 : section(section), 2272 : section(section),
2273 container(NULL), 2273 container(NULL),
2274 manual_input(NULL), 2274 manual_input(NULL),
2275 suggested_info(NULL), 2275 suggested_info(NULL),
2276 suggested_button(NULL) {} 2276 suggested_button(NULL) {}
2277 2277
2278 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2278 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2279 2279
2280 } // namespace autofill 2280 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698