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

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

Issue 2801813003: Omnibox - ClipboardRecentContent - Make Proper Singleton (Closed)
Patch Set: fix iOS 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 <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 // 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
15 // 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
16 // old. 17 // old.
17 class ClipboardRecentContent { 18 class ClipboardRecentContent {
18 public: 19 public:
19 ClipboardRecentContent(); 20 ClipboardRecentContent();
20 virtual ~ClipboardRecentContent(); 21 virtual ~ClipboardRecentContent();
21 22
22 // Returns the global instance of the ClipboardRecentContent singleton. This 23 // Returns the global instance of the ClipboardRecentContent singleton. This
23 // method does *not* create the singleton and will return null if no instance 24 // method does *not* create the singleton and will return null if no instance
24 // was registered via SetInstance(). 25 // was registered via SetInstance().
25 static ClipboardRecentContent* GetInstance(); 26 static ClipboardRecentContent* GetInstance();
26 27
27 // Sets the global instance of ClipboardRecentContent singleton. 28 // Sets the global instance of ClipboardRecentContent singleton.
28 static void SetInstance(ClipboardRecentContent* instance); 29 static void SetInstance(std::unique_ptr<ClipboardRecentContent> new_instance);
29 30
30 // Returns true if the clipboard contains a recent URL that is appropriate to 31 // Returns true if the clipboard contains a recent URL that is appropriate to
31 // be suggested and has not been supressed, and copies it in |url|. 32 // be suggested and has not been supressed, and copies it in |url|.
32 // Otherwise, returns false. |url| must not be null. 33 // Otherwise, returns false. |url| must not be null.
33 virtual bool GetRecentURLFromClipboard(GURL* url) = 0; 34 virtual bool GetRecentURLFromClipboard(GURL* url) = 0;
34 35
35 // Returns how old the content of the clipboard is. 36 // Returns how old the content of the clipboard is.
36 virtual base::TimeDelta GetClipboardContentAge() const = 0; 37 virtual base::TimeDelta GetClipboardContentAge() const = 0;
37 38
38 // Prevent GetRecentURLFromClipboard from returning anything until the 39 // Prevent GetRecentURLFromClipboard from returning anything until the
39 // clipboard's content changed. 40 // clipboard's content changed.
40 virtual void SuppressClipboardContent() = 0; 41 virtual void SuppressClipboardContent() = 0;
41 42
42 protected: 43 protected:
43 // GetRecentURLFromClipboard() should never return a URL from a clipboard 44 // GetRecentURLFromClipboard() should never return a URL from a clipboard
44 // older than this. 45 // older than this.
45 const base::TimeDelta kMaximumAgeOfClipboard = base::TimeDelta::FromHours(3); 46 const base::TimeDelta kMaximumAgeOfClipboard = base::TimeDelta::FromHours(3);
46 47
47 // Returns true if the URL is appropriate to be suggested. 48 // Returns true if the URL is appropriate to be suggested.
48 static bool IsAppropriateSuggestion(const GURL& url); 49 static bool IsAppropriateSuggestion(const GURL& url);
49 50
50 private: 51 private:
51 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent); 52 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContent);
52 }; 53 };
53 54
54 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_ 55 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_H_
OLDNEW
« no previous file with comments | « components/omnibox/browser/autocomplete_controller.cc ('k') | components/open_from_clipboard/clipboard_recent_content.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698