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/i18n/bidi_line_iterator.h" | 8 #include "base/i18n/bidi_line_iterator.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch); | 1025 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch); |
1026 } | 1026 } |
1027 | 1027 |
1028 bool AutocompletePopupContentsView::OnMousePressed( | 1028 bool AutocompletePopupContentsView::OnMousePressed( |
1029 const views::MouseEvent& event) { | 1029 const views::MouseEvent& event) { |
1030 ignore_mouse_drag_ = false; // See comment on |ignore_mouse_drag_| in header. | 1030 ignore_mouse_drag_ = false; // See comment on |ignore_mouse_drag_| in header. |
1031 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) { | 1031 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) { |
1032 size_t index = GetIndexForPoint(event.location()); | 1032 size_t index = GetIndexForPoint(event.location()); |
1033 model_->SetHoveredLine(index); | 1033 model_->SetHoveredLine(index); |
1034 if (HasMatchAt(index) && event.IsLeftMouseButton()) | 1034 if (HasMatchAt(index) && event.IsLeftMouseButton()) |
1035 model_->SetSelectedLine(index, false); | 1035 model_->SetSelectedLine(index, false, false); |
1036 } | 1036 } |
1037 return true; | 1037 return true; |
1038 } | 1038 } |
1039 | 1039 |
1040 void AutocompletePopupContentsView::OnMouseReleased( | 1040 void AutocompletePopupContentsView::OnMouseReleased( |
1041 const views::MouseEvent& event, | 1041 const views::MouseEvent& event, |
1042 bool canceled) { | 1042 bool canceled) { |
1043 if (canceled || ignore_mouse_drag_) { | 1043 if (canceled || ignore_mouse_drag_) { |
1044 ignore_mouse_drag_ = false; | 1044 ignore_mouse_drag_ = false; |
1045 return; | 1045 return; |
1046 } | 1046 } |
1047 | 1047 |
1048 size_t index = GetIndexForPoint(event.location()); | 1048 size_t index = GetIndexForPoint(event.location()); |
1049 if (event.IsOnlyMiddleMouseButton()) | 1049 if (event.IsOnlyMiddleMouseButton()) |
1050 OpenIndex(index, NEW_BACKGROUND_TAB); | 1050 OpenIndex(index, NEW_BACKGROUND_TAB); |
1051 else if (event.IsOnlyLeftMouseButton()) | 1051 else if (event.IsOnlyLeftMouseButton()) |
1052 OpenIndex(index, CURRENT_TAB); | 1052 OpenIndex(index, CURRENT_TAB); |
1053 } | 1053 } |
1054 | 1054 |
1055 bool AutocompletePopupContentsView::OnMouseDragged( | 1055 bool AutocompletePopupContentsView::OnMouseDragged( |
1056 const views::MouseEvent& event) { | 1056 const views::MouseEvent& event) { |
1057 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) { | 1057 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) { |
1058 size_t index = GetIndexForPoint(event.location()); | 1058 size_t index = GetIndexForPoint(event.location()); |
1059 model_->SetHoveredLine(index); | 1059 model_->SetHoveredLine(index); |
1060 if (!ignore_mouse_drag_ && HasMatchAt(index) && event.IsLeftMouseButton()) | 1060 if (!ignore_mouse_drag_ && HasMatchAt(index) && event.IsLeftMouseButton()) |
1061 model_->SetSelectedLine(index, false); | 1061 model_->SetSelectedLine(index, false, false); |
1062 } | 1062 } |
1063 return true; | 1063 return true; |
1064 } | 1064 } |
1065 | 1065 |
1066 views::View* AutocompletePopupContentsView::GetViewForPoint( | 1066 views::View* AutocompletePopupContentsView::GetViewForPoint( |
1067 const gfx::Point& point) { | 1067 const gfx::Point& point) { |
1068 // If there is no opt in view, then we want all mouse events. Otherwise let | 1068 // If there is no opt in view, then we want all mouse events. Otherwise let |
1069 // any descendants of the opt-in view get mouse events. | 1069 // any descendants of the opt-in view get mouse events. |
1070 if (!opt_in_view_) | 1070 if (!opt_in_view_) |
1071 return this; | 1071 return this; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 opt_in_view_ = NULL; | 1203 opt_in_view_ = NULL; |
1204 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 1204 PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); |
1205 DCHECK(counter); | 1205 DCHECK(counter); |
1206 counter->Hide(); | 1206 counter->Hide(); |
1207 if (opt_in) { | 1207 if (opt_in) { |
1208 browser::ShowInstantConfirmDialogIfNecessary( | 1208 browser::ShowInstantConfirmDialogIfNecessary( |
1209 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); | 1209 location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); |
1210 } | 1210 } |
1211 UpdatePopupAppearance(); | 1211 UpdatePopupAppearance(); |
1212 } | 1212 } |
OLD | NEW |