Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/autocomplete/history_provider.h" | 5 #include "chrome/browser/autocomplete/history_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 else if (num_output_slashes > num_input_slashes) | 132 else if (num_output_slashes > num_input_slashes) |
| 133 output.erase(output.length() - num_output_slashes + num_input_slashes); | 133 output.erase(output.length() - num_output_slashes + num_input_slashes); |
| 134 | 134 |
| 135 url_parse::Parsed parts; | 135 url_parse::Parsed parts; |
| 136 URLFixerUpper::SegmentURL(output, &parts); | 136 URLFixerUpper::SegmentURL(output, &parts); |
| 137 // TODO: This function does not take into account the cursor position while | 137 // TODO: This function does not take into account the cursor position while |
| 138 // running various normalizations, including a call to FixupURL(). In order | 138 // running various normalizations, including a call to FixupURL(). In order |
| 139 // to make it work properly, we need to ensure that all logic above is | 139 // to make it work properly, we need to ensure that all logic above is |
| 140 // cursor-aware and offsets the input cursor accordingly. | 140 // cursor-aware and offsets the input cursor accordingly. |
| 141 // For now we simply pretend that the cursor was not set at all. | 141 // For now we simply pretend that the cursor was not set at all. |
| 142 // See http://crbug/163932 for more details. | 142 // Note that this containing function FixupUserInput() is only called |
| 143 // in HistoryURL provider, which is a provider that only does prefix-type | |
| 144 // matching using URLs from history. It does not use cursor position | |
| 145 // in its matching and indeed makes not make sense to do so. | |
|
Peter Kasting
2013/01/04 01:00:23
Wait, does that mean we shouldn't ever use cursor
Mark P
2013/01/04 01:10:46
I think you (and me) are right that all this code
Bart N.
2013/01/07 20:30:59
Mark, here is what I think.
If this function is i
Mark P
2013/01/07 22:17:37
Okay.
| |
| 143 input->UpdateText(output, string16::npos, parts); | 146 input->UpdateText(output, string16::npos, parts); |
| 144 return !output.empty(); | 147 return !output.empty(); |
| 145 } | 148 } |
| 146 | 149 |
| 147 // static | 150 // static |
| 148 size_t HistoryProvider::TrimHttpPrefix(string16* url) { | 151 size_t HistoryProvider::TrimHttpPrefix(string16* url) { |
| 149 // Find any "http:". | 152 // Find any "http:". |
| 150 if (!HasHTTPScheme(*url)) | 153 if (!HasHTTPScheme(*url)) |
| 151 return 0; | 154 return 0; |
| 152 size_t scheme_pos = | 155 size_t scheme_pos = |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 163 } | 166 } |
| 164 | 167 |
| 165 // static | 168 // static |
| 166 bool HistoryProvider::PreventInlineAutocomplete( | 169 bool HistoryProvider::PreventInlineAutocomplete( |
| 167 const AutocompleteInput& input) { | 170 const AutocompleteInput& input) { |
| 168 return input.prevent_inline_autocomplete() || | 171 return input.prevent_inline_autocomplete() || |
| 169 always_prevent_inline_autocomplete_ || | 172 always_prevent_inline_autocomplete_ || |
| 170 (!input.text().empty() && | 173 (!input.text().empty() && |
| 171 IsWhitespace(input.text()[input.text().length() - 1])); | 174 IsWhitespace(input.text()[input.text().length() - 1])); |
| 172 } | 175 } |
| OLD | NEW |