Home | History | Annotate | Download | only in dragdrop
      1 // Copyright (c) 2012 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_AURA_H_
      6 #define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURA_H_
      7 
      8 #include <map>
      9 
     10 #include "base/files/file_path.h"
     11 #include "base/pickle.h"
     12 #include "ui/base/dragdrop/os_exchange_data.h"
     13 #include "ui/gfx/image/image_skia.h"
     14 #include "ui/gfx/vector2d.h"
     15 #include "url/gurl.h"
     16 
     17 namespace ui {
     18 
     19 class Clipboard;
     20 
     21 // OSExchangeData::Provider implementation for aura on linux.
     22 class UI_EXPORT OSExchangeDataProviderAura
     23     : public OSExchangeData::Provider {
     24  public:
     25   OSExchangeDataProviderAura();
     26   virtual ~OSExchangeDataProviderAura();
     27 
     28   // Overridden from OSExchangeData::Provider:
     29   virtual Provider* Clone() const OVERRIDE;
     30   virtual void SetString(const base::string16& data) OVERRIDE;
     31   virtual void SetURL(const GURL& url, const base::string16& title) OVERRIDE;
     32   virtual void SetFilename(const base::FilePath& path) OVERRIDE;
     33   virtual void SetFilenames(
     34       const std::vector<OSExchangeData::FileInfo>& filenames) OVERRIDE;
     35   virtual void SetPickledData(const OSExchangeData::CustomFormat& format,
     36                               const Pickle& data) OVERRIDE;
     37   virtual bool GetString(base::string16* data) const OVERRIDE;
     38   virtual bool GetURLAndTitle(GURL* url, base::string16* title) const OVERRIDE;
     39   virtual bool GetFilename(base::FilePath* path) const OVERRIDE;
     40   virtual bool GetFilenames(
     41       std::vector<OSExchangeData::FileInfo>* filenames) const OVERRIDE;
     42   virtual bool GetPickledData(const OSExchangeData::CustomFormat& format,
     43                               Pickle* data) const OVERRIDE;
     44   virtual bool HasString() const OVERRIDE;
     45   virtual bool HasURL() const OVERRIDE;
     46   virtual bool HasFile() const OVERRIDE;
     47   virtual bool HasCustomFormat(const OSExchangeData::CustomFormat& format) const
     48       OVERRIDE;
     49 
     50   virtual void SetHtml(const base::string16& html,
     51                        const GURL& base_url) OVERRIDE;
     52   virtual bool GetHtml(base::string16* html, GURL* base_url) const OVERRIDE;
     53   virtual bool HasHtml() const OVERRIDE;
     54   virtual void SetDragImage(const gfx::ImageSkia& image,
     55                             const gfx::Vector2d& cursor_offset) OVERRIDE;
     56   virtual const gfx::ImageSkia& GetDragImage() const OVERRIDE;
     57   virtual const gfx::Vector2d& GetDragImageOffset() const OVERRIDE;
     58 
     59  private:
     60   typedef std::map<OSExchangeData::CustomFormat, Pickle>  PickleData;
     61 
     62   // Returns true if |formats_| contains a string format and the string can be
     63   // parsed as a URL.
     64   bool GetPlainTextURL(GURL* url) const;
     65 
     66   // Actual formats that have been set. See comment above |known_formats_|
     67   // for details.
     68   int formats_;
     69 
     70   // String contents.
     71   base::string16 string_;
     72 
     73   // URL contents.
     74   GURL url_;
     75   base::string16 title_;
     76 
     77   // File name.
     78   std::vector<OSExchangeData::FileInfo> filenames_;
     79 
     80   // PICKLED_DATA contents.
     81   PickleData pickle_data_;
     82 
     83   // Drag image and offset data.
     84   gfx::ImageSkia drag_image_;
     85   gfx::Vector2d drag_image_offset_;
     86 
     87   // For HTML format
     88   base::string16 html_;
     89   GURL base_url_;
     90 
     91   DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderAura);
     92 };
     93 
     94 }  // namespace ui
     95 
     96 #endif  // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURA_H_
     97