| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ | 5 #ifndef UI_AURA_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ |
| 6 #define UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ | 6 #define UI_AURA_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ |
| 7 | |
| 8 #include "ui/base/dragdrop/os_exchange_data.h" | |
| 9 | 7 |
| 10 #include <map> | 8 #include <map> |
| 11 #include <memory> | 9 #include <memory> |
| 12 #include <string> | 10 #include <string> |
| 13 #include <utility> | 11 #include <utility> |
| 14 #include <vector> | 12 #include <vector> |
| 15 | 13 |
| 16 #include "mojo/public/cpp/bindings/map.h" | 14 #include "mojo/public/cpp/bindings/map.h" |
| 15 #include "ui/aura/aura_export.h" |
| 16 #include "ui/base/dragdrop/os_exchange_data.h" |
| 17 #include "ui/gfx/geometry/vector2d.h" | 17 #include "ui/gfx/geometry/vector2d.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
| 19 #include "ui/views/mus/mus_export.h" | |
| 20 | 19 |
| 21 namespace views { | 20 namespace aura { |
| 22 | 21 |
| 23 // Translates chrome's requests for various data types to a platform specific | 22 // Translates chrome's requests for various data types to a platform specific |
| 24 // type. In the case of mus, this is a mapping of MIME types to byte arrays. | 23 // type. In the case of mus, this is a mapping of MIME types to byte arrays. |
| 25 // | 24 // |
| 26 // TODO(erg): In the long run, there's a lot of optimizations that we can do | 25 // TODO(erg): In the long run, there's a lot of optimizations that we can do |
| 27 // once everything targets mus. The entire model of OSExchangeDataProvider | 26 // once everything targets mus. The entire model of OSExchangeDataProvider |
| 28 // shoves all data across the wire at once whether it is needed or not. | 27 // shoves all data across the wire at once whether it is needed or not. |
| 29 class VIEWS_MUS_EXPORT OSExchangeDataProviderMus | 28 class AURA_EXPORT OSExchangeDataProviderMus |
| 30 : public ui::OSExchangeData::Provider { | 29 : public ui::OSExchangeData::Provider { |
| 31 public: | 30 public: |
| 32 using Data = std::map<std::string, std::vector<uint8_t>>; | 31 using Data = std::map<std::string, std::vector<uint8_t>>; |
| 33 | 32 |
| 34 OSExchangeDataProviderMus(); | 33 OSExchangeDataProviderMus(); |
| 35 explicit OSExchangeDataProviderMus(Data data); | 34 explicit OSExchangeDataProviderMus(Data data); |
| 36 ~OSExchangeDataProviderMus() override; | 35 ~OSExchangeDataProviderMus() override; |
| 37 | 36 |
| 38 // Returns the raw MIME type to data mapping. | 37 // Returns the raw MIME type to data mapping. |
| 39 Data GetData() const; | 38 Data GetData() const; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 bool GetFilename(base::FilePath* path) const override; | 57 bool GetFilename(base::FilePath* path) const override; |
| 59 bool GetFilenames(std::vector<ui::FileInfo>* file_names) const override; | 58 bool GetFilenames(std::vector<ui::FileInfo>* file_names) const override; |
| 60 bool GetPickledData(const ui::Clipboard::FormatType& format, | 59 bool GetPickledData(const ui::Clipboard::FormatType& format, |
| 61 base::Pickle* data) const override; | 60 base::Pickle* data) const override; |
| 62 | 61 |
| 63 bool HasString() const override; | 62 bool HasString() const override; |
| 64 bool HasURL(ui::OSExchangeData::FilenameToURLPolicy policy) const override; | 63 bool HasURL(ui::OSExchangeData::FilenameToURLPolicy policy) const override; |
| 65 bool HasFile() const override; | 64 bool HasFile() const override; |
| 66 bool HasCustomFormat(const ui::Clipboard::FormatType& format) const override; | 65 bool HasCustomFormat(const ui::Clipboard::FormatType& format) const override; |
| 67 | 66 |
| 68 // Provider doesn't have a consistent interface between operating systems; | 67 // Provider doesn't have a consistent interface between operating systems; |
| 69 // this wasn't seen as a problem when there was a single Provider subclass | 68 // this wasn't seen as a problem when there was a single Provider subclass |
| 70 // per operating system. Now we have to have at least two providers per OS, | 69 // per operating system. Now we have to have at least two providers per OS, |
| 71 // leading to the following warts, which will remain until we clean all the | 70 // leading to the following warts, which will remain until we clean all the |
| 72 // callsites up. | 71 // callsites up. |
| 73 #if (!defined(OS_CHROMEOS) && defined(USE_X11)) || defined(OS_WIN) | 72 #if (!defined(OS_CHROMEOS) && defined(USE_X11)) || defined(OS_WIN) |
| 74 void SetFileContents(const base::FilePath& filename, | 73 void SetFileContents(const base::FilePath& filename, |
| 75 const std::string& file_contents) override; | 74 const std::string& file_contents) override; |
| 76 #endif | 75 #endif |
| 77 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 78 bool GetFileContents(base::FilePath* filename, | 77 bool GetFileContents(base::FilePath* filename, |
| 79 std::string* file_contents) const override; | 78 std::string* file_contents) const override; |
| 80 bool HasFileContents() const override; | 79 bool HasFileContents() const override; |
| 81 void SetDownloadFileInfo( | 80 void SetDownloadFileInfo( |
| 82 const ui::OSExchangeData::DownloadFileInfo& download) override; | 81 const ui::OSExchangeData::DownloadFileInfo& download) override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 | 105 |
| 107 // Drag image and offset data. | 106 // Drag image and offset data. |
| 108 gfx::ImageSkia drag_image_; | 107 gfx::ImageSkia drag_image_; |
| 109 gfx::Vector2d drag_image_offset_; | 108 gfx::Vector2d drag_image_offset_; |
| 110 | 109 |
| 111 Data mime_data_; | 110 Data mime_data_; |
| 112 | 111 |
| 113 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderMus); | 112 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderMus); |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 } // namespace views | 115 } // namespace aura |
| 117 | 116 |
| 118 #endif // UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ | 117 #endif // UI_AURA_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ |
| OLD | NEW |