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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 62 |
63 void OmniboxController::OnResultChanged(bool default_match_changed) { | 63 void OmniboxController::OnResultChanged(bool default_match_changed) { |
64 const bool was_open = popup_->IsOpen(); | 64 const bool was_open = popup_->IsOpen(); |
65 if (default_match_changed) { | 65 if (default_match_changed) { |
66 // The default match has changed, we need to let the OmniboxEditModel know | 66 // The default match has changed, we need to let the OmniboxEditModel know |
67 // about new inline autocomplete text (blue highlight). | 67 // about new inline autocomplete text (blue highlight). |
68 const AutocompleteResult& result = this->result(); | 68 const AutocompleteResult& result = this->result(); |
69 const AutocompleteResult::const_iterator match(result.default_match()); | 69 const AutocompleteResult::const_iterator match(result.default_match()); |
70 if (match != result.end()) { | 70 if (match != result.end()) { |
71 current_match_ = *match; | 71 current_match_ = *match; |
72 // TODO(beaudoin): This code could be made simpler if AutocompleteMatch | |
73 // had an |inline_autocompletion| instead of |inline_autocomplete_offset|. | |
74 // The |fill_into_edit| we get may not match what we have in the view at | |
75 // that time. We're only interested in the inline_autocomplete part, so | |
76 // update this here. | |
77 current_match_.fill_into_edit = omnibox_edit_model_->user_text(); | |
beaudoin
2013/07/16 20:07:28
In fact you need to reset the fill_into_edit with
Mark P
2013/07/16 20:11:50
Done.
| |
78 if (match->inline_autocomplete_offset < match->fill_into_edit.length()) { | |
79 current_match_.inline_autocomplete_offset = | |
80 current_match_.fill_into_edit.length(); | |
81 current_match_.fill_into_edit += match->fill_into_edit.substr( | |
82 match->inline_autocomplete_offset); | |
83 } else { | |
84 current_match_.inline_autocomplete_offset = string16::npos; | |
85 } | |
86 | |
87 if (!prerender::IsOmniboxEnabled(profile_)) | 72 if (!prerender::IsOmniboxEnabled(profile_)) |
88 DoPreconnect(*match); | 73 DoPreconnect(*match); |
89 omnibox_edit_model_->OnCurrentMatchChanged(); | 74 omnibox_edit_model_->OnCurrentMatchChanged(); |
90 } else { | 75 } else { |
91 InvalidateCurrentMatch(); | 76 InvalidateCurrentMatch(); |
92 popup_->OnResultChanged(); | 77 popup_->OnResultChanged(); |
93 omnibox_edit_model_->OnPopupDataChanged(string16(), NULL, string16(), | 78 omnibox_edit_model_->OnPopupDataChanged(string16(), NULL, string16(), |
94 false); | 79 false); |
95 } | 80 } |
96 } else { | 81 } else { |
(...skipping 25 matching lines...) Expand all Loading... | |
122 if (profile_->GetNetworkPredictor()) { | 107 if (profile_->GetNetworkPredictor()) { |
123 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 108 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
124 match.destination_url, | 109 match.destination_url, |
125 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); | 110 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); |
126 } | 111 } |
127 // We could prefetch the alternate nav URL, if any, but because there | 112 // We could prefetch the alternate nav URL, if any, but because there |
128 // can be many of these as a user types an initial series of characters, | 113 // can be many of these as a user types an initial series of characters, |
129 // the OS DNS cache could suffer eviction problems for minimal gain. | 114 // the OS DNS cache could suffer eviction problems for minimal gain. |
130 } | 115 } |
131 } | 116 } |
OLD | NEW |