Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete.h" | 5 #include "chrome/browser/autocomplete/autocomplete.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/i18n/number_formatting.h" | 11 #include "base/i18n/number_formatting.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_match.h" | 17 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 18 #include "chrome/browser/autocomplete/builtin_provider.h" | 18 #include "chrome/browser/autocomplete/builtin_provider.h" |
| 19 #include "chrome/browser/autocomplete/extension_app_provider.h" | |
| 19 #include "chrome/browser/autocomplete/history_contents_provider.h" | 20 #include "chrome/browser/autocomplete/history_contents_provider.h" |
| 20 #include "chrome/browser/autocomplete/history_quick_provider.h" | 21 #include "chrome/browser/autocomplete/history_quick_provider.h" |
| 21 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 22 #include "chrome/browser/autocomplete/keyword_provider.h" | 23 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 23 #include "chrome/browser/autocomplete/search_provider.h" | 24 #include "chrome/browser/autocomplete/search_provider.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_model.h" | 25 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 25 #include "chrome/browser/external_protocol_handler.h" | 26 #include "chrome/browser/external_protocol_handler.h" |
| 26 #include "chrome/browser/net/url_fixer_upper.h" | 27 #include "chrome/browser/net/url_fixer_upper.h" |
| 27 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 providers_.push_back(search_provider_); | 790 providers_.push_back(search_provider_); |
| 790 if (CommandLine::ForCurrentProcess()->HasSwitch( | 791 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 791 switches::kEnableHistoryQuickProvider) && | 792 switches::kEnableHistoryQuickProvider) && |
| 792 !CommandLine::ForCurrentProcess()->HasSwitch( | 793 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 793 switches::kDisableHistoryQuickProvider)) | 794 switches::kDisableHistoryQuickProvider)) |
| 794 providers_.push_back(new HistoryQuickProvider(this, profile)); | 795 providers_.push_back(new HistoryQuickProvider(this, profile)); |
| 795 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 796 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 796 switches::kDisableHistoryURLProvider)) | 797 switches::kDisableHistoryURLProvider)) |
| 797 providers_.push_back(new HistoryURLProvider(this, profile)); | 798 providers_.push_back(new HistoryURLProvider(this, profile)); |
| 798 providers_.push_back(new KeywordProvider(this, profile)); | 799 providers_.push_back(new KeywordProvider(this, profile)); |
| 800 providers_.push_back(new ExtensionAppProvider(this, profile)); | |
|
Peter Kasting
2011/03/31 21:33:59
Nit: This ordering is totally random. Can you alp
Finnur
2011/04/01 15:49:36
Done.
| |
| 799 providers_.push_back(new HistoryContentsProvider(this, profile)); | 801 providers_.push_back(new HistoryContentsProvider(this, profile)); |
| 800 providers_.push_back(new BuiltinProvider(this, profile)); | 802 providers_.push_back(new BuiltinProvider(this, profile)); |
| 801 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) | 803 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) |
| 802 (*i)->AddRef(); | 804 (*i)->AddRef(); |
| 803 } | 805 } |
| 804 | 806 |
| 805 AutocompleteController::~AutocompleteController() { | 807 AutocompleteController::~AutocompleteController() { |
| 806 // The providers may have tasks outstanding that hold refs to them. We need | 808 // The providers may have tasks outstanding that hold refs to them. We need |
| 807 // to ensure they won't call us back if they outlive us. (Practically, | 809 // to ensure they won't call us back if they outlive us. (Practically, |
| 808 // calling Stop() should also cancel those tasks and make it so that we hold | 810 // calling Stop() should also cancel those tasks and make it so that we hold |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 } | 983 } |
| 982 } | 984 } |
| 983 done_ = true; | 985 done_ = true; |
| 984 } | 986 } |
| 985 | 987 |
| 986 void AutocompleteController::StartExpireTimer() { | 988 void AutocompleteController::StartExpireTimer() { |
| 987 if (result_.HasCopiedMatches()) | 989 if (result_.HasCopiedMatches()) |
| 988 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 990 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
| 989 this, &AutocompleteController::ExpireCopiedEntries); | 991 this, &AutocompleteController::ExpireCopiedEntries); |
| 990 } | 992 } |
| OLD | NEW |