blob: 5ba2a691e380ff822ef544b87eaf08ad2602637b [file] [log] [blame]
[email protected]c99ac682014-06-16 20:40:511// Copyright 2014 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.
4
5#ifndef UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_MAC_H_
6#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_MAC_H_
7
avi20f6a6d532015-12-23 08:05:248#include "base/macros.h"
erikchend9b76f02016-04-01 21:48:529#include "base/memory/ref_counted.h"
10#import "ui/base/clipboard/clipboard_util_mac.h"
[email protected]c99ac682014-06-16 20:40:5111#include "ui/base/dragdrop/os_exchange_data.h"
spqchancf5eeb52016-06-03 21:17:1912#include "ui/gfx/geometry/vector2d.h"
13#include "ui/gfx/image/image_skia.h"
[email protected]c99ac682014-06-16 20:40:5114
spqchancf5eeb52016-06-03 21:17:1915@class NSArray;
16@class NSData;
[email protected]b11c08bee2014-07-10 07:55:1217@class NSPasteboard;
spqchancf5eeb52016-06-03 21:17:1918@class NSString;
[email protected]b11c08bee2014-07-10 07:55:1219
[email protected]c99ac682014-06-16 20:40:5120namespace ui {
erikchend9b76f02016-04-01 21:48:5221class UniquePasteboard;
[email protected]c99ac682014-06-16 20:40:5122
23// OSExchangeData::Provider implementation for Mac.
24class UI_BASE_EXPORT OSExchangeDataProviderMac
25 : public OSExchangeData::Provider {
26 public:
27 OSExchangeDataProviderMac();
dcheng08038792014-10-21 10:53:2628 ~OSExchangeDataProviderMac() override;
[email protected]c99ac682014-06-16 20:40:5129
30 // Overridden from OSExchangeData::Provider:
erg5d3242142016-07-26 19:31:0631 std::unique_ptr<Provider> Clone() const override;
dcheng08038792014-10-21 10:53:2632 void MarkOriginatedFromRenderer() override;
33 bool DidOriginateFromRenderer() const override;
34 void SetString(const base::string16& data) override;
35 void SetURL(const GURL& url, const base::string16& title) override;
36 void SetFilename(const base::FilePath& path) override;
37 void SetFilenames(const std::vector<FileInfo>& filenames) override;
Maksim Sisova33072d22019-01-24 15:44:2538 void SetPickledData(const ClipboardFormatType& format,
brettw05cfd8ddb2015-06-02 07:02:4739 const base::Pickle& data) override;
dcheng08038792014-10-21 10:53:2640 bool GetString(base::string16* data) const override;
41 bool GetURLAndTitle(OSExchangeData::FilenameToURLPolicy policy,
42 GURL* url,
43 base::string16* title) const override;
44 bool GetFilename(base::FilePath* path) const override;
45 bool GetFilenames(std::vector<FileInfo>* filenames) const override;
Maksim Sisova33072d22019-01-24 15:44:2546 bool GetPickledData(const ClipboardFormatType& format,
brettw05cfd8ddb2015-06-02 07:02:4747 base::Pickle* data) const override;
dcheng08038792014-10-21 10:53:2648 bool HasString() const override;
49 bool HasURL(OSExchangeData::FilenameToURLPolicy policy) const override;
50 bool HasFile() const override;
Maksim Sisova33072d22019-01-24 15:44:2551 bool HasCustomFormat(const ClipboardFormatType& format) const override;
spqchancf5eeb52016-06-03 21:17:1952 void SetDragImage(const gfx::ImageSkia& image,
53 const gfx::Vector2d& cursor_offset) override;
danakje100d0232017-04-19 17:26:4754 gfx::ImageSkia GetDragImage() const override;
55 gfx::Vector2d GetDragImageOffset() const override;
spqchancf5eeb52016-06-03 21:17:1956
57 // Returns the data for the specified type in the pasteboard.
58 NSData* GetNSDataForType(NSString* type) const;
59
Avi Drissman34fe6eb2018-10-04 20:48:1460 // Gets the underlying pasteboard.
61 NSPasteboard* GetPasteboard() const;
62
jongkwon.lee67304cb2017-09-13 07:45:1163 // Returns the union of SupportedPasteboardTypes() and the types in the
64 // current pasteboard.
65 NSArray* GetAvailableTypes() const;
66
spqchancf5eeb52016-06-03 21:17:1967 // Creates an OSExchangeData object from the given NSPasteboard object.
68 static std::unique_ptr<OSExchangeData> CreateDataFromPasteboard(
69 NSPasteboard* pasteboard);
70
71 // Returns an array of pasteboard types that can be supported by
72 // OSExchangeData.
73 static NSArray* SupportedPasteboardTypes();
[email protected]c99ac682014-06-16 20:40:5174
75 private:
erikchend9b76f02016-04-01 21:48:5276 explicit OSExchangeDataProviderMac(scoped_refptr<ui::UniquePasteboard>);
77 scoped_refptr<ui::UniquePasteboard> pasteboard_;
[email protected]b11c08bee2014-07-10 07:55:1278
spqchancf5eeb52016-06-03 21:17:1979 // Drag image and offset data.
80 gfx::ImageSkia drag_image_;
81 gfx::Vector2d cursor_offset_;
82
[email protected]c99ac682014-06-16 20:40:5183 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderMac);
84};
85
86} // namespace ui
87
88#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_MAC_H_