Chromium Code Reviews| 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 <memory> | |
| 8 #include <set> | 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
| 21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 22 #include "components/omnibox/browser/autocomplete_controller_delegate.h" | 23 #include "components/omnibox/browser/autocomplete_controller_delegate.h" |
| 23 #include "components/omnibox/browser/bookmark_provider.h" | 24 #include "components/omnibox/browser/bookmark_provider.h" |
| 24 #include "components/omnibox/browser/builtin_provider.h" | 25 #include "components/omnibox/browser/builtin_provider.h" |
| 25 #include "components/omnibox/browser/clipboard_url_provider.h" | 26 #include "components/omnibox/browser/clipboard_url_provider.h" |
| 26 #include "components/omnibox/browser/history_quick_provider.h" | 27 #include "components/omnibox/browser/history_quick_provider.h" |
| 27 #include "components/omnibox/browser/history_url_provider.h" | 28 #include "components/omnibox/browser/history_url_provider.h" |
| 28 #include "components/omnibox/browser/keyword_provider.h" | 29 #include "components/omnibox/browser/keyword_provider.h" |
| 29 #include "components/omnibox/browser/omnibox_field_trial.h" | 30 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 30 #include "components/omnibox/browser/physical_web_provider.h" | 31 #include "components/omnibox/browser/physical_web_provider.h" |
| 31 #include "components/omnibox/browser/search_provider.h" | 32 #include "components/omnibox/browser/search_provider.h" |
| 32 #include "components/omnibox/browser/shortcuts_provider.h" | 33 #include "components/omnibox/browser/shortcuts_provider.h" |
| 33 #include "components/omnibox/browser/zero_suggest_provider.h" | 34 #include "components/omnibox/browser/zero_suggest_provider.h" |
| 34 #include "components/open_from_clipboard/clipboard_recent_content.h" | 35 #include "components/open_from_clipboard/clipboard_recent_content.h" |
| 35 #if !defined(OS_IOS) | |
| 36 #include "components/open_from_clipboard/clipboard_recent_content_generic.h" | |
| 37 #endif | |
| 38 #include "components/search_engines/template_url.h" | 36 #include "components/search_engines/template_url.h" |
| 39 #include "components/search_engines/template_url_service.h" | 37 #include "components/search_engines/template_url_service.h" |
| 40 #include "components/strings/grit/components_strings.h" | 38 #include "components/strings/grit/components_strings.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 42 | 40 |
| 41 #if !defined(OS_IOS) | |
| 42 #include "components/open_from_clipboard/clipboard_recent_content_generic.h" | |
| 43 #endif | |
| 44 | |
| 43 namespace { | 45 namespace { |
| 44 | 46 |
| 45 // Converts the given match to a type (and possibly subtype) based on the AQS | 47 // Converts the given match to a type (and possibly subtype) based on the AQS |
| 46 // specification. For more details, see | 48 // specification. For more details, see |
| 47 // http://goto.google.com/binary-clients-logging. | 49 // http://goto.google.com/binary-clients-logging. |
| 48 void AutocompleteMatchToAssistedQuery( | 50 void AutocompleteMatchToAssistedQuery( |
| 49 const AutocompleteMatch::Type& match, | 51 const AutocompleteMatch::Type& match, |
| 50 const AutocompleteProvider* provider, | 52 const AutocompleteProvider* provider, |
| 51 size_t* type, | 53 size_t* type, |
| 52 size_t* subtype) { | 54 size_t* subtype) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 } | 236 } |
| 235 if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) { | 237 if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) { |
| 236 #if !defined(OS_IOS) | 238 #if !defined(OS_IOS) |
| 237 // On iOS, a global ClipboardRecentContent should've been created by now | 239 // On iOS, a global ClipboardRecentContent should've been created by now |
| 238 // (if enabled). If none has been created (e.g., we're on a different | 240 // (if enabled). If none has been created (e.g., we're on a different |
| 239 // platform), use the generic implementation, which AutocompleteController | 241 // platform), use the generic implementation, which AutocompleteController |
| 240 // will own. Don't try to create a generic implementation on iOS because | 242 // will own. Don't try to create a generic implementation on iOS because |
| 241 // iOS doesn't want/need to link in the implementation and the libraries | 243 // iOS doesn't want/need to link in the implementation and the libraries |
| 242 // that would come with it. | 244 // that would come with it. |
| 243 if (!ClipboardRecentContent::GetInstance()) { | 245 if (!ClipboardRecentContent::GetInstance()) { |
| 244 clipboard_recent_content_ = | 246 ClipboardRecentContent::SetInstance( |
| 245 base::MakeUnique<ClipboardRecentContentGeneric>(); | 247 std::unique_ptr<ClipboardRecentContentGeneric>()); |
|
Peter Kasting
2017/04/10 21:59:22
Doesn't this fail to actually create the underlyin
Mark P
2017/04/10 22:05:22
Right you are. :-) Done. (I didn't bother testin
| |
| 246 ClipboardRecentContent::SetInstance(clipboard_recent_content_.get()); | |
| 247 } | 248 } |
| 248 #endif | 249 #endif |
| 249 // ClipboardRecentContent can be null in iOS tests. For non-iOS, we | 250 // ClipboardRecentContent can be null in iOS tests. For non-iOS, we |
| 250 // create a ClipboardRecentContent as above (for both Chrome and tests). | 251 // create a ClipboardRecentContent as above (for both Chrome and tests). |
| 251 if (ClipboardRecentContent::GetInstance()) { | 252 if (ClipboardRecentContent::GetInstance()) { |
| 252 providers_.push_back(new ClipboardURLProvider( | 253 providers_.push_back(new ClipboardURLProvider( |
| 253 provider_client_.get(), history_url_provider_, | 254 provider_client_.get(), history_url_provider_, |
| 254 ClipboardRecentContent::GetInstance())); | 255 ClipboardRecentContent::GetInstance())); |
| 255 } | 256 } |
| 256 } | 257 } |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 expire_timer_.Stop(); | 700 expire_timer_.Stop(); |
| 700 stop_timer_.Stop(); | 701 stop_timer_.Stop(); |
| 701 done_ = true; | 702 done_ = true; |
| 702 if (clear_result && !result_.empty()) { | 703 if (clear_result && !result_.empty()) { |
| 703 result_.Reset(); | 704 result_.Reset(); |
| 704 // NOTE: We pass in false since we're trying to only clear the popup, not | 705 // NOTE: We pass in false since we're trying to only clear the popup, not |
| 705 // touch the edit... this is all a mess and should be cleaned up :( | 706 // touch the edit... this is all a mess and should be cleaned up :( |
| 706 NotifyChanged(false); | 707 NotifyChanged(false); |
| 707 } | 708 } |
| 708 } | 709 } |
| OLD | NEW |