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

Side by Side Diff: components/open_from_clipboard/clipboard_recent_content_generic.cc

Issue 2817003003: Get maximum age of clipboard from clipboard_recent_contents.cc in iOS impl (Closed)
Patch Set: fix generic + rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/open_from_clipboard/clipboard_recent_content_generic.h" 5 #include "components/open_from_clipboard/clipboard_recent_content_generic.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "ui/base/clipboard/clipboard.h" 8 #include "ui/base/clipboard/clipboard.h"
9 9
10 ClipboardRecentContentGeneric::ClipboardRecentContentGeneric() {} 10 ClipboardRecentContentGeneric::ClipboardRecentContentGeneric() {}
11 11
12 bool ClipboardRecentContentGeneric::GetRecentURLFromClipboard(GURL* url) { 12 bool ClipboardRecentContentGeneric::GetRecentURLFromClipboard(GURL* url) {
13 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 13 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
14 base::Time last_modified_time = clipboard->GetClipboardLastModifiedTime(); 14 base::Time last_modified_time = clipboard->GetClipboardLastModifiedTime();
15 if (!last_modified_time_to_suppress_.is_null() && 15 if (!last_modified_time_to_suppress_.is_null() &&
16 (last_modified_time == last_modified_time_to_suppress_)) 16 (last_modified_time == last_modified_time_to_suppress_))
17 return false; 17 return false;
18 18
19 if (GetClipboardContentAge() > kMaximumAgeOfClipboard) 19 if (GetClipboardContentAge() > MaximumAgeOfClipboard())
20 return false; 20 return false;
21 21
22 // Get and clean up the clipboard before processing. 22 // Get and clean up the clipboard before processing.
23 std::string gurl_string; 23 std::string gurl_string;
24 clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &gurl_string); 24 clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &gurl_string);
25 base::TrimWhitespaceASCII(gurl_string, base::TrimPositions::TRIM_ALL, 25 base::TrimWhitespaceASCII(gurl_string, base::TrimPositions::TRIM_ALL,
26 &gurl_string); 26 &gurl_string);
27 27
28 // Interpret the clipboard as a URL if possible. 28 // Interpret the clipboard as a URL if possible.
29 DCHECK(url); 29 DCHECK(url);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 void ClipboardRecentContentGeneric::SuppressClipboardContent() { 65 void ClipboardRecentContentGeneric::SuppressClipboardContent() {
66 // User cleared the user data. The pasteboard entry must be removed from the 66 // User cleared the user data. The pasteboard entry must be removed from the
67 // omnibox list. Do this by suppressing all clipboard content with the 67 // omnibox list. Do this by suppressing all clipboard content with the
68 // current clipboard content's time. Then we only suggest the clipboard 68 // current clipboard content's time. Then we only suggest the clipboard
69 // content later if the time changed. 69 // content later if the time changed.
70 last_modified_time_to_suppress_ = 70 last_modified_time_to_suppress_ =
71 ui::Clipboard::GetForCurrentThread()->GetClipboardLastModifiedTime(); 71 ui::Clipboard::GetForCurrentThread()->GetClipboardLastModifiedTime();
72 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698