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