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/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 // will have updated our state already, so in that case we don't also return | 1002 // will have updated our state already, so in that case we don't also return |
1003 // true from this function. | 1003 // true from this function. |
1004 return !(text_differs && allow_keyword_ui_change && !just_deleted_text && | 1004 return !(text_differs && allow_keyword_ui_change && !just_deleted_text && |
1005 no_selection && (selection_start == user_text_.length()) && | 1005 no_selection && (selection_start == user_text_.length()) && |
1006 MaybeAcceptKeywordBySpace(user_text_)); | 1006 MaybeAcceptKeywordBySpace(user_text_)); |
1007 } | 1007 } |
1008 | 1008 |
1009 void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { | 1009 void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { |
1010 InstantController* instant = controller_->GetInstant(); | 1010 InstantController* instant = controller_->GetInstant(); |
1011 if (instant) | 1011 if (instant) |
1012 instant->SetPopupBounds(bounds); | |
1013 } | |
1014 | |
1015 void OmniboxEditModel::OmniboxBoundsChangedTo(const gfx::Rect& bounds) { | |
1016 InstantController* instant = controller_->GetInstant(); | |
1017 if (instant) | |
1012 instant->SetOmniboxBounds(bounds); | 1018 instant->SetOmniboxBounds(bounds); |
1013 } | 1019 } |
1014 | 1020 |
1015 void OmniboxEditModel::OnResultChanged(bool default_match_changed) { | 1021 void OmniboxEditModel::OnResultChanged(bool default_match_changed) { |
1016 const bool was_open = popup_->IsOpen(); | 1022 const bool was_open = popup_->IsOpen(); |
1017 if (default_match_changed) { | 1023 if (default_match_changed) { |
1018 string16 inline_autocomplete_text; | 1024 string16 inline_autocomplete_text; |
1019 string16 keyword; | 1025 string16 keyword; |
1020 bool is_keyword_hint = false; | 1026 bool is_keyword_hint = false; |
1021 const AutocompleteResult& result = this->result(); | 1027 const AutocompleteResult& result = this->result(); |
(...skipping 16 matching lines...) Expand all Loading... | |
1038 match->GetKeywordUIState(profile_, &keyword, &is_keyword_hint); | 1044 match->GetKeywordUIState(profile_, &keyword, &is_keyword_hint); |
1039 } | 1045 } |
1040 | 1046 |
1041 popup_->OnResultChanged(); | 1047 popup_->OnResultChanged(); |
1042 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, | 1048 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, |
1043 is_keyword_hint); | 1049 is_keyword_hint); |
1044 } else { | 1050 } else { |
1045 popup_->OnResultChanged(); | 1051 popup_->OnResultChanged(); |
1046 } | 1052 } |
1047 | 1053 |
1054 // TODO(melevin): Find a better place to call this. | |
1055 OmniboxBoundsChangedTo(view_->GetBounds()); | |
dhollowa
2012/11/14 17:20:46
The OmniboxView class holds a pointer to an Omnibo
melevin
2012/11/14 22:16:27
Thanks, this is much cleaner.
| |
1056 | |
1048 if (popup_->IsOpen()) { | 1057 if (popup_->IsOpen()) { |
1049 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); | 1058 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); |
1050 } else if (was_open) { | 1059 } else if (was_open) { |
1051 // Accepts the temporary text as the user text, because it makes little | 1060 // Accepts the temporary text as the user text, because it makes little |
1052 // sense to have temporary text when the popup is closed. | 1061 // sense to have temporary text when the popup is closed. |
1053 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); | 1062 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); |
1054 has_temporary_text_ = false; | 1063 has_temporary_text_ = false; |
1055 is_temporary_text_set_by_instant_ = false; | 1064 is_temporary_text_set_by_instant_ = false; |
1056 PopupBoundsChangedTo(gfx::Rect()); | 1065 PopupBoundsChangedTo(gfx::Rect()); |
1057 NotifySearchTabHelper(); | 1066 NotifySearchTabHelper(); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1288 } | 1297 } |
1289 | 1298 |
1290 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1299 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
1291 const string16& text, | 1300 const string16& text, |
1292 AutocompleteMatch* match, | 1301 AutocompleteMatch* match, |
1293 GURL* alternate_nav_url) const { | 1302 GURL* alternate_nav_url) const { |
1294 DCHECK(match); | 1303 DCHECK(match); |
1295 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1304 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
1296 string16(), false, false, match, alternate_nav_url); | 1305 string16(), false, false, match, alternate_nav_url); |
1297 } | 1306 } |
OLD | NEW |