Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: components/omnibox/browser/autocomplete_controller.cc

Issue 2790993003: Add Generic Implementation of ClipboardRecentContent (Closed)
Patch Set: make maxage non-static, plus guard recent content for tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/omnibox/browser/autocomplete_controller.cc
diff --git a/components/omnibox/browser/autocomplete_controller.cc b/components/omnibox/browser/autocomplete_controller.cc
index 1a175d428d4d3b574c6fcf544b923948eb85d461..f2d6554c446f3caf2aec44f122572ade90b64f77 100644
--- a/components/omnibox/browser/autocomplete_controller.cc
+++ b/components/omnibox/browser/autocomplete_controller.cc
@@ -11,6 +11,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@@ -31,6 +32,9 @@
#include "components/omnibox/browser/shortcuts_provider.h"
#include "components/omnibox/browser/zero_suggest_provider.h"
#include "components/open_from_clipboard/clipboard_recent_content.h"
+#if !defined(OS_IOS)
Peter Kasting 2017/04/03 23:35:18 Nit: Put #if'd #includes in a separate group below
Mark P 2017/04/04 04:53:02 Done.
+#include "components/open_from_clipboard/clipboard_recent_content_generic.h"
+#endif
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/strings/grit/components_strings.h"
@@ -229,12 +233,24 @@ AutocompleteController::AutocompleteController(
providers_.push_back(zero_suggest_provider_);
}
if (provider_types & AutocompleteProvider::TYPE_CLIPBOARD_URL) {
- ClipboardRecentContent* clipboard_recent_content =
- ClipboardRecentContent::GetInstance();
- if (clipboard_recent_content) {
- providers_.push_back(new ClipboardURLProvider(provider_client_.get(),
- history_url_provider_,
- clipboard_recent_content));
+#if !defined(OS_IOS)
+ // On iOS, a global ClipboardRecentContent should've been created by now
+ // (if enabled). If none has been created (e.g., we're on a different
+ // platform), use the generic implementation, which AutocompleteController
+ // will own. Don't try to create a generic implementation on iOS because
+ // iOS doesn't want/need to link in the implementation and the libraries
+ // that would come with it.
+ if (!ClipboardRecentContent::GetInstance()) {
+ clipboard_recent_content_ =
+ base::MakeUnique<ClipboardRecentContentGeneric>();
+ ClipboardRecentContent::SetInstance(clipboard_recent_content_.get());
+ }
+#endif
+ // ClipboardRecentContent can be null in tests.
+ if (ClipboardRecentContent::GetInstance()) {
+ providers_.push_back(new ClipboardURLProvider(
+ provider_client_.get(), history_url_provider_,
+ ClipboardRecentContent::GetInstance()));
}
}
if (provider_types & AutocompleteProvider::TYPE_PHYSICAL_WEB) {
« no previous file with comments | « components/omnibox/browser/autocomplete_controller.h ('k') | components/omnibox/browser/omnibox_field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698