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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // 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 |
487 // 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 |
488 // 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 |
489 // 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 |
490 // 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 |
491 // 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 |
492 // 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 |
493 // re-run the query from scratch and ignore |minimal_changes|. | 493 // re-run the query from scratch and ignore |minimal_changes|. |
494 | 494 |
495 // Cancel any in-progress query. | 495 // Cancel any in-progress query. |
496 Stop(false); | 496 Stop(false, false); |
497 | 497 |
498 matches_.clear(); | 498 matches_.clear(); |
499 | 499 |
500 if (called_due_to_focus || | 500 if (called_due_to_focus || |
501 (input.type() == metrics::OmniboxInputType::INVALID) || | 501 (input.type() == metrics::OmniboxInputType::INVALID) || |
502 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 502 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) |
503 return; | 503 return; |
504 | 504 |
505 // 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 |
506 // good results for local file paths, input with spaces, etc. | 506 // good results for local file paths, input with spaces, etc. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 // where we can read the full on-disk DB. | 577 // where we can read the full on-disk DB. |
578 if (input.want_asynchronous_matches()) { | 578 if (input.want_asynchronous_matches()) { |
579 done_ = false; | 579 done_ = false; |
580 params_ = params.release(); // This object will be destroyed in | 580 params_ = params.release(); // This object will be destroyed in |
581 // QueryComplete() once we're done with it. | 581 // QueryComplete() once we're done with it. |
582 history_service->ScheduleAutocomplete( | 582 history_service->ScheduleAutocomplete( |
583 base::Bind(&HistoryURLProvider::ExecuteWithDB, this, params_)); | 583 base::Bind(&HistoryURLProvider::ExecuteWithDB, this, params_)); |
584 } | 584 } |
585 } | 585 } |
586 | 586 |
587 void HistoryURLProvider::Stop(bool clear_cached_results) { | 587 void HistoryURLProvider::Stop(bool clear_cached_results, |
| 588 bool due_to_user_inactivity) { |
588 done_ = true; | 589 done_ = true; |
589 | 590 |
590 if (params_) | 591 if (params_) |
591 params_->cancel_flag.Set(); | 592 params_->cancel_flag.Set(); |
592 } | 593 } |
593 | 594 |
594 AutocompleteMatch HistoryURLProvider::SuggestExactInput( | 595 AutocompleteMatch HistoryURLProvider::SuggestExactInput( |
595 const base::string16& text, | 596 const base::string16& text, |
596 const GURL& destination_url, | 597 const GURL& destination_url, |
597 bool trim_http) { | 598 bool trim_http) { |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1153 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
1153 match.contents.length(), ACMatchClassification::URL, | 1154 match.contents.length(), ACMatchClassification::URL, |
1154 &match.contents_class); | 1155 &match.contents_class); |
1155 } | 1156 } |
1156 match.description = info.title(); | 1157 match.description = info.title(); |
1157 match.description_class = | 1158 match.description_class = |
1158 ClassifyDescription(params.input.text(), match.description); | 1159 ClassifyDescription(params.input.text(), match.description); |
1159 RecordAdditionalInfoFromUrlRow(info, &match); | 1160 RecordAdditionalInfoFromUrlRow(info, &match); |
1160 return match; | 1161 return match; |
1161 } | 1162 } |
OLD | NEW |