blob: 7ee25905b855a3188e3e37aa2a86aa9f30be499f [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;
tfarina88fbdafd2015-10-05 17:25:5438 void SetPickledData(const Clipboard::FormatType& 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;
tfarina88fbdafd2015-10-05 17:25:5446 bool GetPickledData(const Clipboard::FormatType& 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;
tfarina88fbdafd2015-10-05 17:25:5451 bool HasCustomFormat(const Clipboard::FormatType& 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
jongkwon.lee67304cb2017-09-13 07:45:1160 // Returns the union of SupportedPasteboardTypes() and the types in the
61 // current pasteboard.
62 NSArray* GetAvailableTypes() const;
63
spqchancf5eeb52016-06-03 21:17:1964 // Creates an OSExchangeData object from the given NSPasteboard object.
65 static std::unique_ptr<OSExchangeData> CreateDataFromPasteboard(
66 NSPasteboard* pasteboard);
67
68 // Returns an array of pasteboard types that can be supported by
69 // OSExchangeData.
70 static NSArray* SupportedPasteboardTypes();
[email protected]c99ac682014-06-16 20:40:5171
72 private:
erikchend9b76f02016-04-01 21:48:5273 explicit OSExchangeDataProviderMac(scoped_refptr<ui::UniquePasteboard>);
74 scoped_refptr<ui::UniquePasteboard> pasteboard_;
[email protected]b11c08bee2014-07-10 07:55:1275
spqchancf5eeb52016-06-03 21:17:1976 // Drag image and offset data.
77 gfx::ImageSkia drag_image_;
78 gfx::Vector2d cursor_offset_;
79
[email protected]c99ac682014-06-16 20:40:5180 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderMac);
81};
82
83} // namespace ui
84
85#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_MAC_H_