OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 // * and the user has specified a TLD, | 396 // * and the user has specified a TLD, |
397 // * and the input _without_ the TLD _is_ in the history DB, | 397 // * and the input _without_ the TLD _is_ in the history DB, |
398 // * ...then just before pressing "ctrl" the best match we supplied was the | 398 // * ...then just before pressing "ctrl" the best match we supplied was the |
399 // what-you-typed match, so stick with it by promoting this. | 399 // what-you-typed match, so stick with it by promoting this. |
400 history::URLRow info; | 400 history::URLRow info; |
401 if (!db->GetRowForURL(match->destination_url, &info)) { | 401 if (!db->GetRowForURL(match->destination_url, &info)) { |
402 if (input.desired_tld().empty()) | 402 if (input.desired_tld().empty()) |
403 return false; | 403 return false; |
404 GURL destination_url(URLFixerUpper::FixupURL(WideToUTF8(input.text()), | 404 GURL destination_url(URLFixerUpper::FixupURL(WideToUTF8(input.text()), |
405 std::string())); | 405 std::string())); |
406 if (!db->GetRowForURL(destination_url, &info)) | 406 if (!db->GetRowForURL(destination_url, NULL)) |
407 return false; | 407 return false; |
| 408 |
| 409 // If we got here, then we hit the tricky corner case. Make sure that |
| 410 // |info| corresponds to the right URL. |
| 411 info = history::URLRow(match->destination_url); |
408 } else { | 412 } else { |
409 // We have data for this match, use it. | 413 // We have data for this match, use it. |
410 match->deletable = true; | 414 match->deletable = true; |
411 match->description = UTF16ToWide(info.title()); | 415 match->description = UTF16ToWide(info.title()); |
412 AutocompleteMatch::ClassifyMatchInString(input.text(), | 416 AutocompleteMatch::ClassifyMatchInString(input.text(), |
413 UTF16ToWide(info.title()), | 417 UTF16ToWide(info.title()), |
414 ACMatchClassification::NONE, &match->description_class); | 418 ACMatchClassification::NONE, &match->description_class); |
415 } | 419 } |
416 | 420 |
417 // Promote as an exact match. | 421 // Promote as an exact match. |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 &match.contents_class); | 906 &match.contents_class); |
903 } | 907 } |
904 match.description = UTF16ToWide(info.title()); | 908 match.description = UTF16ToWide(info.title()); |
905 AutocompleteMatch::ClassifyMatchInString(params->input.text(), | 909 AutocompleteMatch::ClassifyMatchInString(params->input.text(), |
906 UTF16ToWide(info.title()), | 910 UTF16ToWide(info.title()), |
907 ACMatchClassification::NONE, | 911 ACMatchClassification::NONE, |
908 &match.description_class); | 912 &match.description_class); |
909 | 913 |
910 return match; | 914 return match; |
911 } | 915 } |
OLD | NEW |