Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: components/omnibox/browser/omnibox_edit_model.cc

Issue 2295043005: Skip omnibox default match update check when input is from omnibox focus (Closed)
Patch Set: revise comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 false, false, true, true, false, client_->GetSchemeClassifier()); 657 false, false, true, true, false, client_->GetSchemeClassifier());
658 std::unique_ptr<OmniboxNavigationObserver> observer( 658 std::unique_ptr<OmniboxNavigationObserver> observer(
659 client_->CreateOmniboxNavigationObserver( 659 client_->CreateOmniboxNavigationObserver(
660 input_text, match, 660 input_text, match,
661 autocomplete_controller()->history_url_provider()->SuggestExactInput( 661 autocomplete_controller()->history_url_provider()->SuggestExactInput(
662 alternate_input, alternate_nav_url, false))); 662 alternate_input, alternate_nav_url, false)));
663 663
664 base::TimeDelta elapsed_time_since_last_change_to_default_match( 664 base::TimeDelta elapsed_time_since_last_change_to_default_match(
665 now - autocomplete_controller()->last_time_default_match_changed()); 665 now - autocomplete_controller()->last_time_default_match_changed());
666 DCHECK(match.provider); 666 DCHECK(match.provider);
667 // These elapsed times don't really make sense for ZeroSuggest matches 667 // These elapsed times don't really make sense for matches that come from
668 // (because the user does not modify the omnibox for ZeroSuggest), so for 668 // omnibox focus (because the user did not modify the omnibox), so for those
669 // those we set the elapsed times to something that will be ignored by 669 // we set the elapsed times to something that will be ignored by
670 // metrics_log.cc. They also don't necessarily make sense if the omnibox 670 // metrics_log.cc. They also don't necessarily make sense if the omnibox
671 // dropdown is closed or the user used a paste-and-go action. (In most 671 // dropdown is closed or the user used a paste-and-go action. (In most
672 // cases when this happens, the user never modified the omnibox.) 672 // cases when this happens, the user never modified the omnibox.)
673 const bool popup_open = PopupIsOpen(); 673 const bool popup_open = PopupIsOpen();
674 if ((match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) || 674 if (input_.from_omnibox_focus() || !popup_open || !pasted_text.empty()) {
675 !popup_open || !pasted_text.empty()) {
676 const base::TimeDelta default_time_delta = 675 const base::TimeDelta default_time_delta =
677 base::TimeDelta::FromMilliseconds(-1); 676 base::TimeDelta::FromMilliseconds(-1);
678 elapsed_time_since_user_first_modified_omnibox = default_time_delta; 677 elapsed_time_since_user_first_modified_omnibox = default_time_delta;
679 elapsed_time_since_last_change_to_default_match = default_time_delta; 678 elapsed_time_since_last_change_to_default_match = default_time_delta;
680 } 679 }
681 // If the popup is closed or this is a paste-and-go action (meaning the 680 // If the popup is closed or this is a paste-and-go action (meaning the
682 // contents of the dropdown are ignored regardless), we record for logging 681 // contents of the dropdown are ignored regardless), we record for logging
683 // purposes a selected_index of 0 and a suggestion list as having a single 682 // purposes a selected_index of 0 and a suggestion list as having a single
684 // entry of the match used. 683 // entry of the match used.
685 const bool dropdown_ignored = !popup_open || !pasted_text.empty(); 684 const bool dropdown_ignored = !popup_open || !pasted_text.empty();
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 // Update state and notify view if the omnibox has focus and the caret 1501 // Update state and notify view if the omnibox has focus and the caret
1503 // visibility changed. 1502 // visibility changed.
1504 const bool was_caret_visible = is_caret_visible(); 1503 const bool was_caret_visible = is_caret_visible();
1505 focus_state_ = state; 1504 focus_state_ = state;
1506 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1505 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1507 is_caret_visible() != was_caret_visible) 1506 is_caret_visible() != was_caret_visible)
1508 view_->ApplyCaretVisibility(); 1507 view_->ApplyCaretVisibility();
1509 1508
1510 client_->OnFocusChanged(focus_state_, reason); 1509 client_->OnFocusChanged(focus_state_, reason);
1511 } 1510 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698