Commit 2fa356c2 authored by mpearson's avatar mpearson Committed by Commit bot

Clipboard Recent Content - Code Health - Move kAuthorizedScheme into Subclass

The variable and its related function is only used in one subclass, so it
shouldn't sit in the base class and possibly mislead folks.

BUG=711576

Review-Url: https://codereview.chromium.org/2842793003
Cr-Commit-Position: refs/heads/master@{#468626}
parent 8569024f
......@@ -12,16 +12,6 @@
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() {}
......@@ -41,18 +31,6 @@ void ClipboardRecentContent::SetInstance(
g_clipboard_recent_content = new_instance.release();
}
// 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;
}
// static
base::TimeDelta ClipboardRecentContent::MaximumAgeOfClipboard() {
// Identify the current setting for this parameter from the omnibox field
......
......@@ -45,9 +45,6 @@ class ClipboardRecentContent {
// older than this.
static base::TimeDelta MaximumAgeOfClipboard();
// Returns true if the URL is appropriate to be suggested.
static bool IsAppropriateSuggestion(const GURL& url);
private:
DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent);
};
......
......@@ -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;
}
......@@ -27,6 +27,9 @@ class ClipboardRecentContentGeneric : public ClipboardRecentContent {
void SuppressClipboardContent() override;
private:
// Returns true if the URL is appropriate to be suggested.
static bool IsAppropriateSuggestion(const GURL& url);
DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentGeneric);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment