Chromium Code Reviews| 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 | 72 // 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 | 73 // the time because there is a possibility that the *match prefix differs |
| 76 // update this here. | 74 // from the omnibox content (e.g., swapping spaces for %20). Hence, |
| 75 // we need to replace it. | |
|
Peter Kasting
2013/07/16 21:48:50
I'm still confused by all this (sorry). Why is it
beaudoin
2013/07/18 17:50:18
omnibox_edit_model.cc uses current_match() quite a
| |
| 77 current_match_.fill_into_edit = omnibox_edit_model_->user_text(); | 76 current_match_.fill_into_edit = omnibox_edit_model_->user_text(); |
| 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_)) | 77 if (!prerender::IsOmniboxEnabled(profile_)) |
| 88 DoPreconnect(*match); | 78 DoPreconnect(*match); |
| 89 omnibox_edit_model_->OnCurrentMatchChanged(); | 79 omnibox_edit_model_->OnCurrentMatchChanged(); |
| 90 } else { | 80 } else { |
| 91 InvalidateCurrentMatch(); | 81 InvalidateCurrentMatch(); |
| 92 popup_->OnResultChanged(); | 82 popup_->OnResultChanged(); |
| 93 omnibox_edit_model_->OnPopupDataChanged(string16(), NULL, string16(), | 83 omnibox_edit_model_->OnPopupDataChanged(string16(), NULL, string16(), |
| 94 false); | 84 false); |
| 95 } | 85 } |
| 96 } else { | 86 } else { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 122 if (profile_->GetNetworkPredictor()) { | 112 if (profile_->GetNetworkPredictor()) { |
| 123 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 113 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 124 match.destination_url, | 114 match.destination_url, |
| 125 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); | 115 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); |
| 126 } | 116 } |
| 127 // We could prefetch the alternate nav URL, if any, but because there | 117 // 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, | 118 // 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. | 119 // the OS DNS cache could suffer eviction problems for minimal gain. |
| 130 } | 120 } |
| 131 } | 121 } |
| OLD | NEW |