OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 match.is_history_what_you_typed_match)) { | 666 match.is_history_what_you_typed_match)) { |
667 // When the user pasted in a URL and hit enter, score it like a link click | 667 // When the user pasted in a URL and hit enter, score it like a link click |
668 // rather than a normal typed URL, so it doesn't get inline autocompleted | 668 // rather than a normal typed URL, so it doesn't get inline autocompleted |
669 // as aggressively later. | 669 // as aggressively later. |
670 match.transition = content::PAGE_TRANSITION_LINK; | 670 match.transition = content::PAGE_TRANSITION_LINK; |
671 } | 671 } |
672 | 672 |
673 const TemplateURL* template_url = match.GetTemplateURL(profile_, false); | 673 const TemplateURL* template_url = match.GetTemplateURL(profile_, false); |
674 if (template_url && template_url->url_ref().HasGoogleBaseURLs()) | 674 if (template_url && template_url->url_ref().HasGoogleBaseURLs()) |
675 GoogleURLTracker::GoogleURLSearchCommitted(profile_); | 675 GoogleURLTracker::GoogleURLSearchCommitted(profile_); |
676 | 676 view_->OpenMatch( |
Peter Kasting
2014/04/08 22:52:56
Nit: Don't remove this blank line
Mark P
2014/04/08 22:58:32
Done.
| |
677 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), | 677 match, disposition, alternate_nav_url, base::string16(), |
678 OmniboxPopupModel::kNoMatch); | 678 popup_model() && popup_model()->IsOpen() ? |
Peter Kasting
2014/04/08 22:52:56
It doesn't seem like we need to check this. If th
Mark P
2014/04/08 22:58:32
Done.
| |
679 popup_model()->selected_line() : OmniboxPopupModel::kNoMatch); | |
679 } | 680 } |
680 | 681 |
681 void OmniboxEditModel::OpenMatch(AutocompleteMatch match, | 682 void OmniboxEditModel::OpenMatch(AutocompleteMatch match, |
682 WindowOpenDisposition disposition, | 683 WindowOpenDisposition disposition, |
683 const GURL& alternate_nav_url, | 684 const GURL& alternate_nav_url, |
684 const base::string16& pasted_text, | 685 const base::string16& pasted_text, |
685 size_t index) { | 686 size_t index) { |
686 const base::TimeTicks& now(base::TimeTicks::Now()); | 687 const base::TimeTicks& now(base::TimeTicks::Now()); |
687 base::TimeDelta elapsed_time_since_user_first_modified_omnibox( | 688 base::TimeDelta elapsed_time_since_user_first_modified_omnibox( |
688 now - time_user_first_modified_omnibox_); | 689 now - time_user_first_modified_omnibox_); |
(...skipping 19 matching lines...) Expand all Loading... | |
708 // (because the user does not modify the omnibox for ZeroSuggest), so for | 709 // (because the user does not modify the omnibox for ZeroSuggest), so for |
709 // those we set the elapsed times to something that will be ignored by | 710 // those we set the elapsed times to something that will be ignored by |
710 // metrics_log.cc. | 711 // metrics_log.cc. |
711 if (match.provider && | 712 if (match.provider && |
712 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST)) { | 713 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST)) { |
713 elapsed_time_since_user_first_modified_omnibox = | 714 elapsed_time_since_user_first_modified_omnibox = |
714 base::TimeDelta::FromMilliseconds(-1); | 715 base::TimeDelta::FromMilliseconds(-1); |
715 elapsed_time_since_last_change_to_default_match = | 716 elapsed_time_since_last_change_to_default_match = |
716 base::TimeDelta::FromMilliseconds(-1); | 717 base::TimeDelta::FromMilliseconds(-1); |
717 } | 718 } |
719 DCHECK_NE(OmniboxPopupModel::kNoMatch, index); | |
718 OmniboxLog log( | 720 OmniboxLog log( |
719 input_text, | 721 input_text, |
720 just_deleted_text_, | 722 just_deleted_text_, |
721 autocomplete_controller()->input().type(), | 723 autocomplete_controller()->input().type(), |
722 popup_model()->selected_line(), | 724 index, |
723 -1, // don't yet know tab ID; set later if appropriate | 725 -1, // don't yet know tab ID; set later if appropriate |
724 ClassifyPage(), | 726 ClassifyPage(), |
725 elapsed_time_since_user_first_modified_omnibox, | 727 elapsed_time_since_user_first_modified_omnibox, |
726 match.inline_autocompletion.length(), | 728 match.inline_autocompletion.length(), |
727 elapsed_time_since_last_change_to_default_match, | 729 elapsed_time_since_last_change_to_default_match, |
728 result()); | 730 result()); |
729 | 731 |
730 DCHECK(user_input_in_progress_ || (match.provider && | 732 DCHECK(user_input_in_progress_ || (match.provider && |
731 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST))) | 733 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST))) |
732 << "We didn't get here through the expected series of calls. " | 734 << "We didn't get here through the expected series of calls. " |
733 << "time_user_first_modified_omnibox_ is not set correctly and other " | 735 << "time_user_first_modified_omnibox_ is not set correctly and other " |
734 << "things may be wrong. Match provider: " | 736 << "things may be wrong. Match provider: " |
735 << (match.provider ? match.provider->GetName() : "NULL"); | 737 << (match.provider ? match.provider->GetName() : "NULL"); |
736 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >= | 738 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >= |
737 log.elapsed_time_since_last_change_to_default_match) | 739 log.elapsed_time_since_last_change_to_default_match) |
738 << "We should've got the notification that the user modified the " | 740 << "We should've got the notification that the user modified the " |
739 << "omnibox text at same time or before the most recent time the " | 741 << "omnibox text at same time or before the most recent time the " |
740 << "default match changed."; | 742 << "default match changed."; |
741 | 743 |
742 if (index != OmniboxPopupModel::kNoMatch) | |
743 log.selected_index = index; | |
744 | |
745 if ((disposition == CURRENT_TAB) && delegate_->CurrentPageExists()) { | 744 if ((disposition == CURRENT_TAB) && delegate_->CurrentPageExists()) { |
746 // If we know the destination is being opened in the current tab, | 745 // If we know the destination is being opened in the current tab, |
747 // we can easily get the tab ID. (If it's being opened in a new | 746 // we can easily get the tab ID. (If it's being opened in a new |
748 // tab, we don't know the tab ID yet.) | 747 // tab, we don't know the tab ID yet.) |
749 log.tab_id = delegate_->GetSessionID().id(); | 748 log.tab_id = delegate_->GetSessionID().id(); |
750 } | 749 } |
751 autocomplete_controller()->AddProvidersInfo(&log.providers_info); | 750 autocomplete_controller()->AddProvidersInfo(&log.providers_info); |
752 content::NotificationService::current()->Notify( | 751 content::NotificationService::current()->Notify( |
753 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 752 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
754 content::Source<Profile>(profile_), | 753 content::Source<Profile>(profile_), |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1442 // Update state and notify view if the omnibox has focus and the caret | 1441 // Update state and notify view if the omnibox has focus and the caret |
1443 // visibility changed. | 1442 // visibility changed. |
1444 const bool was_caret_visible = is_caret_visible(); | 1443 const bool was_caret_visible = is_caret_visible(); |
1445 focus_state_ = state; | 1444 focus_state_ = state; |
1446 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1445 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1447 is_caret_visible() != was_caret_visible) | 1446 is_caret_visible() != was_caret_visible) |
1448 view_->ApplyCaretVisibility(); | 1447 view_->ApplyCaretVisibility(); |
1449 | 1448 |
1450 delegate_->OnFocusChanged(focus_state_, reason); | 1449 delegate_->OnFocusChanged(focus_state_, reason); |
1451 } | 1450 } |
OLD | NEW |