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/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/browser/ui/autofill/popup_constants.h" | 11 #include "chrome/browser/ui/autofill/popup_constants.h" |
11 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
12 #include "ui/views/focus/focus_manager.h" | 13 #include "ui/views/focus/focus_manager.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 | 15 |
15 namespace autofill { | 16 namespace autofill { |
16 | 17 |
17 const SkColor AutofillPopupBaseView::kBorderColor = | 18 const SkColor AutofillPopupBaseView::kBorderColor = |
18 SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE); | 19 SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE); |
19 const SkColor AutofillPopupBaseView::kHoveredBackgroundColor = | 20 const SkColor AutofillPopupBaseView::kHoveredBackgroundColor = |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 130 |
130 // If we move off of the popup, we lose the selection. | 131 // If we move off of the popup, we lose the selection. |
131 ClearSelection(); | 132 ClearSelection(); |
132 return false; | 133 return false; |
133 } | 134 } |
134 | 135 |
135 void AutofillPopupBaseView::OnMouseExited(const ui::MouseEvent& event) { | 136 void AutofillPopupBaseView::OnMouseExited(const ui::MouseEvent& event) { |
136 // Pressing return causes the cursor to hide, which will generate an | 137 // Pressing return causes the cursor to hide, which will generate an |
137 // OnMouseExited event. Pressing return should activate the current selection | 138 // OnMouseExited event. Pressing return should activate the current selection |
138 // via AcceleratorPressed, so we need to let that run first. | 139 // via AcceleratorPressed, so we need to let that run first. |
139 base::MessageLoop::current()->PostTask( | 140 base::ThreadTaskRunnerHandle::Get()->PostTask( |
140 FROM_HERE, | 141 FROM_HERE, base::Bind(&AutofillPopupBaseView::ClearSelection, |
141 base::Bind(&AutofillPopupBaseView::ClearSelection, | 142 weak_ptr_factory_.GetWeakPtr())); |
142 weak_ptr_factory_.GetWeakPtr())); | |
143 } | 143 } |
144 | 144 |
145 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) { | 145 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) { |
146 // 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. |
147 // 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) | 148 #if defined(OS_WIN) |
149 // TODO(rouslan): Use event.time_stamp() and ui::EventTimeForNow() when they | 149 // TODO(rouslan): Use event.time_stamp() and ui::EventTimeForNow() when they |
150 // become comparable. http://crbug.com/453559 | 150 // become comparable. http://crbug.com/453559 |
151 if (base::Time::Now() - show_time_ <= base::TimeDelta::FromMilliseconds(50)) | 151 if (base::Time::Now() - show_time_ <= base::TimeDelta::FromMilliseconds(50)) |
152 return; | 152 return; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 void AutofillPopupBaseView::HideController() { | 235 void AutofillPopupBaseView::HideController() { |
236 if (delegate_) | 236 if (delegate_) |
237 delegate_->Hide(); | 237 delegate_->Hide(); |
238 } | 238 } |
239 | 239 |
240 gfx::NativeView AutofillPopupBaseView::container_view() { | 240 gfx::NativeView AutofillPopupBaseView::container_view() { |
241 return delegate_->container_view(); | 241 return delegate_->container_view(); |
242 } | 242 } |
243 | 243 |
244 } // namespace autofill | 244 } // namespace autofill |
OLD | NEW |