OLD | NEW |
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 |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 // Helper class returning an URL if the content of the clipboard can be turned | 15 // 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 | 16 // into an URL, and if it estimates that the content of the clipboard is not too |
17 // old. | 17 // old. |
18 class ClipboardRecentContent { | 18 class ClipboardRecentContent { |
19 public: | 19 public: |
20 // Returns an instance of the ClipboardContent singleton. | 20 ClipboardRecentContent(); |
| 21 virtual ~ClipboardRecentContent(); |
| 22 |
| 23 // Returns the global instance of the ClipboardRecentContent singleton. This |
| 24 // method does *not* create the singleton, and an instance must have been set |
| 25 // via a call to SetInstance() before. |
21 static ClipboardRecentContent* GetInstance(); | 26 static ClipboardRecentContent* GetInstance(); |
22 | 27 |
| 28 // Sets the global instance of ClipboardRecentContent singleton. |
| 29 static void SetInstance(ClipboardRecentContent* instance); |
| 30 |
23 // Returns true if the clipboard contains a recent URL that has not been | 31 // Returns true if the clipboard contains a recent URL that has not been |
24 // supressed, and copies it in |url|. Otherwise, returns false. |url| must not | 32 // supressed, and copies it in |url|. Otherwise, returns false. |url| must not |
25 // be null. | 33 // be null. |
26 virtual bool GetRecentURLFromClipboard(GURL* url) const = 0; | 34 virtual bool GetRecentURLFromClipboard(GURL* url) const = 0; |
27 | 35 |
28 // Returns how old the content of the clipboard is. | 36 // Returns how old the content of the clipboard is. |
29 virtual base::TimeDelta GetClipboardContentAge() const = 0; | 37 virtual base::TimeDelta GetClipboardContentAge() const = 0; |
30 | 38 |
31 // Prevent GetRecentURLFromClipboard from returning anything until the | 39 // Prevent GetRecentURLFromClipboard from returning anything until the |
32 // clipboard's content changed. | 40 // clipboard's content changed. |
33 virtual void SuppressClipboardContent() = 0; | 41 virtual void SuppressClipboardContent() = 0; |
34 | 42 |
35 // Sets which URL scheme this app can be opened with. Used by | |
36 // ClipboardRecentContent to determine whether or not the clipboard contains | |
37 // a relevant URL. |application_scheme| may be empty. | |
38 void set_application_scheme(const std::string& application_scheme) { | |
39 application_scheme_ = application_scheme; | |
40 } | |
41 | |
42 protected: | |
43 ClipboardRecentContent() {} | |
44 virtual ~ClipboardRecentContent() {} | |
45 // Contains the URL scheme opening the app. May be empty. | |
46 std::string application_scheme_; | |
47 | |
48 private: | 43 private: |
49 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent); | 44 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent); |
50 }; | 45 }; |
51 | 46 |
52 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_ | 47 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_ |
OLD | NEW |