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

Side by Side Diff: chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc

Issue 149683005: about:omnibox - add current page classification to possible settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/webui/omnibox/omnibox_ui_handler.h" 5 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.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/bind.h" 10 #include "base/bind.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (!history_service) 166 if (!history_service)
167 return false; 167 return false;
168 history::URLDatabase* url_db = history_service->InMemoryDatabase(); 168 history::URLDatabase* url_db = history_service->InMemoryDatabase();
169 if (!url_db) 169 if (!url_db)
170 return false; 170 return false;
171 *is_typed_host = url_db->IsTypedHost(base::UTF16ToUTF8(host)); 171 *is_typed_host = url_db->IsTypedHost(base::UTF16ToUTF8(host));
172 return true; 172 return true;
173 } 173 }
174 174
175 void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) { 175 void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) {
176 DCHECK_EQ(4u, input->GetSize()); 176 DCHECK_EQ(5u, input->GetSize());
177 base::string16 input_string; 177 base::string16 input_string;
178 bool return_val = input->GetString(0, &input_string); 178 bool return_val = input->GetString(0, &input_string);
179 DCHECK(return_val); 179 DCHECK(return_val);
180 int cursor_position; 180 int cursor_position;
181 return_val = input->GetInteger(1, &cursor_position); 181 return_val = input->GetInteger(1, &cursor_position);
182 DCHECK(return_val); 182 DCHECK(return_val);
183 bool prevent_inline_autocomplete; 183 bool prevent_inline_autocomplete;
184 return_val = input->GetBoolean(2, &prevent_inline_autocomplete); 184 return_val = input->GetBoolean(2, &prevent_inline_autocomplete);
185 DCHECK(return_val); 185 DCHECK(return_val);
186 bool prefer_keyword; 186 bool prefer_keyword;
187 return_val = input->GetBoolean(3, &prefer_keyword); 187 return_val = input->GetBoolean(3, &prefer_keyword);
188 DCHECK(return_val); 188 DCHECK(return_val);
189 int current_page_classification;
190 return_val = input->GetInteger(4, &current_page_classification);
191 DCHECK(return_val);
189 // Reset the controller. If we don't do this, then the 192 // Reset the controller. If we don't do this, then the
190 // AutocompleteController might inappropriately set its |minimal_changes| 193 // AutocompleteController might inappropriately set its |minimal_changes|
191 // variable (or something else) and some providers will short-circuit 194 // variable (or something else) and some providers will short-circuit
192 // important logic and return stale results. In short, we want the 195 // important logic and return stale results. In short, we want the
193 // actual results to not depend on the state of the previous request. 196 // actual results to not depend on the state of the previous request.
194 ResetController(); 197 ResetController();
195 time_omnibox_started_ = base::Time::Now(); 198 time_omnibox_started_ = base::Time::Now();
196 controller_->Start(AutocompleteInput( 199 controller_->Start(AutocompleteInput(
197 input_string, 200 input_string,
198 cursor_position, 201 cursor_position,
199 base::string16(), // user's desired tld (top-level domain) 202 base::string16(), // user's desired tld (top-level domain)
200 GURL(), 203 GURL(),
201 AutocompleteInput::INVALID_SPEC, 204 static_cast<AutocompleteInput::PageClassification>(
205 current_page_classification),
202 prevent_inline_autocomplete, 206 prevent_inline_autocomplete,
203 prefer_keyword, 207 prefer_keyword,
204 true, // allow exact keyword matches 208 true, // allow exact keyword matches
205 AutocompleteInput::ALL_MATCHES)); // want all matches 209 AutocompleteInput::ALL_MATCHES)); // want all matches
206 } 210 }
207 211
208 void OmniboxUIHandler::ResetController() { 212 void OmniboxUIHandler::ResetController() {
209 controller_.reset(new AutocompleteController(profile_, this, 213 controller_.reset(new AutocompleteController(profile_, this,
210 AutocompleteClassifier::kDefaultOmniboxProviders)); 214 AutocompleteClassifier::kDefaultOmniboxProviders));
211 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698