| 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 "components/omnibox/browser/autocomplete_controller.h" | 5 #include "components/omnibox/browser/autocomplete_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "components/omnibox/browser/autocomplete_controller_delegate.h" | 21 #include "components/omnibox/browser/autocomplete_controller_delegate.h" |
| 22 #include "components/omnibox/browser/bookmark_provider.h" | 22 #include "components/omnibox/browser/bookmark_provider.h" |
| 23 #include "components/omnibox/browser/builtin_provider.h" | 23 #include "components/omnibox/browser/builtin_provider.h" |
| 24 #include "components/omnibox/browser/clipboard_url_provider.h" | 24 #include "components/omnibox/browser/clipboard_url_provider.h" |
| 25 #include "components/omnibox/browser/history_quick_provider.h" | 25 #include "components/omnibox/browser/history_quick_provider.h" |
| 26 #include "components/omnibox/browser/history_url_provider.h" | 26 #include "components/omnibox/browser/history_url_provider.h" |
| 27 #include "components/omnibox/browser/keyword_provider.h" | 27 #include "components/omnibox/browser/keyword_provider.h" |
| 28 #include "components/omnibox/browser/omnibox_field_trial.h" | 28 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 29 #include "components/omnibox/browser/physical_web_provider.h" |
| 29 #include "components/omnibox/browser/search_provider.h" | 30 #include "components/omnibox/browser/search_provider.h" |
| 30 #include "components/omnibox/browser/shortcuts_provider.h" | 31 #include "components/omnibox/browser/shortcuts_provider.h" |
| 31 #include "components/omnibox/browser/zero_suggest_provider.h" | 32 #include "components/omnibox/browser/zero_suggest_provider.h" |
| 32 #include "components/open_from_clipboard/clipboard_recent_content.h" | 33 #include "components/open_from_clipboard/clipboard_recent_content.h" |
| 33 #include "components/search_engines/template_url.h" | 34 #include "components/search_engines/template_url.h" |
| 34 #include "components/search_engines/template_url_service.h" | 35 #include "components/search_engines/template_url_service.h" |
| 35 #include "grit/components_strings.h" | 36 #include "grit/components_strings.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 214 } |
| 214 if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) { | 215 if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) { |
| 215 ClipboardRecentContent* clipboard_recent_content = | 216 ClipboardRecentContent* clipboard_recent_content = |
| 216 ClipboardRecentContent::GetInstance(); | 217 ClipboardRecentContent::GetInstance(); |
| 217 if (clipboard_recent_content) { | 218 if (clipboard_recent_content) { |
| 218 providers_.push_back(new ClipboardURLProvider(provider_client_.get(), | 219 providers_.push_back(new ClipboardURLProvider(provider_client_.get(), |
| 219 history_url_provider_, | 220 history_url_provider_, |
| 220 clipboard_recent_content)); | 221 clipboard_recent_content)); |
| 221 } | 222 } |
| 222 } | 223 } |
| 224 if (provider_types & AutocompleteProvider::TYPE_PHYSICAL_WEB) { |
| 225 PhysicalWebProvider* physical_web_provider = |
| 226 PhysicalWebProvider::Create(provider_client_.get()); |
| 227 if (physical_web_provider) |
| 228 providers_.push_back(physical_web_provider); |
| 229 } |
| 223 } | 230 } |
| 224 | 231 |
| 225 AutocompleteController::~AutocompleteController() { | 232 AutocompleteController::~AutocompleteController() { |
| 226 // The providers may have tasks outstanding that hold refs to them. We need | 233 // The providers may have tasks outstanding that hold refs to them. We need |
| 227 // to ensure they won't call us back if they outlive us. (Practically, | 234 // to ensure they won't call us back if they outlive us. (Practically, |
| 228 // calling Stop() should also cancel those tasks and make it so that we hold | 235 // calling Stop() should also cancel those tasks and make it so that we hold |
| 229 // the only refs.) We also don't want to bother notifying anyone of our | 236 // the only refs.) We also don't want to bother notifying anyone of our |
| 230 // result changes here, because the notification observer is in the midst of | 237 // result changes here, because the notification observer is in the midst of |
| 231 // shutdown too, so we don't ask Stop() to clear |result_| (and notify). | 238 // shutdown too, so we don't ask Stop() to clear |result_| (and notify). |
| 232 result_.Reset(); // Not really necessary. | 239 result_.Reset(); // Not really necessary. |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 expire_timer_.Stop(); | 666 expire_timer_.Stop(); |
| 660 stop_timer_.Stop(); | 667 stop_timer_.Stop(); |
| 661 done_ = true; | 668 done_ = true; |
| 662 if (clear_result && !result_.empty()) { | 669 if (clear_result && !result_.empty()) { |
| 663 result_.Reset(); | 670 result_.Reset(); |
| 664 // NOTE: We pass in false since we're trying to only clear the popup, not | 671 // NOTE: We pass in false since we're trying to only clear the popup, not |
| 665 // touch the edit... this is all a mess and should be cleaned up :( | 672 // touch the edit... this is all a mess and should be cleaned up :( |
| 666 NotifyChanged(false); | 673 NotifyChanged(false); |
| 667 } | 674 } |
| 668 } | 675 } |
| OLD | NEW |