| 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_popup_view_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| 10 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 AutofillPopupViewViews::AutofillPopupViewViews( | 31 AutofillPopupViewViews::AutofillPopupViewViews( |
| 32 AutofillPopupController* controller) | 32 AutofillPopupController* controller) |
| 33 : controller_(controller), | 33 : controller_(controller), |
| 34 observing_widget_(NULL) {} | 34 observing_widget_(NULL) {} |
| 35 | 35 |
| 36 AutofillPopupViewViews::~AutofillPopupViewViews() { | 36 AutofillPopupViewViews::~AutofillPopupViewViews() { |
| 37 if (observing_widget_) | 37 if (observing_widget_) |
| 38 observing_widget_->RemoveObserver(this); | 38 observing_widget_->RemoveObserver(this); |
| 39 | |
| 40 controller_->ViewDestroyed(); | |
| 41 } | 39 } |
| 42 | 40 |
| 43 void AutofillPopupViewViews::Hide() { | 41 void AutofillPopupViewViews::Hide() { |
| 44 if (GetWidget()) { | 42 if (GetWidget()) { |
| 45 // This deletes |this|. | 43 // This deletes |this|. |
| 46 GetWidget()->Close(); | 44 GetWidget()->Close(); |
| 47 } else { | 45 } else { |
| 48 delete this; | 46 delete this; |
| 49 } | 47 } |
| 50 } | 48 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void AutofillPopupViewViews::OnMouseReleased(const ui::MouseEvent& event) { | 97 void AutofillPopupViewViews::OnMouseReleased(const ui::MouseEvent& event) { |
| 100 // We only care about the left click. | 98 // We only care about the left click. |
| 101 if (event.IsOnlyLeftMouseButton() && | 99 if (event.IsOnlyLeftMouseButton() && |
| 102 HitTestPoint(gfx::Point(event.x(), event.y()))) | 100 HitTestPoint(gfx::Point(event.x(), event.y()))) |
| 103 controller_->MouseClicked(event.x(), event.y()); | 101 controller_->MouseClicked(event.x(), event.y()); |
| 104 } | 102 } |
| 105 | 103 |
| 106 void AutofillPopupViewViews::OnWidgetBoundsChanged( | 104 void AutofillPopupViewViews::OnWidgetBoundsChanged( |
| 107 views::Widget* widget, | 105 views::Widget* widget, |
| 108 const gfx::Rect& new_bounds) { | 106 const gfx::Rect& new_bounds) { |
| 109 Hide(); | 107 controller_->Hide(); |
| 110 } | 108 } |
| 111 | 109 |
| 112 void AutofillPopupViewViews::Show() { | 110 void AutofillPopupViewViews::Show() { |
| 113 if (!GetWidget()) { | 111 if (!GetWidget()) { |
| 114 // The widget is destroyed by the corresponding NativeWidget, so we use | 112 // The widget is destroyed by the corresponding NativeWidget, so we use |
| 115 // a weak pointer to hold the reference and don't have to worry about | 113 // a weak pointer to hold the reference and don't have to worry about |
| 116 // deletion. | 114 // deletion. |
| 117 views::Widget* widget = new views::Widget; | 115 views::Widget* widget = new views::Widget; |
| 118 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 116 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 119 params.delegate = this; | 117 params.delegate = this; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 canvas->GetStringWidth(controller_->subtexts()[index], | 213 canvas->GetStringWidth(controller_->subtexts()[index], |
| 216 controller_->subtext_font()), | 214 controller_->subtext_font()), |
| 217 entry_rect.height(), | 215 entry_rect.height(), |
| 218 gfx::Canvas::TEXT_ALIGN_CENTER); | 216 gfx::Canvas::TEXT_ALIGN_CENTER); |
| 219 } | 217 } |
| 220 | 218 |
| 221 AutofillPopupView* AutofillPopupView::Create( | 219 AutofillPopupView* AutofillPopupView::Create( |
| 222 AutofillPopupController* controller) { | 220 AutofillPopupController* controller) { |
| 223 return new AutofillPopupViewViews(controller); | 221 return new AutofillPopupViewViews(controller); |
| 224 } | 222 } |
| OLD | NEW |