OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 AutocompleteClassifier::kDefaultOmniboxProviders)); | 33 AutocompleteClassifier::kDefaultOmniboxProviders)); |
34 } | 34 } |
35 | 35 |
36 OmniboxController::~OmniboxController() { | 36 OmniboxController::~OmniboxController() { |
37 } | 37 } |
38 | 38 |
39 void OmniboxController::StartAutocomplete( | 39 void OmniboxController::StartAutocomplete( |
40 string16 user_text, | 40 string16 user_text, |
41 size_t cursor_position, | 41 size_t cursor_position, |
42 const GURL& current_url, | 42 const GURL& current_url, |
43 AutocompleteInput::PageClassification current_page_classification, | 43 AutocompleteInput::OmniboxContext omnibox_context, |
44 bool prevent_inline_autocomplete, | 44 bool prevent_inline_autocomplete, |
45 bool prefer_keyword, | 45 bool prefer_keyword, |
46 bool allow_exact_keyword_match, | 46 bool allow_exact_keyword_match, |
47 int omnibox_start_margin) const { | 47 int omnibox_start_margin) const { |
48 ClearPopupKeywordMode(); | 48 ClearPopupKeywordMode(); |
49 popup_->SetHoveredLine(OmniboxPopupModel::kNoMatch); | 49 popup_->SetHoveredLine(OmniboxPopupModel::kNoMatch); |
50 | 50 |
51 if (chrome::IsInstantExtendedAPIEnabled()) { | 51 if (chrome::IsInstantExtendedAPIEnabled()) { |
52 autocomplete_controller_->search_provider()-> | 52 autocomplete_controller_->search_provider()-> |
53 SetOmniboxStartMargin(omnibox_start_margin); | 53 SetOmniboxStartMargin(omnibox_start_margin); |
54 } | 54 } |
55 | 55 |
56 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as | 56 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as |
57 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. | 57 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. |
58 autocomplete_controller_->Start(AutocompleteInput( | 58 autocomplete_controller_->Start(AutocompleteInput( |
59 user_text, cursor_position, string16(), current_url, | 59 user_text, cursor_position, string16(), current_url, |
60 current_page_classification, prevent_inline_autocomplete, | 60 omnibox_context, prevent_inline_autocomplete, |
61 prefer_keyword, allow_exact_keyword_match, | 61 prefer_keyword, allow_exact_keyword_match, |
62 AutocompleteInput::ALL_MATCHES)); | 62 AutocompleteInput::ALL_MATCHES)); |
63 } | 63 } |
64 | 64 |
65 void OmniboxController::OnResultChanged(bool default_match_changed) { | 65 void OmniboxController::OnResultChanged(bool default_match_changed) { |
66 const bool was_open = popup_->IsOpen(); | 66 const bool was_open = popup_->IsOpen(); |
67 if (default_match_changed) { | 67 if (default_match_changed) { |
68 // The default match has changed, we need to let the OmniboxEditModel know | 68 // The default match has changed, we need to let the OmniboxEditModel know |
69 // about new inline autocomplete text (blue highlight). | 69 // about new inline autocomplete text (blue highlight). |
70 const AutocompleteResult& result = this->result(); | 70 const AutocompleteResult& result = this->result(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (profile_->GetNetworkPredictor()) { | 109 if (profile_->GetNetworkPredictor()) { |
110 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 110 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
111 match.destination_url, | 111 match.destination_url, |
112 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); | 112 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); |
113 } | 113 } |
114 // We could prefetch the alternate nav URL, if any, but because there | 114 // We could prefetch the alternate nav URL, if any, but because there |
115 // can be many of these as a user types an initial series of characters, | 115 // can be many of these as a user types an initial series of characters, |
116 // the OS DNS cache could suffer eviction problems for minimal gain. | 116 // the OS DNS cache could suffer eviction problems for minimal gain. |
117 } | 117 } |
118 } | 118 } |
OLD | NEW |