blob: e5adf8aa3c08937bbdaa85393fe5e56def92c814 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "components/open_from_clipboard/clipboard_recent_content.h"
#include "url/gurl.h"
@class NSArray;
@class NSDate;
@class NSUserDefaults;
@class ClipboardRecentContentImplIOS;
// IOS implementation of ClipboardRecentContent.
// A large part of the implementation is in clipboard_recent_content_impl_ios,
// a GURL-free class that is used by some of the iOS extensions. Not using GURL
// in extensions is preferable as GURL requires depending on ICU which makes the
// extensions much larger.
class ClipboardRecentContentIOS : public ClipboardRecentContent {
// |application_scheme| is the URL scheme that can be used to open the
// current application, may be empty if no such scheme exists. Used to
// determine whether or not the clipboard contains a relevant URL.
// |group_user_defaults| is the NSUserDefaults used to store information on
// pasteboard entry expiration. This information will be shared with other
// application in the application group.
ClipboardRecentContentIOS(const std::string& application_scheme,
NSUserDefaults* group_user_defaults);
// Constructor that directly takes an |implementation|. For use in tests.
explicit ClipboardRecentContentIOS(
ClipboardRecentContentImplIOS* implementation);
~ClipboardRecentContentIOS() override;
// ClipboardRecentContent implementation.
base::Optional<GURL> GetRecentURLFromClipboard() override;
base::Optional<base::string16> GetRecentTextFromClipboard() override;
base::Optional<gfx::Image> GetRecentImageFromClipboard() override;
base::TimeDelta GetClipboardContentAge() const override;
void SuppressClipboardContent() override;
void ClearClipboardContent() override;
// The implementation instance.
base::scoped_nsobject<ClipboardRecentContentImplIOS> implementation_;