summaryrefslogtreecommitdiffstats
path: root/ui/base/dragdrop/os_exchange_data_provider_aura.h
blob: 88218a2767b0488a56714cc83a4048fa62a883d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) 2012 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.

#ifndef UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURA_H_
#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURA_H_

#include <map>

#include "base/files/file_path.h"
#include "base/pickle.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/vector2d.h"
#include "url/gurl.h"

namespace ui {

class Clipboard;

// OSExchangeData::Provider implementation for aura on linux.
class UI_BASE_EXPORT OSExchangeDataProviderAura
    : public OSExchangeData::Provider {
 public:
  OSExchangeDataProviderAura();
  virtual ~OSExchangeDataProviderAura();

  // Overridden from OSExchangeData::Provider:
  virtual Provider* Clone() const override;
  virtual void MarkOriginatedFromRenderer() override;
  virtual bool DidOriginateFromRenderer() const override;
  virtual void SetString(const base::string16& data) override;
  virtual void SetURL(const GURL& url, const base::string16& title) override;
  virtual void SetFilename(const base::FilePath& path) override;
  virtual void SetFilenames(const std::vector<FileInfo>& filenames) override;
  virtual void SetPickledData(const OSExchangeData::CustomFormat& format,
                              const Pickle& data) override;
  virtual bool GetString(base::string16* data) const override;
  virtual bool GetURLAndTitle(OSExchangeData::FilenameToURLPolicy policy,
                              GURL* url,
                              base::string16* title) const override;
  virtual bool GetFilename(base::FilePath* path) const override;
  virtual bool GetFilenames(std::vector<FileInfo>* filenames) const override;
  virtual bool GetPickledData(const OSExchangeData::CustomFormat& format,
                              Pickle* data) const override;
  virtual bool HasString() const override;
  virtual bool HasURL(OSExchangeData::FilenameToURLPolicy policy) const
      override;
  virtual bool HasFile() const override;
  virtual bool HasCustomFormat(const OSExchangeData::CustomFormat& format) const
      override;

  virtual void SetHtml(const base::string16& html,
                       const GURL& base_url) override;
  virtual bool GetHtml(base::string16* html, GURL* base_url) const override;
  virtual bool HasHtml() const override;
  virtual void SetDragImage(const gfx::ImageSkia& image,
                            const gfx::Vector2d& cursor_offset) override;
  virtual const gfx::ImageSkia& GetDragImage() const override;
  virtual const gfx::Vector2d& GetDragImageOffset() const override;

 private:
  typedef std::map<OSExchangeData::CustomFormat, Pickle>  PickleData;

  // Returns true if |formats_| contains a string format and the string can be
  // parsed as a URL.
  bool GetPlainTextURL(GURL* url) const;

  // Actual formats that have been set. See comment above |known_formats_|
  // for details.
  int formats_;

  // String contents.
  base::string16 string_;

  // URL contents.
  GURL url_;
  base::string16 title_;

  // File name.
  std::vector<FileInfo> filenames_;

  // PICKLED_DATA contents.
  PickleData pickle_data_;

  // Drag image and offset data.
  gfx::ImageSkia drag_image_;
  gfx::Vector2d drag_image_offset_;

  // For HTML format
  base::string16 html_;
  GURL base_url_;

  DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderAura);
};

}  // namespace ui

#endif  // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURA_H_