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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 views::View::OnPaint(canvas); | 233 views::View::OnPaint(canvas); |
234 DrawArrow(canvas, width() / 2.0f, color_, SK_ColorTRANSPARENT); | 234 DrawArrow(canvas, width() / 2.0f, color_, SK_ColorTRANSPARENT); |
235 } | 235 } |
236 | 236 |
237 private: | 237 private: |
238 SkColor color_; | 238 SkColor color_; |
239 | 239 |
240 DISALLOW_COPY_AND_ASSIGN(ErrorBubbleContents); | 240 DISALLOW_COPY_AND_ASSIGN(ErrorBubbleContents); |
241 }; | 241 }; |
242 | 242 |
243 // A view that runs a callback whenever its bounds change. | |
244 class DetailsContainerView : public views::View { | |
245 public: | |
246 explicit DetailsContainerView(const base::Closure& callback) | |
247 : bounds_changed_callback_(callback) {} | |
248 virtual ~DetailsContainerView() {} | |
249 | |
250 // views::View implementation. | |
251 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE { | |
252 bounds_changed_callback_.Run(); | |
253 } | |
254 | |
255 private: | |
256 base::Closure bounds_changed_callback_; | |
257 | |
258 DISALLOW_COPY_AND_ASSIGN(DetailsContainerView); | |
259 }; | |
260 | |
261 // A view that propagates visibility and preferred size changes. | 243 // A view that propagates visibility and preferred size changes. |
262 class LayoutPropagationView : public views::View { | 244 class LayoutPropagationView : public views::View { |
263 public: | 245 public: |
264 LayoutPropagationView() {} | 246 LayoutPropagationView() {} |
265 virtual ~LayoutPropagationView() {} | 247 virtual ~LayoutPropagationView() {} |
266 | 248 |
267 protected: | 249 protected: |
268 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE { | 250 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE { |
269 PreferredSizeChanged(); | 251 PreferredSizeChanged(); |
270 } | 252 } |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 if (button_state == views::Button::STATE_PRESSED) | 1042 if (button_state == views::Button::STATE_PRESSED) |
1061 return IDR_AUTOFILL_DIALOG_MENU_BUTTON_P; | 1043 return IDR_AUTOFILL_DIALOG_MENU_BUTTON_P; |
1062 else if (button_state == views::Button::STATE_HOVERED) | 1044 else if (button_state == views::Button::STATE_HOVERED) |
1063 return IDR_AUTOFILL_DIALOG_MENU_BUTTON_H; | 1045 return IDR_AUTOFILL_DIALOG_MENU_BUTTON_H; |
1064 else if (button_state == views::Button::STATE_DISABLED) | 1046 else if (button_state == views::Button::STATE_DISABLED) |
1065 return IDR_AUTOFILL_DIALOG_MENU_BUTTON_D; | 1047 return IDR_AUTOFILL_DIALOG_MENU_BUTTON_D; |
1066 DCHECK_EQ(views::Button::STATE_NORMAL, button_state); | 1048 DCHECK_EQ(views::Button::STATE_NORMAL, button_state); |
1067 return IDR_AUTOFILL_DIALOG_MENU_BUTTON; | 1049 return IDR_AUTOFILL_DIALOG_MENU_BUTTON; |
1068 } | 1050 } |
1069 | 1051 |
| 1052 // AutofillDialogViews::DetailsContainerView ----------------------------------- |
| 1053 |
| 1054 AutofillDialogViews::DetailsContainerView::DetailsContainerView( |
| 1055 const base::Closure& callback) |
| 1056 : bounds_changed_callback_(callback), |
| 1057 ignore_layouts_(false) {} |
| 1058 |
| 1059 AutofillDialogViews::DetailsContainerView::~DetailsContainerView() {} |
| 1060 |
| 1061 void AutofillDialogViews::DetailsContainerView::OnBoundsChanged( |
| 1062 const gfx::Rect& previous_bounds) { |
| 1063 bounds_changed_callback_.Run(); |
| 1064 } |
| 1065 |
| 1066 void AutofillDialogViews::DetailsContainerView::Layout() { |
| 1067 if (!ignore_layouts_) |
| 1068 views::View::Layout(); |
| 1069 } |
| 1070 |
1070 // AutofillDialogViews::SuggestionView ----------------------------------------- | 1071 // AutofillDialogViews::SuggestionView ----------------------------------------- |
1071 | 1072 |
1072 AutofillDialogViews::SuggestionView::SuggestionView( | 1073 AutofillDialogViews::SuggestionView::SuggestionView( |
1073 AutofillDialogViews* autofill_dialog) | 1074 AutofillDialogViews* autofill_dialog) |
1074 : label_(new views::Label()), | 1075 : label_(new views::Label()), |
1075 label_line_2_(new views::Label()), | 1076 label_line_2_(new views::Label()), |
1076 icon_(new views::ImageView()), | 1077 icon_(new views::ImageView()), |
1077 decorated_( | 1078 decorated_( |
1078 new DecoratedTextfield(base::string16(), | 1079 new DecoratedTextfield(base::string16(), |
1079 base::string16(), | 1080 base::string16(), |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 int notification_height = notification_area_->GetHeightForWidth(width); | 1552 int notification_height = notification_area_->GetHeightForWidth(width); |
1552 notification_area_->SetBounds(x, y, width, notification_height); | 1553 notification_area_->SetBounds(x, y, width, notification_height); |
1553 | 1554 |
1554 // The rest (the |scrollable_area_|) takes up whatever's left. | 1555 // The rest (the |scrollable_area_|) takes up whatever's left. |
1555 if (scrollable_area_->visible()) { | 1556 if (scrollable_area_->visible()) { |
1556 int scroll_y = y; | 1557 int scroll_y = y; |
1557 if (notification_height > 0) | 1558 if (notification_height > 0) |
1558 scroll_y += notification_height + views::kRelatedControlVerticalSpacing; | 1559 scroll_y += notification_height + views::kRelatedControlVerticalSpacing; |
1559 | 1560 |
1560 int scroll_bottom = content_bounds.bottom(); | 1561 int scroll_bottom = content_bounds.bottom(); |
1561 scrollable_area_->contents()->SizeToPreferredSize(); | 1562 DCHECK_EQ(scrollable_area_->contents(), details_container_); |
| 1563 details_container_->SizeToPreferredSize(); |
| 1564 // TODO(estade): remove this hack. See crbug.com/285996 |
| 1565 details_container_->set_ignore_layouts(true); |
1562 scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y); | 1566 scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y); |
| 1567 details_container_->set_ignore_layouts(false); |
1563 } | 1568 } |
1564 | 1569 |
1565 if (loading_shield_->visible()) | 1570 if (loading_shield_->visible()) |
1566 loading_shield_->SetBoundsRect(bounds()); | 1571 loading_shield_->SetBoundsRect(bounds()); |
1567 | 1572 |
1568 if (error_bubble_) | 1573 if (error_bubble_) |
1569 error_bubble_->UpdatePosition(); | 1574 error_bubble_->UpdatePosition(); |
1570 } | 1575 } |
1571 | 1576 |
1572 void AutofillDialogViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1577 void AutofillDialogViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2348 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2353 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2349 : section(section), | 2354 : section(section), |
2350 container(NULL), | 2355 container(NULL), |
2351 manual_input(NULL), | 2356 manual_input(NULL), |
2352 suggested_info(NULL), | 2357 suggested_info(NULL), |
2353 suggested_button(NULL) {} | 2358 suggested_button(NULL) {} |
2354 | 2359 |
2355 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2360 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2356 | 2361 |
2357 } // namespace autofill | 2362 } // namespace autofill |
OLD | NEW |