| OLD | NEW |
| 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/ui/autofill/autofill_dialog_controller.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 11 #include "chrome/browser/ui/views/constrained_window_views.h" | 11 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 12 #include "grit/theme_resources.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
| 14 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/button/checkbox.h" | 16 #include "ui/views/controls/button/checkbox.h" |
| 15 #include "ui/views/controls/button/menu_button.h" | 17 #include "ui/views/controls/button/image_button.h" |
| 16 #include "ui/views/controls/combobox/combobox.h" | 18 #include "ui/views/controls/combobox/combobox.h" |
| 17 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 18 #include "ui/views/controls/menu/menu_model_adapter.h" | 20 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 19 #include "ui/views/controls/menu/menu_runner.h" | 21 #include "ui/views/controls/menu/menu_runner.h" |
| 20 #include "ui/views/controls/separator.h" | 22 #include "ui/views/controls/separator.h" |
| 21 #include "ui/views/controls/textfield/textfield.h" | 23 #include "ui/views/controls/textfield/textfield.h" |
| 22 #include "ui/views/layout/box_layout.h" | 24 #include "ui/views/layout/box_layout.h" |
| 23 #include "ui/views/layout/grid_layout.h" | 25 #include "ui/views/layout/grid_layout.h" |
| 24 #include "ui/views/layout/layout_constants.h" | 26 #include "ui/views/layout/layout_constants.h" |
| 25 | 27 |
| 26 namespace autofill { | 28 namespace autofill { |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 // Returns a label that describes a details section. | 32 // Returns a label that describes a details section. |
| 31 views::Label* CreateDetailsSectionLabel(const string16& text) { | 33 views::Label* CreateDetailsSectionLabel(const string16& text) { |
| 32 views::Label* label = new views::Label(text); | 34 views::Label* label = new views::Label(text); |
| 33 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 35 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
| 34 label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD)); | 36 label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD)); |
| 35 // TODO(estade): this should be made to match the native textfield top | 37 // TODO(estade): this should be made to match the native textfield top |
| 36 // inset. It's hard to get at, so for now it's hard-coded. | 38 // inset. It's hard to get at, so for now it's hard-coded. |
| 37 label->set_border(views::Border::CreateEmptyBorder(4, 0, 0, 0)); | 39 label->set_border(views::Border::CreateEmptyBorder(4, 0, 0, 0)); |
| 38 return label; | 40 return label; |
| 39 } | 41 } |
| 40 | 42 |
| 41 // Creates a view that packs a label on the left and some related controls | 43 } // namespace |
| 42 // on the right. | 44 |
| 43 views::View* CreateSectionContainer(const string16& label, | 45 // AutofillDialogViews::SectionContainer --------------------------------------- |
| 44 views::View* controls) { | 46 |
| 45 views::View* container = new views::View(); | 47 AutofillDialogViews::SectionContainer::SectionContainer( |
| 46 views::GridLayout* layout = new views::GridLayout(container); | 48 const string16& label, |
| 47 container->SetLayoutManager(layout); | 49 views::View* controls, |
| 50 views::Button* proxy_button) |
| 51 : proxy_button_(proxy_button), |
| 52 forward_mouse_events_(false) { |
| 53 set_notify_enter_exit_on_child(true); |
| 54 |
| 55 views::GridLayout* layout = new views::GridLayout(this); |
| 56 SetLayoutManager(layout); |
| 48 | 57 |
| 49 const int kColumnSetId = 0; | 58 const int kColumnSetId = 0; |
| 50 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); | 59 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); |
| 51 // TODO(estade): pull out these constants, and figure out better values | 60 // TODO(estade): pull out these constants, and figure out better values |
| 52 // for them. | 61 // for them. |
| 53 column_set->AddColumn(views::GridLayout::FILL, | 62 column_set->AddColumn(views::GridLayout::FILL, |
| 54 views::GridLayout::LEADING, | 63 views::GridLayout::LEADING, |
| 55 0, | 64 0, |
| 56 views::GridLayout::FIXED, | 65 views::GridLayout::FIXED, |
| 57 180, | 66 180, |
| 58 0); | 67 0); |
| 59 column_set->AddPaddingColumn(0, 15); | 68 column_set->AddPaddingColumn(0, 15); |
| 60 column_set->AddColumn(views::GridLayout::FILL, | 69 column_set->AddColumn(views::GridLayout::FILL, |
| 61 views::GridLayout::LEADING, | 70 views::GridLayout::LEADING, |
| 62 0, | 71 0, |
| 63 views::GridLayout::FIXED, | 72 views::GridLayout::FIXED, |
| 64 300, | 73 300, |
| 65 0); | 74 0); |
| 66 | 75 |
| 67 layout->StartRow(0, kColumnSetId); | 76 layout->StartRow(0, kColumnSetId); |
| 68 layout->AddView(CreateDetailsSectionLabel(label)); | 77 layout->AddView(CreateDetailsSectionLabel(label)); |
| 69 layout->AddView(controls); | 78 layout->AddView(controls); |
| 70 return container; | |
| 71 } | 79 } |
| 72 | 80 |
| 73 } // namespace | 81 AutofillDialogViews::SectionContainer::~SectionContainer() {} |
| 82 |
| 83 void AutofillDialogViews::SectionContainer::SetForwardMouseEvents( |
| 84 bool forward) { |
| 85 forward_mouse_events_ = forward; |
| 86 if (!forward) |
| 87 set_background(NULL); |
| 88 } |
| 89 |
| 90 void AutofillDialogViews::SectionContainer::OnMouseEntered( |
| 91 const ui::MouseEvent& event) { |
| 92 if (!forward_mouse_events_) |
| 93 return; |
| 94 |
| 95 // TODO(estade): use the correct color. |
| 96 set_background(views::Background::CreateSolidBackground(SK_ColorLTGRAY)); |
| 97 proxy_button_->OnMouseEntered(ProxyEvent(event)); |
| 98 SchedulePaint(); |
| 99 } |
| 100 |
| 101 void AutofillDialogViews::SectionContainer::OnMouseExited( |
| 102 const ui::MouseEvent& event) { |
| 103 if (!forward_mouse_events_) |
| 104 return; |
| 105 |
| 106 set_background(NULL); |
| 107 proxy_button_->OnMouseExited(ProxyEvent(event)); |
| 108 SchedulePaint(); |
| 109 } |
| 110 |
| 111 bool AutofillDialogViews::SectionContainer::OnMousePressed( |
| 112 const ui::MouseEvent& event) { |
| 113 if (!forward_mouse_events_) |
| 114 return false; |
| 115 |
| 116 return proxy_button_->OnMousePressed(ProxyEvent(event)); |
| 117 } |
| 118 |
| 119 void AutofillDialogViews::SectionContainer::OnMouseReleased( |
| 120 const ui::MouseEvent& event) { |
| 121 if (!forward_mouse_events_) |
| 122 return; |
| 123 |
| 124 proxy_button_->OnMouseReleased(ProxyEvent(event)); |
| 125 } |
| 126 |
| 127 // static |
| 128 ui::MouseEvent AutofillDialogViews::SectionContainer::ProxyEvent( |
| 129 const ui::MouseEvent& event) { |
| 130 ui::MouseEvent event_copy = event; |
| 131 event_copy.set_location(gfx::Point()); |
| 132 return event_copy; |
| 133 } |
| 134 |
| 135 // AutofillDialogView ---------------------------------------------------------- |
| 74 | 136 |
| 75 // static | 137 // static |
| 76 AutofillDialogView* AutofillDialogView::Create( | 138 AutofillDialogView* AutofillDialogView::Create( |
| 77 AutofillDialogController* controller) { | 139 AutofillDialogController* controller) { |
| 78 return new AutofillDialogViews(controller); | 140 return new AutofillDialogViews(controller); |
| 79 } | 141 } |
| 80 | 142 |
| 143 // AutofillDialogViews --------------------------------------------------------- |
| 144 |
| 81 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) | 145 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) |
| 82 : controller_(controller), | 146 : controller_(controller), |
| 83 did_submit_(false), | 147 did_submit_(false), |
| 84 window_(NULL), | 148 window_(NULL), |
| 85 contents_(NULL), | 149 contents_(NULL), |
| 86 email_(SECTION_EMAIL), | 150 email_(SECTION_EMAIL), |
| 87 cc_(SECTION_CC), | 151 cc_(SECTION_CC), |
| 88 billing_(SECTION_BILLING), | 152 billing_(SECTION_BILLING), |
| 89 shipping_(SECTION_SHIPPING) { | 153 shipping_(SECTION_SHIPPING) { |
| 90 DCHECK(controller); | 154 DCHECK(controller); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return true; | 239 return true; |
| 176 } | 240 } |
| 177 | 241 |
| 178 bool AutofillDialogViews::Accept() { | 242 bool AutofillDialogViews::Accept() { |
| 179 did_submit_ = true; | 243 did_submit_ = true; |
| 180 return true; | 244 return true; |
| 181 } | 245 } |
| 182 | 246 |
| 183 void AutofillDialogViews::ButtonPressed(views::Button* sender, | 247 void AutofillDialogViews::ButtonPressed(views::Button* sender, |
| 184 const ui::Event& event) { | 248 const ui::Event& event) { |
| 185 DCHECK_EQ(sender, use_billing_for_shipping_); | 249 if (sender == use_billing_for_shipping_) { |
| 186 shipping_.container->SetVisible(!use_billing_for_shipping_->checked()); | 250 shipping_.container->SetVisible(!use_billing_for_shipping_->checked()); |
| 187 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); | 251 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); |
| 188 } | 252 } else { |
| 253 // TODO(estade): Should the menu be shown on mouse down? |
| 254 DetailsGroup* group = |
| 255 sender == email_.suggested_button ? &email_ : |
| 256 sender == cc_.suggested_button ? &cc_ : |
| 257 sender == billing_.suggested_button ? &billing_ : |
| 258 sender == shipping_.suggested_button ? &shipping_ : NULL; |
| 259 DCHECK(group); |
| 189 | 260 |
| 190 void AutofillDialogViews::OnMenuButtonClicked(views::View* source, | 261 views::MenuModelAdapter adapter( |
| 191 const gfx::Point& point) { | 262 controller_->MenuModelForSection(group->section)); |
| 192 DetailsGroup* group = | 263 menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu())); |
| 193 source == email_.suggested_button ? &email_ : | |
| 194 source == cc_.suggested_button ? &cc_ : | |
| 195 source == billing_.suggested_button ? &billing_ : | |
| 196 source == shipping_.suggested_button ? &shipping_ : NULL; | |
| 197 DCHECK(group); | |
| 198 views::MenuModelAdapter adapter( | |
| 199 controller_->MenuModelForSection(group->section)); | |
| 200 menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu())); | |
| 201 | 264 |
| 202 // Ignore the result since we don't need to handle a deleted menu specially. | 265 // Ignore the result since we don't need to handle a deleted menu specially. |
| 203 ignore_result( | 266 ignore_result( |
| 204 menu_runner_->RunMenuAt(source->GetWidget(), | 267 menu_runner_->RunMenuAt(sender->GetWidget(), |
| 205 group->suggested_button, | 268 NULL, |
| 206 gfx::Rect(point, gfx::Size()), | 269 group->suggested_button->GetBoundsInScreen(), |
| 207 views::MenuItemView::TOPRIGHT, | 270 views::MenuItemView::TOPRIGHT, |
| 208 0)); | 271 0)); |
| 272 } |
| 209 } | 273 } |
| 210 | 274 |
| 211 void AutofillDialogViews::ContentsChanged(views::Textfield* sender, | 275 void AutofillDialogViews::ContentsChanged(views::Textfield* sender, |
| 212 const string16& new_contents) { | 276 const string16& new_contents) { |
| 213 // TODO(estade): work for not billing. | 277 // TODO(estade): work for not billing. |
| 214 for (TextfieldMap::iterator iter = billing_.textfields.begin(); | 278 for (TextfieldMap::iterator iter = billing_.textfields.begin(); |
| 215 iter != billing_.textfields.end(); | 279 iter != billing_.textfields.end(); |
| 216 ++iter) { | 280 ++iter) { |
| 217 if (iter->second == sender) { | 281 if (iter->second == sender) { |
| 218 controller_->UserEditedInput(iter->first, | 282 controller_->UserEditedInput(iter->first, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 334 |
| 271 layout->AddView(label); | 335 layout->AddView(label); |
| 272 } | 336 } |
| 273 | 337 |
| 274 layout->StartRow(0, single_column_set); | 338 layout->StartRow(0, single_column_set); |
| 275 layout->AddView(CreateIntroContainer()); | 339 layout->AddView(CreateIntroContainer()); |
| 276 | 340 |
| 277 layout->StartRowWithPadding(0, single_column_set, | 341 layout->StartRowWithPadding(0, single_column_set, |
| 278 0, views::kUnrelatedControlVerticalSpacing); | 342 0, views::kUnrelatedControlVerticalSpacing); |
| 279 layout->AddView(CreateDetailsContainer()); | 343 layout->AddView(CreateDetailsContainer()); |
| 280 | |
| 281 // Separator. | |
| 282 layout->StartRowWithPadding(0, single_column_set, | |
| 283 0, views::kUnrelatedControlVerticalSpacing); | |
| 284 layout->AddView(new views::Separator()); | |
| 285 | |
| 286 // Wallet checkbox. | |
| 287 layout->StartRowWithPadding(0, single_column_set, | |
| 288 0, views::kRelatedControlVerticalSpacing); | |
| 289 layout->AddView(new views::Checkbox(controller_->WalletOptionText())); | |
| 290 } | 344 } |
| 291 | 345 |
| 292 views::View* AutofillDialogViews::CreateIntroContainer() { | 346 views::View* AutofillDialogViews::CreateIntroContainer() { |
| 293 views::View* view = new views::View(); | 347 views::View* view = new views::View(); |
| 294 view->SetLayoutManager( | 348 view->SetLayoutManager( |
| 295 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 349 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 296 | 350 |
| 297 std::pair<string16, string16> intro_text_parts = | 351 std::pair<string16, string16> intro_text_parts = |
| 298 controller_->GetIntroTextParts(); | 352 controller_->GetIntroTextParts(); |
| 299 | 353 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 328 | 382 |
| 329 return view; | 383 return view; |
| 330 } | 384 } |
| 331 | 385 |
| 332 void AutofillDialogViews::CreateDetailsSection(DialogSection section) { | 386 void AutofillDialogViews::CreateDetailsSection(DialogSection section) { |
| 333 DCHECK_NE(SECTION_CC, section); | 387 DCHECK_NE(SECTION_CC, section); |
| 334 DCHECK_NE(SECTION_BILLING, section); | 388 DCHECK_NE(SECTION_BILLING, section); |
| 335 | 389 |
| 336 // Inputs container (manual inputs + combobox). | 390 // Inputs container (manual inputs + combobox). |
| 337 views::View* inputs_container = CreateInputsContainer(section); | 391 views::View* inputs_container = CreateInputsContainer(section); |
| 338 // Container (holds label + inputs). | |
| 339 views::View* container = CreateSectionContainer( | |
| 340 controller_->LabelForSection(section), inputs_container); | |
| 341 | 392 |
| 342 DetailsGroup* group = GroupForSection(section); | 393 DetailsGroup* group = GroupForSection(section); |
| 343 group->container = container; | 394 // Container (holds label + inputs). |
| 395 group->container = new SectionContainer( |
| 396 controller_->LabelForSection(section), |
| 397 inputs_container, |
| 398 group->suggested_button); |
| 399 UpdateDetailsGroupState(*group); |
| 344 } | 400 } |
| 345 | 401 |
| 346 void AutofillDialogViews::CreateBillingSection() { | 402 void AutofillDialogViews::CreateBillingSection() { |
| 347 views::View* billing = new views::View(); | 403 views::View* billing = new views::View(); |
| 348 billing->SetLayoutManager(new views::BoxLayout( | 404 billing->SetLayoutManager(new views::BoxLayout( |
| 349 views::BoxLayout::kVertical, 0, 0, | 405 views::BoxLayout::kVertical, 0, 0, |
| 350 views::kRelatedControlVerticalSpacing)); | 406 views::kRelatedControlVerticalSpacing)); |
| 351 | 407 |
| 352 static const DialogSection sections[] = { SECTION_CC, SECTION_BILLING }; | 408 static const DialogSection sections[] = { SECTION_CC, SECTION_BILLING }; |
| 353 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(sections); ++i) { | 409 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(sections); ++i) { |
| 354 // Inputs container (manual inputs + combobox). | 410 // Inputs container (manual inputs + combobox). |
| 355 views::View* inputs_container = CreateInputsContainer(sections[i]); | 411 views::View* inputs_container = CreateInputsContainer(sections[i]); |
| 356 billing->AddChildView(inputs_container); | 412 billing->AddChildView(inputs_container); |
| 357 } | 413 } |
| 358 | 414 |
| 359 use_billing_for_shipping_ = | 415 use_billing_for_shipping_ = |
| 360 new views::Checkbox(controller_->UseBillingForShippingText()); | 416 new views::Checkbox(controller_->UseBillingForShippingText()); |
| 361 use_billing_for_shipping_->SetChecked(true); | 417 use_billing_for_shipping_->SetChecked(true); |
| 362 use_billing_for_shipping_->set_listener(this); | 418 use_billing_for_shipping_->set_listener(this); |
| 363 billing->AddChildView(use_billing_for_shipping_); | 419 billing->AddChildView(use_billing_for_shipping_); |
| 364 | 420 |
| 365 // Container (holds label + inputs). | 421 // Container (holds label + inputs). |
| 366 views::View* container = CreateSectionContainer( | 422 billing_.container = new SectionContainer( |
| 367 controller_->LabelForSection(SECTION_BILLING), billing); | 423 controller_->LabelForSection(SECTION_BILLING), |
| 368 billing_.container = container; | 424 billing, |
| 425 billing_.suggested_button); |
| 426 UpdateDetailsGroupState(billing_); |
| 427 UpdateDetailsGroupState(cc_); |
| 369 } | 428 } |
| 370 | 429 |
| 371 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { | 430 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { |
| 372 views::View* inputs_container = new views::View(); | 431 views::View* inputs_container = new views::View(); |
| 373 views::GridLayout* layout = new views::GridLayout(inputs_container); | 432 views::GridLayout* layout = new views::GridLayout(inputs_container); |
| 374 inputs_container->SetLayoutManager(layout); | 433 inputs_container->SetLayoutManager(layout); |
| 375 | 434 |
| 376 int kColumnSetId = 0; | 435 int kColumnSetId = 0; |
| 377 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); | 436 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); |
| 378 column_set->AddColumn(views::GridLayout::FILL, | 437 column_set->AddColumn(views::GridLayout::FILL, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 395 info_view->SetLayoutManager( | 454 info_view->SetLayoutManager( |
| 396 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 455 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 397 views::View* manual_inputs = InitInputsView(section); | 456 views::View* manual_inputs = InitInputsView(section); |
| 398 info_view->AddChildView(manual_inputs); | 457 info_view->AddChildView(manual_inputs); |
| 399 views::Label* suggested_info = new views::Label(); | 458 views::Label* suggested_info = new views::Label(); |
| 400 suggested_info->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 459 suggested_info->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 401 info_view->AddChildView(suggested_info); | 460 info_view->AddChildView(suggested_info); |
| 402 layout->AddView(info_view); | 461 layout->AddView(info_view); |
| 403 | 462 |
| 404 // TODO(estade): Fix the appearance of this button. | 463 // TODO(estade): Fix the appearance of this button. |
| 405 views::MenuButton* menu_button = | 464 views::ImageButton* menu_button = new views::ImageButton(this); |
| 406 new views::MenuButton(NULL, string16(), this, true); | 465 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 466 menu_button->SetImage(views::CustomButton::STATE_NORMAL, |
| 467 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); |
| 468 menu_button->SetImage(views::CustomButton::STATE_PRESSED, |
| 469 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); |
| 407 layout->AddView(menu_button); | 470 layout->AddView(menu_button); |
| 408 | 471 |
| 409 DetailsGroup* group = GroupForSection(section); | 472 DetailsGroup* group = GroupForSection(section); |
| 410 group->suggested_button = menu_button; | 473 group->suggested_button = menu_button; |
| 411 group->manual_input = manual_inputs; | 474 group->manual_input = manual_inputs; |
| 412 group->suggested_info = suggested_info; | 475 group->suggested_info = suggested_info; |
| 413 UpdateDetailsGroupState(*group); | |
| 414 return inputs_container; | 476 return inputs_container; |
| 415 } | 477 } |
| 416 | 478 |
| 417 // TODO(estade): we should be using Chrome-style constrained window padding | 479 // TODO(estade): we should be using Chrome-style constrained window padding |
| 418 // values. | 480 // values. |
| 419 views::View* AutofillDialogViews::InitInputsView(DialogSection section) { | 481 views::View* AutofillDialogViews::InitInputsView(DialogSection section) { |
| 420 const DetailInputs& inputs = controller_->RequestedFieldsForSection(section); | 482 const DetailInputs& inputs = controller_->RequestedFieldsForSection(section); |
| 421 TextfieldMap* textfields = &GroupForSection(section)->textfields; | 483 TextfieldMap* textfields = &GroupForSection(section)->textfields; |
| 422 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes; | 484 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes; |
| 423 | 485 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 layout->AddView(field); | 537 layout->AddView(field); |
| 476 } | 538 } |
| 477 } | 539 } |
| 478 | 540 |
| 479 return view; | 541 return view; |
| 480 } | 542 } |
| 481 | 543 |
| 482 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { | 544 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { |
| 483 string16 suggestion_text = | 545 string16 suggestion_text = |
| 484 controller_->SuggestionTextForSection(group.section); | 546 controller_->SuggestionTextForSection(group.section); |
| 485 group.manual_input->SetVisible(suggestion_text.empty()); | 547 bool show_suggestions = !suggestion_text.empty(); |
| 486 group.suggested_info->SetVisible(!suggestion_text.empty()); | 548 group.manual_input->SetVisible(!show_suggestions); |
| 549 group.suggested_info->SetVisible(show_suggestions); |
| 487 group.suggested_info->SetText(suggestion_text); | 550 group.suggested_info->SetText(suggestion_text); |
| 551 |
| 552 if (group.container) |
| 553 group.container->SetForwardMouseEvents(show_suggestions); |
| 554 |
| 488 if (GetWidget()) | 555 if (GetWidget()) |
| 489 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); | 556 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); |
| 490 } | 557 } |
| 491 | 558 |
| 492 AutofillDialogViews::DetailsGroup* AutofillDialogViews:: | 559 AutofillDialogViews::DetailsGroup* AutofillDialogViews:: |
| 493 GroupForSection(DialogSection section) { | 560 GroupForSection(DialogSection section) { |
| 494 switch (section) { | 561 switch (section) { |
| 495 case SECTION_EMAIL: | 562 case SECTION_EMAIL: |
| 496 return &email_; | 563 return &email_; |
| 497 case SECTION_CC: | 564 case SECTION_CC: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 509 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 576 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 510 : section(section), | 577 : section(section), |
| 511 container(NULL), | 578 container(NULL), |
| 512 manual_input(NULL), | 579 manual_input(NULL), |
| 513 suggested_info(NULL), | 580 suggested_info(NULL), |
| 514 suggested_button(NULL) {} | 581 suggested_button(NULL) {} |
| 515 | 582 |
| 516 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 583 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 517 | 584 |
| 518 } // namespace autofill | 585 } // namespace autofill |
| OLD | NEW |