| 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_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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderListener* listener, | 474 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderListener* listener, |
| 475 Profile* profile) | 475 Profile* profile) |
| 476 : HistoryProvider(profile, AutocompleteProvider::TYPE_HISTORY_URL), | 476 : HistoryProvider(profile, AutocompleteProvider::TYPE_HISTORY_URL), |
| 477 listener_(listener), | 477 listener_(listener), |
| 478 params_(NULL) { | 478 params_(NULL) { |
| 479 // Initialize HUP scoring params based on the current experiment. | 479 // Initialize HUP scoring params based on the current experiment. |
| 480 OmniboxFieldTrial::GetExperimentalHUPScoringParams(&scoring_params_); | 480 OmniboxFieldTrial::GetExperimentalHUPScoringParams(&scoring_params_); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void HistoryURLProvider::Start(const AutocompleteInput& input, | 483 void HistoryURLProvider::Start(const AutocompleteInput& input, |
| 484 bool minimal_changes) { | 484 bool minimal_changes, |
| 485 bool called_due_to_focus) { |
| 485 // NOTE: We could try hard to do less work in the |minimal_changes| case | 486 // NOTE: We could try hard to do less work in the |minimal_changes| case |
| 486 // here; some clever caching would let us reuse the raw matches from the | 487 // here; some clever caching would let us reuse the raw matches from the |
| 487 // history DB without re-querying. However, we'd still have to go back to | 488 // history DB without re-querying. However, we'd still have to go back to |
| 488 // the history thread to mark these up properly, and if pass 2 is currently | 489 // the history thread to mark these up properly, and if pass 2 is currently |
| 489 // running, we'd need to wait for it to return to the main thread before | 490 // running, we'd need to wait for it to return to the main thread before |
| 490 // doing this (we can't just write new data for it to read due to thread | 491 // doing this (we can't just write new data for it to read due to thread |
| 491 // safety issues). At that point it's just as fast, and easier, to simply | 492 // safety issues). At that point it's just as fast, and easier, to simply |
| 492 // re-run the query from scratch and ignore |minimal_changes|. | 493 // re-run the query from scratch and ignore |minimal_changes|. |
| 493 | 494 |
| 494 // Cancel any in-progress query. | 495 // Cancel any in-progress query. |
| 495 Stop(false); | 496 Stop(false); |
| 496 | 497 |
| 497 matches_.clear(); | 498 matches_.clear(); |
| 498 | 499 |
| 499 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 500 if (called_due_to_focus || |
| 501 (input.type() == metrics::OmniboxInputType::INVALID) || |
| 500 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 502 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) |
| 501 return; | 503 return; |
| 502 | 504 |
| 503 // Do some fixup on the user input before matching against it, so we provide | 505 // Do some fixup on the user input before matching against it, so we provide |
| 504 // good results for local file paths, input with spaces, etc. | 506 // good results for local file paths, input with spaces, etc. |
| 505 const FixupReturn fixup_return(FixupUserInput(input)); | 507 const FixupReturn fixup_return(FixupUserInput(input)); |
| 506 if (!fixup_return.first) | 508 if (!fixup_return.first) |
| 507 return; | 509 return; |
| 508 url::Parsed parts; | 510 url::Parsed parts; |
| 509 url_fixer::SegmentURL(fixup_return.second, &parts); | 511 url_fixer::SegmentURL(fixup_return.second, &parts); |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1157 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
| 1156 match.contents.length(), ACMatchClassification::URL, | 1158 match.contents.length(), ACMatchClassification::URL, |
| 1157 &match.contents_class); | 1159 &match.contents_class); |
| 1158 } | 1160 } |
| 1159 match.description = info.title(); | 1161 match.description = info.title(); |
| 1160 match.description_class = | 1162 match.description_class = |
| 1161 ClassifyDescription(params.input.text(), match.description); | 1163 ClassifyDescription(params.input.text(), match.description); |
| 1162 RecordAdditionalInfoFromUrlRow(info, &match); | 1164 RecordAdditionalInfoFromUrlRow(info, &match); |
| 1163 return match; | 1165 return match; |
| 1164 } | 1166 } |
| OLD | NEW |