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

Unified Diff: components/open_from_clipboard/clipboard_recent_content_generic.cc

Issue 2842793003: Clipboard Recent Content - Code Health - Move kAuthorizedScheme into Subclass (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content_generic.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/open_from_clipboard/clipboard_recent_content_generic.cc
diff --git a/components/open_from_clipboard/clipboard_recent_content_generic.cc b/components/open_from_clipboard/clipboard_recent_content_generic.cc
index 15ffa42eb9837128e29cdc6d8aef60972cf7f6e8..70b3691661d690b5f9fc04f02bcd7b1e1cb5a8b3 100644
--- a/components/open_from_clipboard/clipboard_recent_content_generic.cc
+++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc
@@ -7,6 +7,19 @@
#include "base/strings/string_util.h"
#include "ui/base/clipboard/clipboard.h"
+namespace {
+// 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
+
ClipboardRecentContentGeneric::ClipboardRecentContentGeneric() {}
bool ClipboardRecentContentGeneric::GetRecentURLFromClipboard(GURL* url) {
@@ -63,3 +76,15 @@ void ClipboardRecentContentGeneric::SuppressClipboardContent() {
// not recent.
ui::Clipboard::GetForCurrentThread()->ClearLastModifiedTime();
}
+
+// static
+bool ClipboardRecentContentGeneric::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;
+}
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content_generic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698