| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 // A View for a single notification banner. | 222 // A View for a single notification banner. |
| 223 class NotificationView : public views::View, | 223 class NotificationView : public views::View, |
| 224 public views::StyledLabelListener { | 224 public views::StyledLabelListener { |
| 225 public: | 225 public: |
| 226 NotificationView(const DialogNotification& data, | 226 NotificationView(const DialogNotification& data, |
| 227 AutofillDialogViewDelegate* delegate) | 227 AutofillDialogViewDelegate* delegate) |
| 228 : data_(data), | 228 : data_(data), |
| 229 delegate_(delegate), | 229 delegate_(delegate), |
| 230 checkbox_(NULL) { | 230 checkbox_(NULL) { |
| 231 scoped_ptr<views::View> label_view; | 231 std::unique_ptr<views::View> label_view; |
| 232 scoped_ptr<views::StyledLabel> label( | 232 std::unique_ptr<views::StyledLabel> label( |
| 233 new views::StyledLabel(data.display_text(), this)); | 233 new views::StyledLabel(data.display_text(), this)); |
| 234 label->set_auto_color_readability_enabled(false); | 234 label->set_auto_color_readability_enabled(false); |
| 235 | 235 |
| 236 views::StyledLabel::RangeStyleInfo text_style; | 236 views::StyledLabel::RangeStyleInfo text_style; |
| 237 text_style.color = data.GetTextColor(); | 237 text_style.color = data.GetTextColor(); |
| 238 | 238 |
| 239 if (data.link_range().is_empty()) { | 239 if (data.link_range().is_empty()) { |
| 240 label->AddStyleRange(gfx::Range(0, data.display_text().size()), | 240 label->AddStyleRange(gfx::Range(0, data.display_text().size()), |
| 241 text_style); | 241 text_style); |
| 242 } else { | 242 } else { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 const std::vector<DialogNotification>& notifications) { | 382 const std::vector<DialogNotification>& notifications) { |
| 383 notifications_ = notifications; | 383 notifications_ = notifications; |
| 384 | 384 |
| 385 RemoveAllChildViews(true); | 385 RemoveAllChildViews(true); |
| 386 | 386 |
| 387 if (notifications_.empty()) | 387 if (notifications_.empty()) |
| 388 return; | 388 return; |
| 389 | 389 |
| 390 for (size_t i = 0; i < notifications_.size(); ++i) { | 390 for (size_t i = 0; i < notifications_.size(); ++i) { |
| 391 const DialogNotification& notification = notifications_[i]; | 391 const DialogNotification& notification = notifications_[i]; |
| 392 scoped_ptr<NotificationView> view(new NotificationView(notification, | 392 std::unique_ptr<NotificationView> view( |
| 393 delegate_)); | 393 new NotificationView(notification, delegate_)); |
| 394 | 394 |
| 395 AddChildView(view.release()); | 395 AddChildView(view.release()); |
| 396 } | 396 } |
| 397 | 397 |
| 398 PreferredSizeChanged(); | 398 PreferredSizeChanged(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 gfx::Size AutofillDialogViews::NotificationArea::GetPreferredSize() const { | 401 gfx::Size AutofillDialogViews::NotificationArea::GetPreferredSize() const { |
| 402 gfx::Size size = views::View::GetPreferredSize(); | 402 gfx::Size size = views::View::GetPreferredSize(); |
| 403 // Ensure that long notifications wrap and don't enlarge the dialog. | 403 // Ensure that long notifications wrap and don't enlarge the dialog. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 0); | 485 0); |
| 486 label_bar_layout->StartRow(0, kColumnSetId); | 486 label_bar_layout->StartRow(0, kColumnSetId); |
| 487 label_bar_layout->AddView(label_view); | 487 label_bar_layout->AddView(label_view); |
| 488 label_bar_layout->AddView(proxy_button); | 488 label_bar_layout->AddView(proxy_button); |
| 489 | 489 |
| 490 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 490 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 491 AddChildView(label_bar); | 491 AddChildView(label_bar); |
| 492 AddChildView(controls); | 492 AddChildView(controls); |
| 493 | 493 |
| 494 SetEventTargeter( | 494 SetEventTargeter( |
| 495 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 495 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
| 496 } | 496 } |
| 497 | 497 |
| 498 AutofillDialogViews::SectionContainer::~SectionContainer() {} | 498 AutofillDialogViews::SectionContainer::~SectionContainer() {} |
| 499 | 499 |
| 500 void AutofillDialogViews::SectionContainer::SetActive(bool active) { | 500 void AutofillDialogViews::SectionContainer::SetActive(bool active) { |
| 501 bool is_active = active && proxy_button_->visible(); | 501 bool is_active = active && proxy_button_->visible(); |
| 502 if (is_active == !!background()) | 502 if (is_active == !!background()) |
| 503 return; | 503 return; |
| 504 | 504 |
| 505 set_background( | 505 set_background( |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 view->SetLayoutManager(layout); | 1370 view->SetLayoutManager(layout); |
| 1371 | 1371 |
| 1372 int column_set_id = 0; | 1372 int column_set_id = 0; |
| 1373 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section); | 1373 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section); |
| 1374 for (DetailInputs::const_iterator it = inputs.begin(); | 1374 for (DetailInputs::const_iterator it = inputs.begin(); |
| 1375 it != inputs.end(); ++it) { | 1375 it != inputs.end(); ++it) { |
| 1376 const DetailInput& input = *it; | 1376 const DetailInput& input = *it; |
| 1377 | 1377 |
| 1378 ui::ComboboxModel* input_model = | 1378 ui::ComboboxModel* input_model = |
| 1379 delegate_->ComboboxModelForAutofillType(input.type); | 1379 delegate_->ComboboxModelForAutofillType(input.type); |
| 1380 scoped_ptr<views::View> view_to_add; | 1380 std::unique_ptr<views::View> view_to_add; |
| 1381 if (input_model) { | 1381 if (input_model) { |
| 1382 views::Combobox* combobox = new views::Combobox(input_model); | 1382 views::Combobox* combobox = new views::Combobox(input_model); |
| 1383 combobox->set_listener(this); | 1383 combobox->set_listener(this); |
| 1384 comboboxes->insert(std::make_pair(input.type, combobox)); | 1384 comboboxes->insert(std::make_pair(input.type, combobox)); |
| 1385 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); | 1385 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); |
| 1386 view_to_add.reset(combobox); | 1386 view_to_add.reset(combobox); |
| 1387 } else { | 1387 } else { |
| 1388 ExpandingTextfield* field = new ExpandingTextfield(input.initial_value, | 1388 ExpandingTextfield* field = new ExpandingTextfield(input.initial_value, |
| 1389 input.placeholder_text, | 1389 input.placeholder_text, |
| 1390 input.IsMultiline(), | 1390 input.IsMultiline(), |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 manual_input(NULL), | 1908 manual_input(NULL), |
| 1909 suggested_info(NULL), | 1909 suggested_info(NULL), |
| 1910 suggested_button(NULL) {} | 1910 suggested_button(NULL) {} |
| 1911 | 1911 |
| 1912 AutofillDialogViews::DetailsGroup::DetailsGroup(const DetailsGroup& other) = | 1912 AutofillDialogViews::DetailsGroup::DetailsGroup(const DetailsGroup& other) = |
| 1913 default; | 1913 default; |
| 1914 | 1914 |
| 1915 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 1915 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 1916 | 1916 |
| 1917 } // namespace autofill | 1917 } // namespace autofill |
| OLD | NEW |