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

Unified Diff: components/open_from_clipboard/clipboard_recent_content_ios.mm

Issue 1274713003: Refactor ClipboardRecentContent singleton creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment by jif Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/open_from_clipboard/clipboard_recent_content_ios.mm
diff --git a/components/open_from_clipboard/clipboard_recent_content_ios.mm b/components/open_from_clipboard/clipboard_recent_content_ios.mm
index 80ced53c7a95de77d93d7efd00915d71009f7a8e..d27d2566eb2d3f4b2f893cdbe50c517cd46fbaef 100644
--- a/components/open_from_clipboard/clipboard_recent_content_ios.mm
+++ b/components/open_from_clipboard/clipboard_recent_content_ios.mm
@@ -2,33 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/open_from_clipboard/clipboard_recent_content_ios.h"
+#import "components/open_from_clipboard/clipboard_recent_content_ios.h"
#import <UIKit/UIKit.h>
-#include "base/ios/ios_util.h"
+#import "base/ios/ios_util.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/singleton.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/sys_string_conversions.h"
#include "base/sys_info.h"
#include "url/gurl.h"
#include "url/url_constants.h"
-ClipboardRecentContent* ClipboardRecentContent::GetInstance() {
- return ClipboardRecentContentIOS::GetInstance();
-}
-
// Bridge that forwards pasteboard change notifications to its delegate.
-@interface PasteboardNotificationListenerBridge : NSObject {
+@interface PasteboardNotificationListenerBridge : NSObject
+
+// Initialize the PasteboardNotificationListenerBridge with |delegate| which
+// must not be null.
+- (instancetype)initWithDelegate:(ClipboardRecentContentIOS*)delegate
+ NS_DESIGNATED_INITIALIZER;
+
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+@implementation PasteboardNotificationListenerBridge {
ClipboardRecentContentIOS* _delegate;
}
-@end
-@implementation PasteboardNotificationListenerBridge
+- (instancetype)init {
+ NOTREACHED();
+ return nil;
+}
-- (id)initWithDelegate:(ClipboardRecentContentIOS*)delegate {
+- (instancetype)initWithDelegate:(ClipboardRecentContentIOS*)delegate {
DCHECK(delegate);
self = [super init];
if (self) {
@@ -84,10 +92,6 @@ const char* kAuthorizedSchemes[] = {
};
} // namespace
-ClipboardRecentContentIOS* ClipboardRecentContentIOS::GetInstance() {
- return Singleton<ClipboardRecentContentIOS>::get();
-}
-
bool ClipboardRecentContentIOS::GetRecentURLFromClipboard(GURL* url) const {
DCHECK(url);
if (GetClipboardContentAge() > kMaximumAgeOfClipboard ||
@@ -127,11 +131,16 @@ void ClipboardRecentContentIOS::PasteboardChanged() {
}
}
-ClipboardRecentContentIOS::ClipboardRecentContentIOS() {
+ClipboardRecentContentIOS::ClipboardRecentContentIOS(
+ const std::string& application_scheme)
+ : application_scheme_(application_scheme) {
Init(base::TimeDelta::FromMilliseconds(base::SysInfo::Uptime()));
}
-ClipboardRecentContentIOS::ClipboardRecentContentIOS(base::TimeDelta uptime) {
+ClipboardRecentContentIOS::ClipboardRecentContentIOS(
+ const std::string& application_scheme,
+ base::TimeDelta uptime)
+ : application_scheme_(application_scheme) {
Init(uptime);
}

Powered by Google App Engine
This is Rietveld 408576698