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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 8872036: Profiles: Move NetworkActionPredictor to the ProfileKeyedService framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove dtor Created 9 years 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 | chrome/browser/autocomplete/network_action_predictor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete/autocomplete_edit.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
15 #include "chrome/browser/autocomplete/autocomplete_match.h" 15 #include "chrome/browser/autocomplete/autocomplete_match.h"
16 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 16 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
17 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" 17 #include "chrome/browser/autocomplete/autocomplete_popup_view.h"
18 #include "chrome/browser/autocomplete/keyword_provider.h" 18 #include "chrome/browser/autocomplete/keyword_provider.h"
19 #include "chrome/browser/autocomplete/network_action_predictor.h" 19 #include "chrome/browser/autocomplete/network_action_predictor.h"
20 #include "chrome/browser/autocomplete/network_action_predictor_factory.h"
20 #include "chrome/browser/autocomplete/search_provider.h" 21 #include "chrome/browser/autocomplete/search_provider.h"
21 #include "chrome/browser/bookmarks/bookmark_utils.h" 22 #include "chrome/browser/bookmarks/bookmark_utils.h"
22 #include "chrome/browser/command_updater.h" 23 #include "chrome/browser/command_updater.h"
23 #include "chrome/browser/extensions/extension_omnibox_api.h" 24 #include "chrome/browser/extensions/extension_omnibox_api.h"
24 #include "chrome/browser/google/google_url_tracker.h" 25 #include "chrome/browser/google/google_url_tracker.h"
25 #include "chrome/browser/instant/instant_controller.h" 26 #include "chrome/browser/instant/instant_controller.h"
26 #include "chrome/browser/net/predictor.h" 27 #include "chrome/browser/net/predictor.h"
27 #include "chrome/browser/net/url_fixer_upper.h" 28 #include "chrome/browser/net/url_fixer_upper.h"
28 #include "chrome/browser/prerender/prerender_field_trial.h" 29 #include "chrome/browser/prerender/prerender_field_trial.h"
29 #include "chrome/browser/prerender/prerender_manager.h" 30 #include "chrome/browser/prerender/prerender_manager.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 bool AutocompleteEditModel::AcceptCurrentInstantPreview() { 210 bool AutocompleteEditModel::AcceptCurrentInstantPreview() {
210 return InstantController::CommitIfCurrent(controller_->GetInstant()); 211 return InstantController::CommitIfCurrent(controller_->GetInstant());
211 } 212 }
212 213
213 void AutocompleteEditModel::OnChanged() { 214 void AutocompleteEditModel::OnChanged() {
214 const AutocompleteMatch current_match = CurrentMatch(); 215 const AutocompleteMatch current_match = CurrentMatch();
215 216
216 NetworkActionPredictor::Action recommended_action = 217 NetworkActionPredictor::Action recommended_action =
217 NetworkActionPredictor::ACTION_NONE; 218 NetworkActionPredictor::ACTION_NONE;
218 NetworkActionPredictor* network_action_predictor = user_input_in_progress() ? 219 NetworkActionPredictor* network_action_predictor =
219 profile_->GetNetworkActionPredictor() : NULL; 220 user_input_in_progress() ?
221 NetworkActionPredictorFactory::GetForProfile(profile_) : NULL;
220 if (network_action_predictor) { 222 if (network_action_predictor) {
221 network_action_predictor->RegisterTransitionalMatches(user_text_, 223 network_action_predictor->RegisterTransitionalMatches(user_text_,
222 result()); 224 result());
223 // Confer with the NetworkActionPredictor to determine what action, if any, 225 // Confer with the NetworkActionPredictor to determine what action, if any,
224 // we should take. Get the recommended action here even if we don't need it 226 // we should take. Get the recommended action here even if we don't need it
225 // so we can get stats for anyone who is opted in to UMA, but only get it if 227 // so we can get stats for anyone who is opted in to UMA, but only get it if
226 // the user has actually typed something to avoid constructing it before 228 // the user has actually typed something to avoid constructing it before
227 // it's needed. Note: This event is triggered as part of startup when the 229 // it's needed. Note: This event is triggered as part of startup when the
228 // initial tab transitions to the start page. 230 // initial tab transitions to the start page.
229 recommended_action = 231 recommended_action =
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 void AutocompleteEditModel::Revert() { 396 void AutocompleteEditModel::Revert() {
395 SetInputInProgress(false); 397 SetInputInProgress(false);
396 paste_state_ = NONE; 398 paste_state_ = NONE;
397 InternalSetUserText(string16()); 399 InternalSetUserText(string16());
398 keyword_.clear(); 400 keyword_.clear();
399 is_keyword_hint_ = false; 401 is_keyword_hint_ = false;
400 has_temporary_text_ = false; 402 has_temporary_text_ = false;
401 view_->SetWindowTextAndCaretPos(permanent_text_, 403 view_->SetWindowTextAndCaretPos(permanent_text_,
402 has_focus_ ? permanent_text_.length() : 0); 404 has_focus_ ? permanent_text_.length() : 0);
403 NetworkActionPredictor* network_action_predictor = 405 NetworkActionPredictor* network_action_predictor =
404 profile_->GetNetworkActionPredictor(); 406 NetworkActionPredictorFactory::GetForProfile(profile_);
405 if (network_action_predictor) 407 if (network_action_predictor)
406 network_action_predictor->ClearTransitionalMatches(); 408 network_action_predictor->ClearTransitionalMatches();
407 } 409 }
408 410
409 void AutocompleteEditModel::StartAutocomplete( 411 void AutocompleteEditModel::StartAutocomplete(
410 bool has_selected_text, 412 bool has_selected_text,
411 bool prevent_inline_autocomplete) const { 413 bool prevent_inline_autocomplete) const {
412 bool keyword_is_selected = KeywordIsSelected(); 414 bool keyword_is_selected = KeywordIsSelected();
413 popup_->SetHoveredLine(AutocompletePopupModel::kNoMatch); 415 popup_->SetHoveredLine(AutocompletePopupModel::kNoMatch);
414 // We don't explicitly clear AutocompletePopupModel::manually_selected_match, 416 // We don't explicitly clear AutocompletePopupModel::manually_selected_match,
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 // static 1084 // static
1083 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1085 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1084 switch (c) { 1086 switch (c) {
1085 case 0x0020: // Space 1087 case 0x0020: // Space
1086 case 0x3000: // Ideographic Space 1088 case 0x3000: // Ideographic Space
1087 return true; 1089 return true;
1088 default: 1090 default:
1089 return false; 1091 return false;
1090 } 1092 }
1091 } 1093 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/network_action_predictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698