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

Unified Diff: components/open_from_clipboard/clipboard_recent_content.cc

Issue 2790993003: Add Generic Implementation of ClipboardRecentContent (Closed)
Patch Set: tested interactively; works. removed field trial force-enable code 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..a31a9d6f76aca9e1c9d9246573a3d54aecedde26 100644
--- a/components/open_from_clipboard/clipboard_recent_content.cc
+++ b/components/open_from_clipboard/clipboard_recent_content.cc
@@ -4,13 +4,28 @@
#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
ClipboardRecentContent::ClipboardRecentContent() {}
-ClipboardRecentContent::~ClipboardRecentContent() {}
+ClipboardRecentContent::~ClipboardRecentContent() {
+ g_clipboard_recent_content = nullptr;
Peter Kasting 2017/04/03 23:35:18 I'm still worried about lifetime management here.
Mark P 2017/04/04 04:53:02 Rightly so, you make a good point below. I see tw
+}
// static
ClipboardRecentContent* ClipboardRecentContent::GetInstance() {
@@ -21,3 +36,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