| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 if (fixed_text.empty()) { | 629 if (fixed_text.empty()) { |
| 630 // Conceivably fixup could result in an empty string (although I don't | 630 // Conceivably fixup could result in an empty string (although I don't |
| 631 // have cases where this happens offhand). We can't do anything with | 631 // have cases where this happens offhand). We can't do anything with |
| 632 // empty input, so just bail; otherwise we'd crash later. | 632 // empty input, so just bail; otherwise we'd crash later. |
| 633 return; | 633 return; |
| 634 } | 634 } |
| 635 params->input.set_text(fixed_text); | 635 params->input.set_text(fixed_text); |
| 636 | 636 |
| 637 // Pass 1: Get the in-memory URL database, and use it to find and promote | 637 // Pass 1: Get the in-memory URL database, and use it to find and promote |
| 638 // the inline autocomplete match, if any. | 638 // the inline autocomplete match, if any. |
| 639 history::URLDatabase* url_db = history_service->in_memory_database(); | 639 history::URLDatabase* url_db = history_service->InMemoryDatabase(); |
| 640 // url_db can be NULL if it hasn't finished initializing (or failed to | 640 // url_db can be NULL if it hasn't finished initializing (or failed to |
| 641 // initialize). In this case all we can do is fall back on the second | 641 // initialize). In this case all we can do is fall back on the second |
| 642 // pass. Ultimately, we should probably try to ensure the history system | 642 // pass. |
| 643 // starts properly before we get here, as otherwise this can cause | 643 // |
| 644 // inconsistent behavior when the user has just started the browser and | 644 // TODO(pkasting): We should just block here until this loads. Any time |
| 645 // tries to type immediately. | 645 // someone unloads the history backend, we'll get inconsistent inline |
| 646 // autocomplete behavior here. |
| 646 if (url_db) { | 647 if (url_db) { |
| 647 DoAutocomplete(NULL, url_db, params.get()); | 648 DoAutocomplete(NULL, url_db, params.get()); |
| 648 // params->matches now has the matches we should expose to the provider. | 649 // params->matches now has the matches we should expose to the provider. |
| 649 // Pass 2 expects a "clean slate" set of matches. | 650 // Pass 2 expects a "clean slate" set of matches. |
| 650 matches_.clear(); | 651 matches_.clear(); |
| 651 matches_.swap(params->matches); | 652 matches_.swap(params->matches); |
| 652 UpdateStarredStateOfMatches(); | 653 UpdateStarredStateOfMatches(); |
| 653 } | 654 } |
| 654 } | 655 } |
| 655 | 656 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 history_match.input_location - offset, params->input.text().length(), | 826 history_match.input_location - offset, params->input.text().length(), |
| 826 match.contents.length(), ACMatchClassification::URL, | 827 match.contents.length(), ACMatchClassification::URL, |
| 827 &match.contents_class); | 828 &match.contents_class); |
| 828 match.description = info.title(); | 829 match.description = info.title(); |
| 829 AutocompleteMatch::ClassifyMatchInString(params->input.text(), info.title(), | 830 AutocompleteMatch::ClassifyMatchInString(params->input.text(), info.title(), |
| 830 ACMatchClassification::NONE, | 831 ACMatchClassification::NONE, |
| 831 &match.description_class); | 832 &match.description_class); |
| 832 | 833 |
| 833 return match; | 834 return match; |
| 834 } | 835 } |
| OLD | NEW |