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/omnibox/inline_omnibox_popup_view.h" | 5 #include "chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // Size our children to the available content area. | 231 // Size our children to the available content area. |
232 LayoutChildren(); | 232 LayoutChildren(); |
233 } | 233 } |
234 | 234 |
235 views::View* InlineOmniboxPopupView::GetEventHandlerForPoint( | 235 views::View* InlineOmniboxPopupView::GetEventHandlerForPoint( |
236 const gfx::Point& point) { | 236 const gfx::Point& point) { |
237 return this; | 237 return this; |
238 } | 238 } |
239 | 239 |
240 bool InlineOmniboxPopupView::OnMousePressed( | 240 bool InlineOmniboxPopupView::OnMousePressed( |
241 const views::MouseEvent& event) { | 241 const ui::MouseEvent& event) { |
242 ignore_mouse_drag_ = false; // See comment on |ignore_mouse_drag_| in header. | 242 ignore_mouse_drag_ = false; // See comment on |ignore_mouse_drag_| in header. |
243 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) | 243 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) |
244 UpdateLineEvent(event, event.IsLeftMouseButton()); | 244 UpdateLineEvent(event, event.IsLeftMouseButton()); |
245 return true; | 245 return true; |
246 } | 246 } |
247 | 247 |
248 bool InlineOmniboxPopupView::OnMouseDragged( | 248 bool InlineOmniboxPopupView::OnMouseDragged( |
249 const views::MouseEvent& event) { | 249 const ui::MouseEvent& event) { |
250 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) | 250 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) |
251 UpdateLineEvent(event, !ignore_mouse_drag_ && event.IsLeftMouseButton()); | 251 UpdateLineEvent(event, !ignore_mouse_drag_ && event.IsLeftMouseButton()); |
252 return true; | 252 return true; |
253 } | 253 } |
254 | 254 |
255 void InlineOmniboxPopupView::OnMouseReleased( | 255 void InlineOmniboxPopupView::OnMouseReleased( |
256 const views::MouseEvent& event) { | 256 const ui::MouseEvent& event) { |
257 if (ignore_mouse_drag_) { | 257 if (ignore_mouse_drag_) { |
258 OnMouseCaptureLost(); | 258 OnMouseCaptureLost(); |
259 return; | 259 return; |
260 } | 260 } |
261 | 261 |
262 if (event.IsOnlyMiddleMouseButton() || event.IsOnlyLeftMouseButton()) { | 262 if (event.IsOnlyMiddleMouseButton() || event.IsOnlyLeftMouseButton()) { |
263 OpenSelectedLine(event, event.IsOnlyLeftMouseButton() ? CURRENT_TAB : | 263 OpenSelectedLine(event, event.IsOnlyLeftMouseButton() ? CURRENT_TAB : |
264 NEW_BACKGROUND_TAB); | 264 NEW_BACKGROUND_TAB); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 void InlineOmniboxPopupView::OnMouseCaptureLost() { | 268 void InlineOmniboxPopupView::OnMouseCaptureLost() { |
269 ignore_mouse_drag_ = false; | 269 ignore_mouse_drag_ = false; |
270 } | 270 } |
271 | 271 |
272 void InlineOmniboxPopupView::OnMouseMoved( | 272 void InlineOmniboxPopupView::OnMouseMoved( |
273 const views::MouseEvent& event) { | 273 const ui::MouseEvent& event) { |
274 model_->SetHoveredLine(GetIndexForPoint(event.location())); | 274 model_->SetHoveredLine(GetIndexForPoint(event.location())); |
275 } | 275 } |
276 | 276 |
277 void InlineOmniboxPopupView::OnMouseEntered( | 277 void InlineOmniboxPopupView::OnMouseEntered( |
278 const views::MouseEvent& event) { | 278 const ui::MouseEvent& event) { |
279 model_->SetHoveredLine(GetIndexForPoint(event.location())); | 279 model_->SetHoveredLine(GetIndexForPoint(event.location())); |
280 } | 280 } |
281 | 281 |
282 void InlineOmniboxPopupView::OnMouseExited( | 282 void InlineOmniboxPopupView::OnMouseExited( |
283 const views::MouseEvent& event) { | 283 const ui::MouseEvent& event) { |
284 model_->SetHoveredLine(OmniboxPopupModel::kNoMatch); | 284 model_->SetHoveredLine(OmniboxPopupModel::kNoMatch); |
285 } | 285 } |
286 | 286 |
287 ui::GestureStatus InlineOmniboxPopupView::OnGestureEvent( | 287 ui::GestureStatus InlineOmniboxPopupView::OnGestureEvent( |
288 const views::GestureEvent& event) { | 288 const views::GestureEvent& event) { |
289 switch (event.type()) { | 289 switch (event.type()) { |
290 case ui::ET_GESTURE_TAP_DOWN: | 290 case ui::ET_GESTURE_TAP_DOWN: |
291 case ui::ET_GESTURE_SCROLL_BEGIN: | 291 case ui::ET_GESTURE_SCROLL_BEGIN: |
292 case ui::ET_GESTURE_SCROLL_UPDATE: | 292 case ui::ET_GESTURE_SCROLL_UPDATE: |
293 UpdateLineEvent(event, true); | 293 UpdateLineEvent(event, true); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 if (HasMatchAt(index) && should_set_selected_line) | 386 if (HasMatchAt(index) && should_set_selected_line) |
387 model_->SetSelectedLine(index, false, false); | 387 model_->SetSelectedLine(index, false, false); |
388 } | 388 } |
389 | 389 |
390 void InlineOmniboxPopupView::OpenSelectedLine( | 390 void InlineOmniboxPopupView::OpenSelectedLine( |
391 const ui::LocatedEvent& event, | 391 const ui::LocatedEvent& event, |
392 WindowOpenDisposition disposition) { | 392 WindowOpenDisposition disposition) { |
393 size_t index = GetIndexForPoint(event.location()); | 393 size_t index = GetIndexForPoint(event.location()); |
394 OpenIndex(index, disposition); | 394 OpenIndex(index, disposition); |
395 } | 395 } |
OLD | NEW |