Chromium Code Reviews| 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 677 view_->OpenMatch(match, disposition, alternate_nav_url, base::string16(), | 677 view_->OpenMatch( |
| 678 OmniboxPopupModel::kNoMatch); | 678 match, disposition, alternate_nav_url, base::string16(), |
| 679 popup_model() ? | |
|
Peter Kasting
2014/04/08 23:02:20
Can we really have no popup model here? Maybe in
Mark P
2014/04/08 23:05:01
I didn't actually try skipping this test. Do you
Mark P
2014/04/09 00:16:04
Done. Running it through the try servers now. (I
| |
| 680 popup_model()->selected_line() : OmniboxPopupModel::kNoMatch); | |
| 679 } | 681 } |
| 680 | 682 |
| 681 void OmniboxEditModel::OpenMatch(AutocompleteMatch match, | 683 void OmniboxEditModel::OpenMatch(AutocompleteMatch match, |
| 682 WindowOpenDisposition disposition, | 684 WindowOpenDisposition disposition, |
| 683 const GURL& alternate_nav_url, | 685 const GURL& alternate_nav_url, |
| 684 const base::string16& pasted_text, | 686 const base::string16& pasted_text, |
| 685 size_t index) { | 687 size_t index) { |
| 686 const base::TimeTicks& now(base::TimeTicks::Now()); | 688 const base::TimeTicks& now(base::TimeTicks::Now()); |
| 687 base::TimeDelta elapsed_time_since_user_first_modified_omnibox( | 689 base::TimeDelta elapsed_time_since_user_first_modified_omnibox( |
| 688 now - time_user_first_modified_omnibox_); | 690 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 | 710 // (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 | 711 // those we set the elapsed times to something that will be ignored by |
| 710 // metrics_log.cc. | 712 // metrics_log.cc. |
| 711 if (match.provider && | 713 if (match.provider && |
| 712 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST)) { | 714 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST)) { |
| 713 elapsed_time_since_user_first_modified_omnibox = | 715 elapsed_time_since_user_first_modified_omnibox = |
| 714 base::TimeDelta::FromMilliseconds(-1); | 716 base::TimeDelta::FromMilliseconds(-1); |
| 715 elapsed_time_since_last_change_to_default_match = | 717 elapsed_time_since_last_change_to_default_match = |
| 716 base::TimeDelta::FromMilliseconds(-1); | 718 base::TimeDelta::FromMilliseconds(-1); |
| 717 } | 719 } |
| 720 DCHECK_NE(OmniboxPopupModel::kNoMatch, index); | |
| 718 OmniboxLog log( | 721 OmniboxLog log( |
| 719 input_text, | 722 input_text, |
| 720 just_deleted_text_, | 723 just_deleted_text_, |
| 721 autocomplete_controller()->input().type(), | 724 autocomplete_controller()->input().type(), |
| 722 popup_model()->selected_line(), | 725 index, |
| 723 -1, // don't yet know tab ID; set later if appropriate | 726 -1, // don't yet know tab ID; set later if appropriate |
| 724 ClassifyPage(), | 727 ClassifyPage(), |
| 725 elapsed_time_since_user_first_modified_omnibox, | 728 elapsed_time_since_user_first_modified_omnibox, |
| 726 match.inline_autocompletion.length(), | 729 match.inline_autocompletion.length(), |
| 727 elapsed_time_since_last_change_to_default_match, | 730 elapsed_time_since_last_change_to_default_match, |
| 728 result()); | 731 result()); |
| 729 | 732 |
| 730 DCHECK(user_input_in_progress_ || (match.provider && | 733 DCHECK(user_input_in_progress_ || (match.provider && |
| 731 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST))) | 734 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST))) |
| 732 << "We didn't get here through the expected series of calls. " | 735 << "We didn't get here through the expected series of calls. " |
| 733 << "time_user_first_modified_omnibox_ is not set correctly and other " | 736 << "time_user_first_modified_omnibox_ is not set correctly and other " |
| 734 << "things may be wrong. Match provider: " | 737 << "things may be wrong. Match provider: " |
| 735 << (match.provider ? match.provider->GetName() : "NULL"); | 738 << (match.provider ? match.provider->GetName() : "NULL"); |
| 736 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >= | 739 DCHECK(log.elapsed_time_since_user_first_modified_omnibox >= |
| 737 log.elapsed_time_since_last_change_to_default_match) | 740 log.elapsed_time_since_last_change_to_default_match) |
| 738 << "We should've got the notification that the user modified the " | 741 << "We should've got the notification that the user modified the " |
| 739 << "omnibox text at same time or before the most recent time the " | 742 << "omnibox text at same time or before the most recent time the " |
| 740 << "default match changed."; | 743 << "default match changed."; |
| 741 | 744 |
| 742 if (index != OmniboxPopupModel::kNoMatch) | |
| 743 log.selected_index = index; | |
| 744 | |
| 745 if ((disposition == CURRENT_TAB) && delegate_->CurrentPageExists()) { | 745 if ((disposition == CURRENT_TAB) && delegate_->CurrentPageExists()) { |
| 746 // If we know the destination is being opened in the current tab, | 746 // 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 | 747 // 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.) | 748 // tab, we don't know the tab ID yet.) |
| 749 log.tab_id = delegate_->GetSessionID().id(); | 749 log.tab_id = delegate_->GetSessionID().id(); |
| 750 } | 750 } |
| 751 autocomplete_controller()->AddProvidersInfo(&log.providers_info); | 751 autocomplete_controller()->AddProvidersInfo(&log.providers_info); |
| 752 content::NotificationService::current()->Notify( | 752 content::NotificationService::current()->Notify( |
| 753 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 753 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
| 754 content::Source<Profile>(profile_), | 754 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 | 1442 // Update state and notify view if the omnibox has focus and the caret |
| 1443 // visibility changed. | 1443 // visibility changed. |
| 1444 const bool was_caret_visible = is_caret_visible(); | 1444 const bool was_caret_visible = is_caret_visible(); |
| 1445 focus_state_ = state; | 1445 focus_state_ = state; |
| 1446 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1446 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1447 is_caret_visible() != was_caret_visible) | 1447 is_caret_visible() != was_caret_visible) |
| 1448 view_->ApplyCaretVisibility(); | 1448 view_->ApplyCaretVisibility(); |
| 1449 | 1449 |
| 1450 delegate_->OnFocusChanged(focus_state_, reason); | 1450 delegate_->OnFocusChanged(focus_state_, reason); |
| 1451 } | 1451 } |
| OLD | NEW |