Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / open_from_clipboard / clipboard_recent_content.h
blob2aee470615d456028cae9572df04f1f10d86e14f
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_
6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/time/time.h"
13 class GURL;
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
17 // old.
18 class ClipboardRecentContent {
19 public:
20 ClipboardRecentContent();
21 virtual ~ClipboardRecentContent();
23 // Returns the global instance of the ClipboardRecentContent singleton. This
24 // method does *not* create the singleton and will return null if no instance
25 // was registered via SetInstance().
26 static ClipboardRecentContent* GetInstance();
28 // Sets the global instance of ClipboardRecentContent singleton.
29 static void SetInstance(ClipboardRecentContent* instance);
31 // Returns true if the clipboard contains a recent URL that has not been
32 // supressed, and copies it in |url|. Otherwise, returns false. |url| must not
33 // be null.
34 virtual bool GetRecentURLFromClipboard(GURL* url) const = 0;
36 // Reports that the URL contained in the pasteboard was displayed.
37 virtual void RecentURLDisplayed() = 0;
39 // Returns how old the content of the clipboard is.
40 virtual base::TimeDelta GetClipboardContentAge() const = 0;
42 // Prevent GetRecentURLFromClipboard from returning anything until the
43 // clipboard's content changed.
44 virtual void SuppressClipboardContent() = 0;
46 private:
47 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent);
50 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_