OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete/autocomplete_popup_contents_view.
h" | 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_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/autocomplete/autocomplete_edit_view.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) { | 437 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) { |
438 size_t index = GetIndexForPoint(event.location()); | 438 size_t index = GetIndexForPoint(event.location()); |
439 model_->SetHoveredLine(index); | 439 model_->SetHoveredLine(index); |
440 if (!ignore_mouse_drag_ && HasMatchAt(index) && event.IsLeftMouseButton()) | 440 if (!ignore_mouse_drag_ && HasMatchAt(index) && event.IsLeftMouseButton()) |
441 model_->SetSelectedLine(index, false, false); | 441 model_->SetSelectedLine(index, false, false); |
442 } | 442 } |
443 return true; | 443 return true; |
444 } | 444 } |
445 | 445 |
446 void AutocompletePopupContentsView::OnMouseReleased( | 446 void AutocompletePopupContentsView::OnMouseReleased( |
447 const views::MouseEvent& event, | 447 const views::MouseEvent& event) { |
448 bool canceled) { | 448 if (ignore_mouse_drag_) { |
449 if (canceled || ignore_mouse_drag_) { | 449 OnMouseCaptureLost(); |
450 ignore_mouse_drag_ = false; | |
451 return; | 450 return; |
452 } | 451 } |
453 | 452 |
454 size_t index = GetIndexForPoint(event.location()); | 453 size_t index = GetIndexForPoint(event.location()); |
455 if (event.IsOnlyMiddleMouseButton()) | 454 if (event.IsOnlyMiddleMouseButton()) |
456 OpenIndex(index, NEW_BACKGROUND_TAB); | 455 OpenIndex(index, NEW_BACKGROUND_TAB); |
457 else if (event.IsOnlyLeftMouseButton()) | 456 else if (event.IsOnlyLeftMouseButton()) |
458 OpenIndex(index, CURRENT_TAB); | 457 OpenIndex(index, CURRENT_TAB); |
459 } | 458 } |
460 | 459 |
| 460 void AutocompletePopupContentsView::OnMouseCaptureLost() { |
| 461 ignore_mouse_drag_ = false; |
| 462 } |
| 463 |
461 void AutocompletePopupContentsView::OnMouseMoved( | 464 void AutocompletePopupContentsView::OnMouseMoved( |
462 const views::MouseEvent& event) { | 465 const views::MouseEvent& event) { |
463 model_->SetHoveredLine(GetIndexForPoint(event.location())); | 466 model_->SetHoveredLine(GetIndexForPoint(event.location())); |
464 } | 467 } |
465 | 468 |
466 void AutocompletePopupContentsView::OnMouseEntered( | 469 void AutocompletePopupContentsView::OnMouseEntered( |
467 const views::MouseEvent& event) { | 470 const views::MouseEvent& event) { |
468 model_->SetHoveredLine(GetIndexForPoint(event.location())); | 471 model_->SetHoveredLine(GetIndexForPoint(event.location())); |
469 } | 472 } |
470 | 473 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 opt_in_view_ = NULL; | 675 opt_in_view_ = NULL; |
673 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 676 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); |
674 DCHECK(counter); | 677 DCHECK(counter); |
675 counter->Hide(); | 678 counter->Hide(); |
676 if (opt_in) { | 679 if (opt_in) { |
677 browser::ShowInstantConfirmDialogIfNecessary( | 680 browser::ShowInstantConfirmDialogIfNecessary( |
678 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); | 681 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); |
679 } | 682 } |
680 UpdatePopupAppearance(); | 683 UpdatePopupAppearance(); |
681 } | 684 } |
OLD | NEW |