OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 match.fill_into_edit.substr(inline_autocomplete_offset); | 1119 match.fill_into_edit.substr(inline_autocomplete_offset); |
1120 } | 1120 } |
1121 // An inlineable navsuggestion can only be the default match when there | 1121 // An inlineable navsuggestion can only be the default match when there |
1122 // is no keyword provider active, lest it appear first and break the user | 1122 // is no keyword provider active, lest it appear first and break the user |
1123 // out of keyword mode. It can also only be default if either the inline | 1123 // out of keyword mode. It can also only be default if either the inline |
1124 // autocompletion is empty or we're not preventing inline autocompletion. | 1124 // autocompletion is empty or we're not preventing inline autocompletion. |
1125 // Finally, if we have an inlineable navsuggestion with an inline completion | 1125 // Finally, if we have an inlineable navsuggestion with an inline completion |
1126 // that we're not preventing, make sure we didn't trim any whitespace. | 1126 // that we're not preventing, make sure we didn't trim any whitespace. |
1127 // We don't want to claim http://foo.com/bar is inlineable against the | 1127 // We don't want to claim http://foo.com/bar is inlineable against the |
1128 // input "foo.com/b ". | 1128 // input "foo.com/b ". |
1129 match.allowed_to_be_default_match = navigation.IsInlineable(input) && | 1129 match.allowed_to_be_default_match = (prefix != NULL) && |
1130 (providers_.GetKeywordProviderURL() == NULL) && | 1130 (providers_.GetKeywordProviderURL() == NULL) && |
1131 (match.inline_autocompletion.empty() || | 1131 (match.inline_autocompletion.empty() || |
1132 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace)); | 1132 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace)); |
| 1133 // Also allow a user's input to be marked as default if it would be fixed |
| 1134 // up to something equivalent to the URL-what-you-typed match. This handles |
| 1135 // cases like the user input containing a trailing colon on a raw hostname. |
| 1136 // (The URL-what-you-typed match will ignore the colon.) |
| 1137 match.ComputeStrippedDestinationURL(profile_); |
| 1138 if (AutocompleteMatch::GURLToStrippedGURL( |
| 1139 input_.canonicalized_url(), profile_, base::string16()) == |
| 1140 match.stripped_destination_url) |
| 1141 match.allowed_to_be_default_match = true; |
1133 | 1142 |
1134 match.contents = navigation.match_contents(); | 1143 match.contents = navigation.match_contents(); |
1135 match.contents_class = navigation.match_contents_class(); | 1144 match.contents_class = navigation.match_contents_class(); |
1136 match.description = navigation.description(); | 1145 match.description = navigation.description(); |
1137 AutocompleteMatch::ClassifyMatchInString(input, match.description, | 1146 AutocompleteMatch::ClassifyMatchInString(input, match.description, |
1138 ACMatchClassification::NONE, &match.description_class); | 1147 ACMatchClassification::NONE, &match.description_class); |
1139 | 1148 |
1140 match.RecordAdditionalInfo( | 1149 match.RecordAdditionalInfo( |
1141 kRelevanceFromServerKey, | 1150 kRelevanceFromServerKey, |
1142 navigation.relevance_from_server() ? kTrue : kFalse); | 1151 navigation.relevance_from_server() ? kTrue : kFalse); |
(...skipping 20 matching lines...) Expand all Loading... |
1163 // Make the base64 encoded value URL and filename safe(see RFC 3548). | 1172 // Make the base64 encoded value URL and filename safe(see RFC 3548). |
1164 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); | 1173 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); |
1165 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); | 1174 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); |
1166 } | 1175 } |
1167 | 1176 |
1168 // Extend expiration time another 60 seconds. | 1177 // Extend expiration time another 60 seconds. |
1169 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); | 1178 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); |
1170 | 1179 |
1171 return current_token_; | 1180 return current_token_; |
1172 } | 1181 } |
OLD | NEW |