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

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

Issue 2046263002: Fix DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Created 4 years, 6 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
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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 input_text, base::string16::npos, std::string(), 643 input_text, base::string16::npos, std::string(),
644 // Somehow we can occasionally get here with no active tab. It's not 644 // Somehow we can occasionally get here with no active tab. It's not
645 // clear why this happens. 645 // clear why this happens.
646 client_->CurrentPageExists() ? client_->GetURL() : GURL(), ClassifyPage(), 646 client_->CurrentPageExists() ? client_->GetURL() : GURL(), ClassifyPage(),
647 false, false, true, true, false, client_->GetSchemeClassifier()); 647 false, false, true, true, false, client_->GetSchemeClassifier());
648 std::unique_ptr<OmniboxNavigationObserver> observer( 648 std::unique_ptr<OmniboxNavigationObserver> observer(
649 client_->CreateOmniboxNavigationObserver( 649 client_->CreateOmniboxNavigationObserver(
650 input_text, match, 650 input_text, match,
651 autocomplete_controller()->history_url_provider()->SuggestExactInput( 651 autocomplete_controller()->history_url_provider()->SuggestExactInput(
652 alternate_input, alternate_nav_url, 652 alternate_input, alternate_nav_url,
653 AutocompleteInput::HasHTTPScheme(input_text)))); 653 !AutocompleteInput::HasHTTPScheme(input_text))));
654 654
655 base::TimeDelta elapsed_time_since_last_change_to_default_match( 655 base::TimeDelta elapsed_time_since_last_change_to_default_match(
656 now - autocomplete_controller()->last_time_default_match_changed()); 656 now - autocomplete_controller()->last_time_default_match_changed());
657 DCHECK(match.provider); 657 DCHECK(match.provider);
658 // These elapsed times don't really make sense for ZeroSuggest matches 658 // These elapsed times don't really make sense for ZeroSuggest matches
659 // (because the user does not modify the omnibox for ZeroSuggest), so for 659 // (because the user does not modify the omnibox for ZeroSuggest), so for
660 // those we set the elapsed times to something that will be ignored by 660 // those we set the elapsed times to something that will be ignored by
661 // metrics_log.cc. They also don't necessarily make sense if the omnibox 661 // metrics_log.cc. They also don't necessarily make sense if the omnibox
662 // dropdown is closed or the user used a paste-and-go action. (In most 662 // dropdown is closed or the user used a paste-and-go action. (In most
663 // cases when this happens, the user never modified the omnibox.) 663 // cases when this happens, the user never modified the omnibox.)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 view_->RevertAll(); // Revert the box to its unedited state. 752 view_->RevertAll(); // Revert the box to its unedited state.
753 } 753 }
754 754
755 RecordPercentageMatchHistogram( 755 RecordPercentageMatchHistogram(
756 permanent_text_, current_text, 756 permanent_text_, current_text,
757 controller_->GetToolbarModel()->WouldReplaceURL(), 757 controller_->GetToolbarModel()->WouldReplaceURL(),
758 match.transition, view_->GetWidth()); 758 match.transition, view_->GetWidth());
759 759
760 // Track whether the destination URL sends us to a search results page 760 // Track whether the destination URL sends us to a search results page
761 // using the default search provider. 761 // using the default search provider.
762 if (client_->GetTemplateURLService() 762 TemplateURLService* template_url_service = client_->GetTemplateURLService();
Peter Kasting 2016/06/08 01:21:34 Another change to avoid segfaulting in test code.
763 ->IsSearchResultsPageFromDefaultSearchProvider( 763 if (template_url_service &&
764 match.destination_url)) { 764 template_url_service->IsSearchResultsPageFromDefaultSearchProvider(
765 match.destination_url)) {
765 base::RecordAction( 766 base::RecordAction(
766 base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP")); 767 base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP"));
767 } 768 }
768 769
769 if (match.destination_url.is_valid()) { 770 if (match.destination_url.is_valid()) {
770 // This calls RevertAll again. 771 // This calls RevertAll again.
771 base::AutoReset<bool> tmp(&in_revert_, true); 772 base::AutoReset<bool> tmp(&in_revert_, true);
772 controller_->OnAutocompleteAccept( 773 controller_->OnAutocompleteAccept(
773 match.destination_url, disposition, 774 match.destination_url, disposition,
774 ui::PageTransitionFromInt( 775 ui::PageTransitionFromInt(
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 // Update state and notify view if the omnibox has focus and the caret 1466 // Update state and notify view if the omnibox has focus and the caret
1466 // visibility changed. 1467 // visibility changed.
1467 const bool was_caret_visible = is_caret_visible(); 1468 const bool was_caret_visible = is_caret_visible();
1468 focus_state_ = state; 1469 focus_state_ = state;
1469 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1470 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1470 is_caret_visible() != was_caret_visible) 1471 is_caret_visible() != was_caret_visible)
1471 view_->ApplyCaretVisibility(); 1472 view_->ApplyCaretVisibility();
1472 1473
1473 client_->OnFocusChanged(focus_state_, reason); 1474 client_->OnFocusChanged(focus_state_, reason);
1474 } 1475 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698