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/memory/ptr_util.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "components/omnibox/browser/autocomplete_controller_delegate.h" | 22 #include "components/omnibox/browser/autocomplete_controller_delegate.h" |
22 #include "components/omnibox/browser/bookmark_provider.h" | 23 #include "components/omnibox/browser/bookmark_provider.h" |
23 #include "components/omnibox/browser/builtin_provider.h" | 24 #include "components/omnibox/browser/builtin_provider.h" |
24 #include "components/omnibox/browser/clipboard_url_provider.h" | 25 #include "components/omnibox/browser/clipboard_url_provider.h" |
25 #include "components/omnibox/browser/history_quick_provider.h" | 26 #include "components/omnibox/browser/history_quick_provider.h" |
26 #include "components/omnibox/browser/history_url_provider.h" | 27 #include "components/omnibox/browser/history_url_provider.h" |
27 #include "components/omnibox/browser/keyword_provider.h" | 28 #include "components/omnibox/browser/keyword_provider.h" |
28 #include "components/omnibox/browser/omnibox_field_trial.h" | 29 #include "components/omnibox/browser/omnibox_field_trial.h" |
29 #include "components/omnibox/browser/physical_web_provider.h" | 30 #include "components/omnibox/browser/physical_web_provider.h" |
30 #include "components/omnibox/browser/search_provider.h" | 31 #include "components/omnibox/browser/search_provider.h" |
31 #include "components/omnibox/browser/shortcuts_provider.h" | 32 #include "components/omnibox/browser/shortcuts_provider.h" |
32 #include "components/omnibox/browser/zero_suggest_provider.h" | 33 #include "components/omnibox/browser/zero_suggest_provider.h" |
33 #include "components/open_from_clipboard/clipboard_recent_content.h" | 34 #include "components/open_from_clipboard/clipboard_recent_content.h" |
| 35 #include "components/open_from_clipboard/clipboard_recent_content_generic.h" |
34 #include "components/search_engines/template_url.h" | 36 #include "components/search_engines/template_url.h" |
35 #include "components/search_engines/template_url_service.h" | 37 #include "components/search_engines/template_url_service.h" |
36 #include "components/strings/grit/components_strings.h" | 38 #include "components/strings/grit/components_strings.h" |
37 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 // Converts the given match to a type (and possibly subtype) based on the AQS | 43 // Converts the given match to a type (and possibly subtype) based on the AQS |
42 // specification. For more details, see | 44 // specification. For more details, see |
43 // http://goto.google.com/binary-clients-logging. | 45 // http://goto.google.com/binary-clients-logging. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 224 } |
223 if (provider_types & AutocompleteProvider::TYPE_SHORTCUTS) | 225 if (provider_types & AutocompleteProvider::TYPE_SHORTCUTS) |
224 providers_.push_back(new ShortcutsProvider(provider_client_.get())); | 226 providers_.push_back(new ShortcutsProvider(provider_client_.get())); |
225 if (provider_types & AutocompleteProvider::TYPE_ZERO_SUGGEST) { | 227 if (provider_types & AutocompleteProvider::TYPE_ZERO_SUGGEST) { |
226 zero_suggest_provider_ = ZeroSuggestProvider::Create( | 228 zero_suggest_provider_ = ZeroSuggestProvider::Create( |
227 provider_client_.get(), history_url_provider_, this); | 229 provider_client_.get(), history_url_provider_, this); |
228 if (zero_suggest_provider_) | 230 if (zero_suggest_provider_) |
229 providers_.push_back(zero_suggest_provider_); | 231 providers_.push_back(zero_suggest_provider_); |
230 } | 232 } |
231 if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) { | 233 if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) { |
232 ClipboardRecentContent* clipboard_recent_content = | 234 // On iOS, a global ClipboardRecentContent should've been created by now |
233 ClipboardRecentContent::GetInstance(); | 235 // (if enabled). If none has been created (e.g., we're on a different |
234 if (clipboard_recent_content) { | 236 // platform), use the generic implementation, which AutocompleteController |
235 providers_.push_back(new ClipboardURLProvider(provider_client_.get(), | 237 // will own. |
236 history_url_provider_, | 238 if (!ClipboardRecentContent::GetInstance()) { |
237 clipboard_recent_content)); | 239 clipboard_recent_content_ = |
| 240 base::MakeUnique<ClipboardRecentContentGeneric>(); |
| 241 ClipboardRecentContent::SetInstance(clipboard_recent_content_.get()); |
238 } | 242 } |
| 243 providers_.push_back( |
| 244 new ClipboardURLProvider(provider_client_.get(), history_url_provider_, |
| 245 ClipboardRecentContent::GetInstance())); |
239 } | 246 } |
240 if (provider_types & AutocompleteProvider::TYPE_PHYSICAL_WEB) { | 247 if (provider_types & AutocompleteProvider::TYPE_PHYSICAL_WEB) { |
241 PhysicalWebProvider* physical_web_provider = PhysicalWebProvider::Create( | 248 PhysicalWebProvider* physical_web_provider = PhysicalWebProvider::Create( |
242 provider_client_.get(), history_url_provider_); | 249 provider_client_.get(), history_url_provider_); |
243 if (physical_web_provider) | 250 if (physical_web_provider) |
244 providers_.push_back(physical_web_provider); | 251 providers_.push_back(physical_web_provider); |
245 } | 252 } |
246 } | 253 } |
247 | 254 |
248 AutocompleteController::~AutocompleteController() { | 255 AutocompleteController::~AutocompleteController() { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 expire_timer_.Stop(); | 689 expire_timer_.Stop(); |
683 stop_timer_.Stop(); | 690 stop_timer_.Stop(); |
684 done_ = true; | 691 done_ = true; |
685 if (clear_result && !result_.empty()) { | 692 if (clear_result && !result_.empty()) { |
686 result_.Reset(); | 693 result_.Reset(); |
687 // NOTE: We pass in false since we're trying to only clear the popup, not | 694 // NOTE: We pass in false since we're trying to only clear the popup, not |
688 // touch the edit... this is all a mess and should be cleaned up :( | 695 // touch the edit... this is all a mess and should be cleaned up :( |
689 NotifyChanged(false); | 696 NotifyChanged(false); |
690 } | 697 } |
691 } | 698 } |
OLD | NEW |