OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_base_view.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_popup_base_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/ui/autofill/popup_constants.h" | 10 #include "chrome/browser/ui/autofill/popup_constants.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // deletion. | 59 // deletion. |
60 views::Widget* widget = new views::Widget; | 60 views::Widget* widget = new views::Widget; |
61 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 61 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
62 params.delegate = this; | 62 params.delegate = this; |
63 params.parent = container_view(); | 63 params.parent = container_view(); |
64 widget->Init(params); | 64 widget->Init(params); |
65 widget->SetContentsView(this); | 65 widget->SetContentsView(this); |
66 | 66 |
67 // No animation for popup appearance (too distracting). | 67 // No animation for popup appearance (too distracting). |
68 widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); | 68 widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); |
| 69 |
| 70 show_time_ = base::Time::Now(); |
69 } | 71 } |
70 | 72 |
71 SetBorder(views::Border::CreateSolidBorder(kPopupBorderThickness, | 73 SetBorder(views::Border::CreateSolidBorder(kPopupBorderThickness, |
72 kBorderColor)); | 74 kBorderColor)); |
73 | 75 |
74 DoUpdateBoundsAndRedrawPopup(); | 76 DoUpdateBoundsAndRedrawPopup(); |
75 GetWidget()->Show(); | 77 GetWidget()->Show(); |
76 | 78 |
77 // Showing the widget can change native focus (which would result in an | 79 // Showing the widget can change native focus (which would result in an |
78 // immediate hiding of the popup). Only start observing after shown. | 80 // immediate hiding of the popup). Only start observing after shown. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // via AcceleratorPressed, so we need to let that run first. | 138 // via AcceleratorPressed, so we need to let that run first. |
137 base::MessageLoop::current()->PostTask( | 139 base::MessageLoop::current()->PostTask( |
138 FROM_HERE, | 140 FROM_HERE, |
139 base::Bind(&AutofillPopupBaseView::ClearSelection, | 141 base::Bind(&AutofillPopupBaseView::ClearSelection, |
140 weak_ptr_factory_.GetWeakPtr())); | 142 weak_ptr_factory_.GetWeakPtr())); |
141 } | 143 } |
142 | 144 |
143 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) { | 145 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) { |
144 // A synthesized mouse move will be sent when the popup is first shown. | 146 // A synthesized mouse move will be sent when the popup is first shown. |
145 // Don't preview a suggestion if the mouse happens to be hovering there. | 147 // Don't preview a suggestion if the mouse happens to be hovering there. |
| 148 #if defined(OS_WIN) |
| 149 // TODO(rouslan): Use event.time_stamp() and ui::EventTimeForNow() when they |
| 150 // become comparable. http://crbug.com/453559 |
| 151 if (base::Time::Now() - show_time_ <= base::TimeDelta::FromMilliseconds(50)) |
| 152 return; |
| 153 #else |
146 if (event.flags() & ui::EF_IS_SYNTHESIZED) | 154 if (event.flags() & ui::EF_IS_SYNTHESIZED) |
147 return; | 155 return; |
| 156 #endif |
148 | 157 |
149 if (HitTestPoint(event.location())) | 158 if (HitTestPoint(event.location())) |
150 SetSelection(event.location()); | 159 SetSelection(event.location()); |
151 else | 160 else |
152 ClearSelection(); | 161 ClearSelection(); |
153 } | 162 } |
154 | 163 |
155 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) { | 164 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) { |
156 return event.GetClickCount() == 1; | 165 return event.GetClickCount() == 1; |
157 } | 166 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void AutofillPopupBaseView::HideController() { | 235 void AutofillPopupBaseView::HideController() { |
227 if (delegate_) | 236 if (delegate_) |
228 delegate_->Hide(); | 237 delegate_->Hide(); |
229 } | 238 } |
230 | 239 |
231 gfx::NativeView AutofillPopupBaseView::container_view() { | 240 gfx::NativeView AutofillPopupBaseView::container_view() { |
232 return delegate_->container_view(); | 241 return delegate_->container_view(); |
233 } | 242 } |
234 | 243 |
235 } // namespace autofill | 244 } // namespace autofill |
OLD | NEW |