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/autocomplete_controller.h" | 5 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/autocomplete/search_provider.h" | 23 #include "chrome/browser/autocomplete/search_provider.h" |
24 #include "chrome/browser/autocomplete/shortcuts_provider.h" | 24 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/search_engines/template_url.h" | 26 #include "chrome/browser/search_engines/template_url.h" |
27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
30 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 | 32 |
| 33 #if defined(OS_CHROMEOS) |
| 34 #include "chrome/browser/autocomplete/contact_provider_chromeos.h" |
| 35 #endif |
| 36 |
33 namespace { | 37 namespace { |
34 | 38 |
35 // Converts the given type to an integer based on the AQS specification. | 39 // Converts the given type to an integer based on the AQS specification. |
36 // For more details, See http://goto.google.com/binary-clients-logging . | 40 // For more details, See http://goto.google.com/binary-clients-logging . |
37 int AutocompleteMatchToAssistedQueryType(const AutocompleteMatch::Type& type) { | 41 int AutocompleteMatchToAssistedQueryType(const AutocompleteMatch::Type& type) { |
38 switch (type) { | 42 switch (type) { |
39 case AutocompleteMatch::SEARCH_SUGGEST: return 0; | 43 case AutocompleteMatch::SEARCH_SUGGEST: return 0; |
40 case AutocompleteMatch::NAVSUGGEST: return 5; | 44 case AutocompleteMatch::NAVSUGGEST: return 5; |
41 case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: return 57; | 45 case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: return 57; |
42 case AutocompleteMatch::URL_WHAT_YOU_TYPED: return 58; | 46 case AutocompleteMatch::URL_WHAT_YOU_TYPED: return 58; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // HistoryURLProvider to not search titles once HQP is turned on permanently. | 98 // HistoryURLProvider to not search titles once HQP is turned on permanently. |
95 // TODO(jcivelli): Enable the History Quick Provider and figure out why it | 99 // TODO(jcivelli): Enable the History Quick Provider and figure out why it |
96 // reports the wrong results for some pages. | 100 // reports the wrong results for some pages. |
97 bool hqp_enabled = false; | 101 bool hqp_enabled = false; |
98 #endif // !OS_ANDROID | 102 #endif // !OS_ANDROID |
99 providers_.push_back(new HistoryURLProvider(this, profile)); | 103 providers_.push_back(new HistoryURLProvider(this, profile)); |
100 providers_.push_back(new ShortcutsProvider(this, profile)); | 104 providers_.push_back(new ShortcutsProvider(this, profile)); |
101 providers_.push_back(new HistoryContentsProvider(this, profile, hqp_enabled)); | 105 providers_.push_back(new HistoryContentsProvider(this, profile, hqp_enabled)); |
102 providers_.push_back(new BuiltinProvider(this, profile)); | 106 providers_.push_back(new BuiltinProvider(this, profile)); |
103 providers_.push_back(new ExtensionAppProvider(this, profile)); | 107 providers_.push_back(new ExtensionAppProvider(this, profile)); |
| 108 #if defined(OS_CHROMEOS) |
| 109 providers_.push_back(new ContactProvider(this, profile)); |
| 110 #endif |
104 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) | 111 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) |
105 (*i)->AddRef(); | 112 (*i)->AddRef(); |
106 } | 113 } |
107 | 114 |
108 AutocompleteController::~AutocompleteController() { | 115 AutocompleteController::~AutocompleteController() { |
109 // The providers may have tasks outstanding that hold refs to them. We need | 116 // The providers may have tasks outstanding that hold refs to them. We need |
110 // to ensure they won't call us back if they outlive us. (Practically, | 117 // to ensure they won't call us back if they outlive us. (Practically, |
111 // calling Stop() should also cancel those tasks and make it so that we hold | 118 // calling Stop() should also cancel those tasks and make it so that we hold |
112 // the only refs.) We also don't want to bother notifying anyone of our | 119 // the only refs.) We also don't want to bother notifying anyone of our |
113 // result changes here, because the notification observer is in the midst of | 120 // result changes here, because the notification observer is in the midst of |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 407 } |
401 done_ = true; | 408 done_ = true; |
402 } | 409 } |
403 | 410 |
404 void AutocompleteController::StartExpireTimer() { | 411 void AutocompleteController::StartExpireTimer() { |
405 if (result_.HasCopiedMatches()) | 412 if (result_.HasCopiedMatches()) |
406 expire_timer_.Start(FROM_HERE, | 413 expire_timer_.Start(FROM_HERE, |
407 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 414 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
408 this, &AutocompleteController::ExpireCopiedEntries); | 415 this, &AutocompleteController::ExpireCopiedEntries); |
409 } | 416 } |
OLD | NEW |