Chromium Code Reviews| 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_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ |
| 6 #define UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ | 6 #define UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ |
| 7 | 7 |
| 8 #include "ui/base/dragdrop/os_exchange_data.h" | 8 #include "ui/base/dragdrop/os_exchange_data.h" |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/map.h" | |
| 10 #include "ui/gfx/geometry/vector2d.h" | 11 #include "ui/gfx/geometry/vector2d.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
| 13 #include "ui/views/mus/mus_export.h" | |
| 12 | 14 |
| 13 namespace views { | 15 namespace views { |
| 14 | 16 |
| 15 class OSExchangeDataProviderMus : public ui::OSExchangeData::Provider { | 17 // Translates chrome's requests for varies data types to a platform specific |
|
sky
2016/08/15 20:31:26
varies->various
| |
| 18 // type. In the case of mus, this is a mapping of MIME types to byte arrays. | |
| 19 // | |
| 20 // TODO(erg): In the long run, there's a lot of optimizations that we can do | |
| 21 // once everything targets mus. The entire model of OSExchangeDataProvider | |
| 22 // shoves all data across the wire at once whether it is needed or not. | |
| 23 class VIEWS_MUS_EXPORT OSExchangeDataProviderMus | |
|
sky
2016/08/15 20:31:26
This class isn't dependent on views. Wouldn't it m
Elliot Glaysher
2016/08/15 21:53:13
As mentioned in person, this would make //services
| |
| 24 : public ui::OSExchangeData::Provider { | |
| 16 public: | 25 public: |
| 26 using Data = std::map<std::string, std::vector<uint8_t>>; | |
| 27 | |
| 17 OSExchangeDataProviderMus(); | 28 OSExchangeDataProviderMus(); |
| 18 ~OSExchangeDataProviderMus() override; | 29 ~OSExchangeDataProviderMus() override; |
| 19 | 30 |
| 31 // Returns the raw MIME type to data mapping. | |
| 32 Data GetData() const; | |
| 33 | |
| 20 // Overridden from OSExchangeData::Provider: | 34 // Overridden from OSExchangeData::Provider: |
| 21 std::unique_ptr<Provider> Clone() const override; | 35 std::unique_ptr<Provider> Clone() const override; |
| 22 | 36 |
| 23 void MarkOriginatedFromRenderer() override; | 37 void MarkOriginatedFromRenderer() override; |
| 24 bool DidOriginateFromRenderer() const override; | 38 bool DidOriginateFromRenderer() const override; |
| 25 | 39 |
| 26 void SetString(const base::string16& data) override; | 40 void SetString(const base::string16& data) override; |
| 27 void SetURL(const GURL& url, const base::string16& title) override; | 41 void SetURL(const GURL& url, const base::string16& title) override; |
| 28 void SetFilename(const base::FilePath& path) override; | 42 void SetFilename(const base::FilePath& path) override; |
| 29 void SetFilenames(const std::vector<ui::FileInfo>& file_names) override; | 43 void SetFilenames(const std::vector<ui::FileInfo>& file_names) override; |
| 30 void SetPickledData(const ui::Clipboard::FormatType& format, | 44 void SetPickledData(const ui::Clipboard::FormatType& format, |
| 31 const base::Pickle& data) override; | 45 const base::Pickle& data) override; |
| 32 | 46 |
| 33 bool GetString(base::string16* data) const override; | 47 bool GetString(base::string16* data) const override; |
| 34 bool GetURLAndTitle(ui::OSExchangeData::FilenameToURLPolicy policy, | 48 bool GetURLAndTitle(ui::OSExchangeData::FilenameToURLPolicy policy, |
| 35 GURL* url, | 49 GURL* url, |
| 36 base::string16* title) const override; | 50 base::string16* title) const override; |
| 37 bool GetFilename(base::FilePath* path) const override; | 51 bool GetFilename(base::FilePath* path) const override; |
| 38 bool GetFilenames(std::vector<ui::FileInfo>* file_names) const override; | 52 bool GetFilenames(std::vector<ui::FileInfo>* file_names) const override; |
| 39 bool GetPickledData(const ui::Clipboard::FormatType& format, | 53 bool GetPickledData(const ui::Clipboard::FormatType& format, |
| 40 base::Pickle* data) const override; | 54 base::Pickle* data) const override; |
| 41 | 55 |
| 42 bool HasString() const override; | 56 bool HasString() const override; |
| 43 bool HasURL(ui::OSExchangeData::FilenameToURLPolicy policy) const override; | 57 bool HasURL(ui::OSExchangeData::FilenameToURLPolicy policy) const override; |
| 44 bool HasFile() const override; | 58 bool HasFile() const override; |
| 45 bool HasCustomFormat(const ui::Clipboard::FormatType& format) const override; | 59 bool HasCustomFormat(const ui::Clipboard::FormatType& format) const override; |
| 46 | 60 |
| 47 // Provider doesn't have a consistent interface between operating systems; | 61 // Provider doesn't have a consistent interface between operating systems; |
| 48 // this wasn't seen as a problem when there was a single Provider subclass | 62 // this wasn't seen as a problem when there was a single Provider subclass |
| 49 // per operating system. Now we have to have at least two providers per OS, | 63 // per operating system. Now we have to have at least two providers per OS, |
| 50 // leading to the following warts, which will remain until we clean all the | 64 // leading to the following warts, which will remain until we clean all the |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 62 #endif | 76 #endif |
| 63 | 77 |
| 64 #if defined(USE_AURA) | 78 #if defined(USE_AURA) |
| 65 void SetHtml(const base::string16& html, const GURL& base_url) override; | 79 void SetHtml(const base::string16& html, const GURL& base_url) override; |
| 66 bool GetHtml(base::string16* html, GURL* base_url) const override; | 80 bool GetHtml(base::string16* html, GURL* base_url) const override; |
| 67 bool HasHtml() const override; | 81 bool HasHtml() const override; |
| 68 #endif | 82 #endif |
| 69 | 83 |
| 70 #if defined(USE_AURA) || defined(OS_MACOSX) | 84 #if defined(USE_AURA) || defined(OS_MACOSX) |
| 71 void SetDragImage(const gfx::ImageSkia& image, | 85 void SetDragImage(const gfx::ImageSkia& image, |
| 72 const gfx::Vector2d& cursor_offset) override; | 86 const gfx::Vector2d& cursor_offset) override; |
| 73 const gfx::ImageSkia& GetDragImage() const override; | 87 const gfx::ImageSkia& GetDragImage() const override; |
| 74 const gfx::Vector2d& GetDragImageOffset() const override; | 88 const gfx::Vector2d& GetDragImageOffset() const override; |
| 75 #endif | 89 #endif |
| 76 | 90 |
| 77 private: | 91 private: |
| 92 // Returns true if |formats_| contains a file format and the file name can be | |
| 93 // parsed as a URL. | |
| 94 bool GetFileURL(GURL* url) const; | |
| 95 | |
| 96 // Returns true if |formats_| contains a string format and the string can be | |
| 97 // parsed as a URL. | |
| 98 bool GetPlainTextURL(GURL* url) const; | |
| 99 | |
| 78 // Drag image and offset data. | 100 // Drag image and offset data. |
| 79 gfx::ImageSkia drag_image_; | 101 gfx::ImageSkia drag_image_; |
| 80 gfx::Vector2d drag_image_offset_; | 102 gfx::Vector2d drag_image_offset_; |
| 81 | 103 |
| 104 Data mime_data_; | |
| 82 | 105 |
| 83 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderMus); | 106 DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderMus); |
| 84 }; | 107 }; |
| 85 | 108 |
| 86 } // namespace views | 109 } // namespace views |
| 87 | 110 |
| 88 #endif // UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ | 111 #endif // UI_VIEWS_MUS_OS_EXCHANGE_DATA_PROVIDER_MUS_H_ |
| OLD | NEW |