| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 const size_t num_output_slashes = | 127 const size_t num_output_slashes = |
| 128 (last_output_nonslash == string16::npos) ? | 128 (last_output_nonslash == string16::npos) ? |
| 129 output.length() : (output.length() - 1 - last_output_nonslash); | 129 output.length() : (output.length() - 1 - last_output_nonslash); |
| 130 if (num_output_slashes < num_input_slashes) | 130 if (num_output_slashes < num_input_slashes) |
| 131 output.append(num_input_slashes - num_output_slashes, '/'); | 131 output.append(num_input_slashes - num_output_slashes, '/'); |
| 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 | |
| 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 | |
| 140 // cursor-aware and offsets the input cursor accordingly. | |
| 141 // For now we simply pretend that the cursor was not set at all. | |
| 142 // See http://crbug/163932 for more details. | |
| 143 input->UpdateText(output, string16::npos, parts); | 137 input->UpdateText(output, string16::npos, parts); |
| 144 return !output.empty(); | 138 return !output.empty(); |
| 145 } | 139 } |
| 146 | 140 |
| 147 // static | 141 // static |
| 148 size_t HistoryProvider::TrimHttpPrefix(string16* url) { | 142 size_t HistoryProvider::TrimHttpPrefix(string16* url) { |
| 149 // Find any "http:". | 143 // Find any "http:". |
| 150 if (!HasHTTPScheme(*url)) | 144 if (!HasHTTPScheme(*url)) |
| 151 return 0; | 145 return 0; |
| 152 size_t scheme_pos = | 146 size_t scheme_pos = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 163 } | 157 } |
| 164 | 158 |
| 165 // static | 159 // static |
| 166 bool HistoryProvider::PreventInlineAutocomplete( | 160 bool HistoryProvider::PreventInlineAutocomplete( |
| 167 const AutocompleteInput& input) { | 161 const AutocompleteInput& input) { |
| 168 return input.prevent_inline_autocomplete() || | 162 return input.prevent_inline_autocomplete() || |
| 169 always_prevent_inline_autocomplete_ || | 163 always_prevent_inline_autocomplete_ || |
| 170 (!input.text().empty() && | 164 (!input.text().empty() && |
| 171 IsWhitespace(input.text()[input.text().length() - 1])); | 165 IsWhitespace(input.text()[input.text().length() - 1])); |
| 172 } | 166 } |
| OLD | NEW |