Chromium Code Reviews| 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 static const int64 kMouseMoveIngoreMs = 50; | |
| 150 if ((base::Time::Now() - show_time_).InMilliseconds() <= kMouseMoveIngoreMs) | |
|
Evan Stade
2015/03/19 20:16:30
if (base::Time::Now() < show_time_ + TimeDelta::Fr
please use gerrit instead
2015/03/20 17:36:43
Done.
| |
| 151 return; | |
| 152 #else | |
| 146 if (event.flags() & ui::EF_IS_SYNTHESIZED) | 153 if (event.flags() & ui::EF_IS_SYNTHESIZED) |
| 147 return; | 154 return; |
| 155 #endif | |
| 148 | 156 |
| 149 if (HitTestPoint(event.location())) | 157 if (HitTestPoint(event.location())) |
| 150 SetSelection(event.location()); | 158 SetSelection(event.location()); |
| 151 else | 159 else |
| 152 ClearSelection(); | 160 ClearSelection(); |
| 153 } | 161 } |
| 154 | 162 |
| 155 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) { | 163 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) { |
| 156 return event.GetClickCount() == 1; | 164 return event.GetClickCount() == 1; |
| 157 } | 165 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 void AutofillPopupBaseView::HideController() { | 234 void AutofillPopupBaseView::HideController() { |
| 227 if (delegate_) | 235 if (delegate_) |
| 228 delegate_->Hide(); | 236 delegate_->Hide(); |
| 229 } | 237 } |
| 230 | 238 |
| 231 gfx::NativeView AutofillPopupBaseView::container_view() { | 239 gfx::NativeView AutofillPopupBaseView::container_view() { |
| 232 return delegate_->container_view(); | 240 return delegate_->container_view(); |
| 233 } | 241 } |
| 234 | 242 |
| 235 } // namespace autofill | 243 } // namespace autofill |
| OLD | NEW |