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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 autocomplete_controller_->input().text(), | 519 autocomplete_controller_->input().text(), |
520 just_deleted_text_, | 520 just_deleted_text_, |
521 autocomplete_controller_->input().type(), | 521 autocomplete_controller_->input().type(), |
522 popup_->selected_line(), | 522 popup_->selected_line(), |
523 -1, // don't yet know tab ID; set later if appropriate | 523 -1, // don't yet know tab ID; set later if appropriate |
524 ClassifyPage(controller_->GetTabContents()-> | 524 ClassifyPage(controller_->GetTabContents()-> |
525 web_contents()->GetURL()), | 525 web_contents()->GetURL()), |
526 base::TimeTicks::Now() - time_user_first_modified_omnibox_, | 526 base::TimeTicks::Now() - time_user_first_modified_omnibox_, |
527 0, // inline autocomplete length; possibly set later | 527 0, // inline autocomplete length; possibly set later |
528 result()); | 528 result()); |
529 DCHECK(user_input_in_progress_) << "We didn't get here through the " | 529 DCHECK(user_input_in_progress_ || match.provider->name() == "ZeroSuggest") |
530 "expected series of calls. time_user_first_modified_omnibox_ is " | 530 << "We didn't get here through the expected series of calls. " |
531 "not set correctly and other things may be wrong."; | 531 << "time_user_first_modified_omnibox_ is not set correctly and other " |
| 532 << "things may be wrong. Match provider: " << match.provider->name(); |
532 if (index != OmniboxPopupModel::kNoMatch) | 533 if (index != OmniboxPopupModel::kNoMatch) |
533 log.selected_index = index; | 534 log.selected_index = index; |
534 else if (!has_temporary_text_) | 535 else if (!has_temporary_text_) |
535 log.inline_autocompleted_length = inline_autocomplete_text_.length(); | 536 log.inline_autocompleted_length = inline_autocomplete_text_.length(); |
536 if (disposition == CURRENT_TAB) { | 537 if (disposition == CURRENT_TAB) { |
537 // If we know the destination is being opened in the current tab, | 538 // If we know the destination is being opened in the current tab, |
538 // we can easily get the tab ID. (If it's being opened in a new | 539 // we can easily get the tab ID. (If it's being opened in a new |
539 // tab, we don't know the tab ID yet.) | 540 // tab, we don't know the tab ID yet.) |
540 log.tab_id = controller_->GetTabContents()-> | 541 log.tab_id = controller_->GetTabContents()-> |
541 session_tab_helper()->session_id().id(); | 542 session_tab_helper()->session_id().id(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 685 } |
685 | 686 |
686 void OmniboxEditModel::OnSetFocus(bool control_down) { | 687 void OmniboxEditModel::OnSetFocus(bool control_down) { |
687 has_focus_ = true; | 688 has_focus_ = true; |
688 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; | 689 control_key_state_ = control_down ? DOWN_WITHOUT_CHANGE : UP; |
689 | 690 |
690 InstantController* instant = controller_->GetInstant(); | 691 InstantController* instant = controller_->GetInstant(); |
691 if (instant) | 692 if (instant) |
692 instant->OnAutocompleteGotFocus(); | 693 instant->OnAutocompleteGotFocus(); |
693 | 694 |
| 695 TabContents* tab_contents = controller_->GetTabContents(); |
| 696 if (tab_contents) { |
| 697 // TODO(jered): We may want to merge this into Start() and just call that |
| 698 // here rather than having a special entry point for zero-suggest. Note |
| 699 // that we avoid PermanentURL() here because it's not guaranteed to give us |
| 700 // the actual underlying current URL, e.g. if we're on the NTP and the |
| 701 // |permanent_text_| is empty. |
| 702 autocomplete_controller_->StartZeroSuggest( |
| 703 tab_contents->web_contents()->GetURL(), user_text_); |
| 704 } |
| 705 |
694 NotifySearchTabHelper(); | 706 NotifySearchTabHelper(); |
695 } | 707 } |
696 | 708 |
697 void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) { | 709 void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) { |
698 SetSuggestedText(string16(), INSTANT_COMPLETE_NOW); | 710 SetSuggestedText(string16(), INSTANT_COMPLETE_NOW); |
699 | 711 |
700 if (InstantController* instant = controller_->GetInstant()) | 712 if (InstantController* instant = controller_->GetInstant()) |
701 instant->OnAutocompleteLostFocus(view_gaining_focus); | 713 instant->OnAutocompleteLostFocus(view_gaining_focus); |
702 | 714 |
| 715 // TODO(jered): Rip this out along with StartZeroSuggest. |
| 716 autocomplete_controller_->StopZeroSuggest(); |
703 NotifySearchTabHelper(); | 717 NotifySearchTabHelper(); |
704 } | 718 } |
705 | 719 |
706 void OmniboxEditModel::OnKillFocus() { | 720 void OmniboxEditModel::OnKillFocus() { |
707 has_focus_ = false; | 721 has_focus_ = false; |
708 control_key_state_ = UP; | 722 control_key_state_ = UP; |
709 paste_state_ = NONE; | 723 paste_state_ = NONE; |
710 } | 724 } |
711 | 725 |
712 bool OmniboxEditModel::OnEscapeKeyPressed() { | 726 bool OmniboxEditModel::OnEscapeKeyPressed() { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1221 } |
1208 | 1222 |
1209 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1223 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
1210 const string16& text, | 1224 const string16& text, |
1211 AutocompleteMatch* match, | 1225 AutocompleteMatch* match, |
1212 GURL* alternate_nav_url) const { | 1226 GURL* alternate_nav_url) const { |
1213 DCHECK(match); | 1227 DCHECK(match); |
1214 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1228 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
1215 string16(), false, false, match, alternate_nav_url); | 1229 string16(), false, false, match, alternate_nav_url); |
1216 } | 1230 } |
OLD | NEW |