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

Unified Diff: components/open_from_clipboard/clipboard_recent_content_generic.cc

Issue 2812773002: Refactor Clipboard Last Modified Time Storage (Closed)
Patch Set: itri-state enum 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
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 87c6542b9ea8f1375987a2335b16cfecde5bf533..15ffa42eb9837128e29cdc6d8aef60972cf7f6e8 100644
--- a/components/open_from_clipboard/clipboard_recent_content_generic.cc
+++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc
@@ -10,17 +10,12 @@
ClipboardRecentContentGeneric::ClipboardRecentContentGeneric() {}
bool ClipboardRecentContentGeneric::GetRecentURLFromClipboard(GURL* url) {
- ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
- base::Time last_modified_time = clipboard->GetClipboardLastModifiedTime();
- if (!last_modified_time_to_suppress_.is_null() &&
- (last_modified_time == last_modified_time_to_suppress_))
- return false;
-
if (GetClipboardContentAge() > MaximumAgeOfClipboard())
return false;
// Get and clean up the clipboard before processing.
std::string gurl_string;
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &gurl_string);
base::TrimWhitespaceASCII(gurl_string, base::TrimPositions::TRIM_ALL,
&gurl_string);
@@ -53,7 +48,7 @@ bool ClipboardRecentContentGeneric::GetRecentURLFromClipboard(GURL* url) {
base::TimeDelta ClipboardRecentContentGeneric::GetClipboardContentAge() const {
const base::Time last_modified_time =
- ui::Clipboard::GetForCurrentThread()->GetClipboardLastModifiedTime();
+ ui::Clipboard::GetForCurrentThread()->GetLastModifiedTime();
const base::Time now = base::Time::Now();
// In case of system clock change, assume the last modified time is now.
// (Don't return a negative age, i.e., a time in the future.)
@@ -64,9 +59,7 @@ base::TimeDelta ClipboardRecentContentGeneric::GetClipboardContentAge() const {
void ClipboardRecentContentGeneric::SuppressClipboardContent() {
// User cleared the user data. The pasteboard entry must be removed from the
- // omnibox list. Do this by suppressing all clipboard content with the
- // current clipboard content's time. Then we only suggest the clipboard
- // content later if the time changed.
- last_modified_time_to_suppress_ =
- ui::Clipboard::GetForCurrentThread()->GetClipboardLastModifiedTime();
+ // omnibox list. Do this by pretending the current clipboard is ancient,
+ // not recent.
+ ui::Clipboard::GetForCurrentThread()->ClearLastModifiedTime();
}

Powered by Google App Engine
This is Rietveld 408576698