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

Side by Side Diff: components/open_from_clipboard/clipboard_recent_content.h

Issue 2790993003: Add Generic Implementation of ClipboardRecentContent (Closed)
Patch Set: tested interactively; works. removed field trial force-enable code 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_ 5 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_
6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_ 6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 12 #include "url/gurl.h"
13 class GURL;
14 13
15 // Helper class returning an URL if the content of the clipboard can be turned 14 // Helper class returning an URL if the content of the clipboard can be turned
16 // into an URL, and if it estimates that the content of the clipboard is not too 15 // into an URL, and if it estimates that the content of the clipboard is not too
17 // old. 16 // old.
18 class ClipboardRecentContent { 17 class ClipboardRecentContent {
19 public: 18 public:
20 ClipboardRecentContent(); 19 ClipboardRecentContent();
21 virtual ~ClipboardRecentContent(); 20 virtual ~ClipboardRecentContent();
22 21
23 // Returns the global instance of the ClipboardRecentContent singleton. This 22 // Returns the global instance of the ClipboardRecentContent singleton. This
24 // method does *not* create the singleton and will return null if no instance 23 // method does *not* create the singleton and will return null if no instance
25 // was registered via SetInstance(). 24 // was registered via SetInstance().
26 static ClipboardRecentContent* GetInstance(); 25 static ClipboardRecentContent* GetInstance();
27 26
28 // Sets the global instance of ClipboardRecentContent singleton. 27 // Sets the global instance of ClipboardRecentContent singleton.
29 static void SetInstance(ClipboardRecentContent* instance); 28 static void SetInstance(ClipboardRecentContent* instance);
30 29
31 // Returns true if the clipboard contains a recent URL that has not been 30 // Returns true if the clipboard contains a recent URL that is appropriate to
32 // supressed, and copies it in |url|. Otherwise, returns false. |url| must not 31 // be suggested and has not been supressed, and copies it in |url|.
33 // be null. 32 // Otherwise, returns false. |url| must not be null.
34 virtual bool GetRecentURLFromClipboard(GURL* url) = 0; 33 virtual bool GetRecentURLFromClipboard(GURL* url) = 0;
35 34
36 // Returns how old the content of the clipboard is. 35 // Returns how old the content of the clipboard is.
37 virtual base::TimeDelta GetClipboardContentAge() const = 0; 36 virtual base::TimeDelta GetClipboardContentAge() const = 0;
38 37
39 // Prevent GetRecentURLFromClipboard from returning anything until the 38 // Prevent GetRecentURLFromClipboard from returning anything until the
40 // clipboard's content changed. 39 // clipboard's content changed.
41 virtual void SuppressClipboardContent() = 0; 40 virtual void SuppressClipboardContent() = 0;
42 41
42 protected:
43 // GetRecentURLFromClipboard() should never return a URL from a clipboard
44 // older than this.
45 const base::TimeDelta kMaximumAgeOfClipboard = base::TimeDelta::FromHours(3);
46
47 // Returns true if the URL is appropriate to be suggested.
48 static bool IsAppropriateSuggestion(const GURL& url);
49
43 private: 50 private:
44 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent); 51 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent);
45 }; 52 };
46 53
47 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_ 54 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698