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