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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_controller.cc

Issue 232023004: Ensures the autocomplete_controller input is saved and restored when changing tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed broken browser test. Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_controller.h" 5 #include "chrome/browser/ui/omnibox/omnibox_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 8 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
9 #include "chrome/browser/autocomplete/autocomplete_match.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "chrome/browser/autocomplete/search_provider.h" 10 #include "chrome/browser/autocomplete/search_provider.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 profile_(profile), 65 profile_(profile),
66 popup_(NULL), 66 popup_(NULL),
67 autocomplete_controller_(new AutocompleteController(profile, this, 67 autocomplete_controller_(new AutocompleteController(profile, this,
68 AutocompleteClassifier::kDefaultOmniboxProviders)) { 68 AutocompleteClassifier::kDefaultOmniboxProviders)) {
69 } 69 }
70 70
71 OmniboxController::~OmniboxController() { 71 OmniboxController::~OmniboxController() {
72 } 72 }
73 73
74 void OmniboxController::StartAutocomplete( 74 void OmniboxController::StartAutocomplete(
75 base::string16 user_text, 75 const AutocompleteInput& input) const {
76 size_t cursor_position,
77 const GURL& current_url,
78 AutocompleteInput::PageClassification current_page_classification,
79 bool prevent_inline_autocomplete,
80 bool prefer_keyword,
81 bool allow_exact_keyword_match) const {
82 ClearPopupKeywordMode(); 76 ClearPopupKeywordMode();
83 popup_->SetHoveredLine(OmniboxPopupModel::kNoMatch); 77 popup_->SetHoveredLine(OmniboxPopupModel::kNoMatch);
84 78
85 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as 79 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as
86 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. 80 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it.
87 autocomplete_controller_->Start(AutocompleteInput( 81 autocomplete_controller_->Start(input);
88 user_text, cursor_position, base::string16(), current_url,
89 current_page_classification, prevent_inline_autocomplete,
90 prefer_keyword, allow_exact_keyword_match, true));
91 } 82 }
92 83
93 void OmniboxController::OnResultChanged(bool default_match_changed) { 84 void OmniboxController::OnResultChanged(bool default_match_changed) {
94 const bool was_open = popup_->IsOpen(); 85 const bool was_open = popup_->IsOpen();
95 if (default_match_changed) { 86 if (default_match_changed) {
96 // The default match has changed, we need to let the OmniboxEditModel know 87 // The default match has changed, we need to let the OmniboxEditModel know
97 // about new inline autocomplete text (blue highlight). 88 // about new inline autocomplete text (blue highlight).
98 const AutocompleteResult& result = this->result(); 89 const AutocompleteResult& result = this->result();
99 const AutocompleteResult::const_iterator match(result.default_match()); 90 const AutocompleteResult::const_iterator match(result.default_match());
100 if (match != result.end()) { 91 if (match != result.end()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (profile_->GetNetworkPredictor()) { 142 if (profile_->GetNetworkPredictor()) {
152 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( 143 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl(
153 match.destination_url, 144 match.destination_url,
154 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); 145 predictors::AutocompleteActionPredictor::IsPreconnectable(match));
155 } 146 }
156 // We could prefetch the alternate nav URL, if any, but because there 147 // We could prefetch the alternate nav URL, if any, but because there
157 // can be many of these as a user types an initial series of characters, 148 // can be many of these as a user types an initial series of characters,
158 // the OS DNS cache could suffer eviction problems for minimal gain. 149 // the OS DNS cache could suffer eviction problems for minimal gain.
159 } 150 }
160 } 151 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_controller.h ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698