Chromium Code Reviews| 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..a2f5347db3abc9df534fc56f582f933a61ab456d 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 |
| + |
| +const base::TimeDelta ClipboardRecentContent::kMaximumAgeOfClipboard = |
|
dcheng
2017/04/02 05:04:03
Does this generate a static initializer? (The cons
Mark P
2017/04/02 05:33:56
Changed to constexpr.
|
| + 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 (size_t i = 0; i < arraysize(kAuthorizedSchemes); ++i) { |
|
dcheng
2017/04/02 05:04:03
Alternatively:
for (const auto* authorized_scheme
Mark P
2017/04/02 05:33:56
Nice. Done.
|
| + if (url.SchemeIs(kAuthorizedSchemes[i])) |
| + return true; |
| + } |
| + |
| + // Not a scheme we're allowed to return. |
| + return false; |
| +} |