| 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 "components/omnibox/browser/omnibox_edit_model.h" | 5 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 AutocompleteInput alternate_input( | 662 AutocompleteInput alternate_input( |
| 663 input_text, base::string16::npos, std::string(), | 663 input_text, base::string16::npos, std::string(), |
| 664 // Somehow we can occasionally get here with no active tab. It's not | 664 // Somehow we can occasionally get here with no active tab. It's not |
| 665 // clear why this happens. | 665 // clear why this happens. |
| 666 client_->CurrentPageExists() ? client_->GetURL() : GURL(), ClassifyPage(), | 666 client_->CurrentPageExists() ? client_->GetURL() : GURL(), ClassifyPage(), |
| 667 false, false, true, true, false, client_->GetSchemeClassifier()); | 667 false, false, true, true, false, client_->GetSchemeClassifier()); |
| 668 std::unique_ptr<OmniboxNavigationObserver> observer( | 668 std::unique_ptr<OmniboxNavigationObserver> observer( |
| 669 client_->CreateOmniboxNavigationObserver( | 669 client_->CreateOmniboxNavigationObserver( |
| 670 input_text, match, | 670 input_text, match, |
| 671 autocomplete_controller()->history_url_provider()->SuggestExactInput( | 671 autocomplete_controller()->history_url_provider()->SuggestExactInput( |
| 672 alternate_input, alternate_nav_url, | 672 alternate_input, alternate_nav_url, false))); |
| 673 AutocompleteInput::HasHTTPScheme(input_text)))); | |
| 674 | 673 |
| 675 base::TimeDelta elapsed_time_since_last_change_to_default_match( | 674 base::TimeDelta elapsed_time_since_last_change_to_default_match( |
| 676 now - autocomplete_controller()->last_time_default_match_changed()); | 675 now - autocomplete_controller()->last_time_default_match_changed()); |
| 677 DCHECK(match.provider); | 676 DCHECK(match.provider); |
| 678 // These elapsed times don't really make sense for ZeroSuggest matches | 677 // These elapsed times don't really make sense for ZeroSuggest matches |
| 679 // (because the user does not modify the omnibox for ZeroSuggest), so for | 678 // (because the user does not modify the omnibox for ZeroSuggest), so for |
| 680 // those we set the elapsed times to something that will be ignored by | 679 // those we set the elapsed times to something that will be ignored by |
| 681 // metrics_log.cc. They also don't necessarily make sense if the omnibox | 680 // metrics_log.cc. They also don't necessarily make sense if the omnibox |
| 682 // dropdown is closed or the user used a paste-and-go action. (In most | 681 // dropdown is closed or the user used a paste-and-go action. (In most |
| 683 // cases when this happens, the user never modified the omnibox.) | 682 // cases when this happens, the user never modified the omnibox.) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 view_->RevertAll(); // Revert the box to its unedited state. | 771 view_->RevertAll(); // Revert the box to its unedited state. |
| 773 } | 772 } |
| 774 | 773 |
| 775 RecordPercentageMatchHistogram( | 774 RecordPercentageMatchHistogram( |
| 776 permanent_text_, current_text, | 775 permanent_text_, current_text, |
| 777 controller_->GetToolbarModel()->WouldReplaceURL(), | 776 controller_->GetToolbarModel()->WouldReplaceURL(), |
| 778 match.transition, view_->GetWidth()); | 777 match.transition, view_->GetWidth()); |
| 779 | 778 |
| 780 // Track whether the destination URL sends us to a search results page | 779 // Track whether the destination URL sends us to a search results page |
| 781 // using the default search provider. | 780 // using the default search provider. |
| 782 if (client_->GetTemplateURLService() | 781 TemplateURLService* template_url_service = client_->GetTemplateURLService(); |
| 783 ->IsSearchResultsPageFromDefaultSearchProvider( | 782 if (template_url_service && |
| 784 match.destination_url)) { | 783 template_url_service->IsSearchResultsPageFromDefaultSearchProvider( |
| 784 match.destination_url)) { |
| 785 base::RecordAction( | 785 base::RecordAction( |
| 786 base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP")); | 786 base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP")); |
| 787 } | 787 } |
| 788 | 788 |
| 789 if (match.destination_url.is_valid()) { | 789 if (match.destination_url.is_valid()) { |
| 790 // This calls RevertAll again. | 790 // This calls RevertAll again. |
| 791 base::AutoReset<bool> tmp(&in_revert_, true); | 791 base::AutoReset<bool> tmp(&in_revert_, true); |
| 792 controller_->OnAutocompleteAccept( | 792 controller_->OnAutocompleteAccept( |
| 793 match.destination_url, disposition, | 793 match.destination_url, disposition, |
| 794 ui::PageTransitionFromInt( | 794 ui::PageTransitionFromInt( |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 // Update state and notify view if the omnibox has focus and the caret | 1526 // Update state and notify view if the omnibox has focus and the caret |
| 1527 // visibility changed. | 1527 // visibility changed. |
| 1528 const bool was_caret_visible = is_caret_visible(); | 1528 const bool was_caret_visible = is_caret_visible(); |
| 1529 focus_state_ = state; | 1529 focus_state_ = state; |
| 1530 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1530 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1531 is_caret_visible() != was_caret_visible) | 1531 is_caret_visible() != was_caret_visible) |
| 1532 view_->ApplyCaretVisibility(); | 1532 view_->ApplyCaretVisibility(); |
| 1533 | 1533 |
| 1534 client_->OnFocusChanged(focus_state_, reason); | 1534 client_->OnFocusChanged(focus_state_, reason); |
| 1535 } | 1535 } |
| OLD | NEW |