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

Unified Diff: components/open_from_clipboard/clipboard_recent_content.cc

Issue 2790993003: Add Generic Implementation of ClipboardRecentContent (Closed)
Patch Set: suppress suggestion regardless of history_service existing 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/open_from_clipboard/clipboard_recent_content.cc
diff --git a/components/open_from_clipboard/clipboard_recent_content.cc b/components/open_from_clipboard/clipboard_recent_content.cc
index 56312ec2ae029a7a5a3b99ede5d4e87b234fc38e..2616984bf4b4595e961d4ae5052e2cbe46dca5bb 100644
--- a/components/open_from_clipboard/clipboard_recent_content.cc
+++ b/components/open_from_clipboard/clipboard_recent_content.cc
@@ -4,9 +4,25 @@
#include "components/open_from_clipboard/clipboard_recent_content.h"
+#include "url/url_constants.h"
+
namespace {
ClipboardRecentContent* g_clipboard_recent_content = nullptr;
-}
+
+// Schemes appropriate for suggestion by ClipboardRecentContent.
+const char* kAuthorizedSchemes[] = {
+ url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme,
+ // TODO(mpearson): add support for chrome:// URLs. Right now the scheme
+ // for that lives in content and is accessible via
+ // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme
+ // TODO(mpearson): when adding desktop support, add kFileScheme, kFtpScheme,
+ // and kGopherScheme.
+};
+
+} // namespace
+
+constexpr base::TimeDelta ClipboardRecentContent::kMaximumAgeOfClipboard =
+ base::TimeDelta::FromHours(3);
ClipboardRecentContent::ClipboardRecentContent() {}
@@ -21,3 +37,15 @@ ClipboardRecentContent* ClipboardRecentContent::GetInstance() {
void ClipboardRecentContent::SetInstance(ClipboardRecentContent* instance) {
g_clipboard_recent_content = instance;
}
+
+// static
+bool ClipboardRecentContent::IsAppropriateSuggestion(const GURL& url) {
+ // Check to make sure it's a scheme we're willing to suggest.
+ for (const auto* authorized_scheme : kAuthorizedSchemes) {
+ if (url.SchemeIs(authorized_scheme))
+ return true;
+ }
+
+ // Not a scheme we're allowed to return.
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698