| 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 17 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.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/extension_app_provider.h" |
| 20 #include "chrome/browser/autocomplete/history_contents_provider.h" | 20 #include "chrome/browser/autocomplete/history_contents_provider.h" |
| 21 #include "chrome/browser/autocomplete/history_quick_provider.h" | 21 #include "chrome/browser/autocomplete/history_quick_provider.h" |
| 22 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 23 #include "chrome/browser/autocomplete/keyword_provider.h" | 23 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 24 #include "chrome/browser/autocomplete/search_provider.h" | 24 #include "chrome/browser/autocomplete/search_provider.h" |
| 25 #include "chrome/browser/autocomplete/shortcuts_provider.h" | 25 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
| 26 #include "chrome/browser/autocomplete/zero_suggest_provider.h" | 26 #include "chrome/browser/autocomplete/zero_suggest_provider.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/chrome_switches.h" | |
| 31 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 32 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 33 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 35 | 34 |
| 36 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
| 37 #include "chrome/browser/autocomplete/contact_provider_chromeos.h" | 36 #include "chrome/browser/autocomplete/contact_provider_chromeos.h" |
| 38 #include "chrome/browser/chromeos/contacts/contact_manager.h" | 37 #include "chrome/browser/chromeos/contacts/contact_manager.h" |
| 39 #endif | 38 #endif |
| 40 | 39 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 providers_.push_back(keyword_provider_); | 123 providers_.push_back(keyword_provider_); |
| 125 } | 124 } |
| 126 #endif | 125 #endif |
| 127 if (provider_types & AutocompleteProvider::TYPE_SEARCH) { | 126 if (provider_types & AutocompleteProvider::TYPE_SEARCH) { |
| 128 search_provider_ = new SearchProvider(this, profile); | 127 search_provider_ = new SearchProvider(this, profile); |
| 129 providers_.push_back(search_provider_); | 128 providers_.push_back(search_provider_); |
| 130 } | 129 } |
| 131 if (provider_types & AutocompleteProvider::TYPE_SHORTCUTS) | 130 if (provider_types & AutocompleteProvider::TYPE_SHORTCUTS) |
| 132 providers_.push_back(new ShortcutsProvider(this, profile)); | 131 providers_.push_back(new ShortcutsProvider(this, profile)); |
| 133 | 132 |
| 134 CommandLine* cl = CommandLine::ForCurrentProcess(); | 133 // Create ZeroSuggest if it is enabled. |
| 135 if ((provider_types & AutocompleteProvider::TYPE_ZERO_SUGGEST) && | 134 zero_suggest_provider_ = ZeroSuggestProvider::Create(this, profile); |
| 136 cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) { | 135 if (zero_suggest_provider_) { |
| 137 zero_suggest_provider_ = new ZeroSuggestProvider(this, profile, | |
| 138 cl->GetSwitchValueASCII(switches::kExperimentalZeroSuggestURLPrefix)); | |
| 139 providers_.push_back(zero_suggest_provider_); | 136 providers_.push_back(zero_suggest_provider_); |
| 140 } | 137 } |
| 141 | 138 |
| 142 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) | 139 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) |
| 143 (*i)->AddRef(); | 140 (*i)->AddRef(); |
| 144 } | 141 } |
| 145 | 142 |
| 146 AutocompleteController::~AutocompleteController() { | 143 AutocompleteController::~AutocompleteController() { |
| 147 // The providers may have tasks outstanding that hold refs to them. We need | 144 // The providers may have tasks outstanding that hold refs to them. We need |
| 148 // to ensure they won't call us back if they outlive us. (Practically, | 145 // to ensure they won't call us back if they outlive us. (Practically, |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 461 } |
| 465 done_ = true; | 462 done_ = true; |
| 466 } | 463 } |
| 467 | 464 |
| 468 void AutocompleteController::StartExpireTimer() { | 465 void AutocompleteController::StartExpireTimer() { |
| 469 if (result_.HasCopiedMatches()) | 466 if (result_.HasCopiedMatches()) |
| 470 expire_timer_.Start(FROM_HERE, | 467 expire_timer_.Start(FROM_HERE, |
| 471 base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 468 base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
| 472 this, &AutocompleteController::ExpireCopiedEntries); | 469 this, &AutocompleteController::ExpireCopiedEntries); |
| 473 } | 470 } |
| OLD | NEW |