| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_VIEWS_MUS_CLIPBOARD_MUS_H_ |
| 6 #define UI_VIEWS_MUS_CLIPBOARD_MUS_H_ |
| 7 |
| 8 #include "components/mus/public/interfaces/clipboard.mojom.h" |
| 9 #include "ui/base/clipboard/clipboard.h" |
| 10 #include "ui/views/mus/mus_export.h" |
| 11 |
| 12 namespace shell { |
| 13 class Connector; |
| 14 } |
| 15 |
| 16 namespace views { |
| 17 |
| 18 // An adaptor class which translates the ui::Clipboard interface to the |
| 19 // clipboard provided by mus. |
| 20 class VIEWS_MUS_EXPORT ClipboardMus : public ui::Clipboard { |
| 21 public: |
| 22 ClipboardMus(); |
| 23 ~ClipboardMus() override; |
| 24 |
| 25 void Init(shell::Connector* connector); |
| 26 |
| 27 private: |
| 28 bool HasMimeType(const mojo::Array<mojo::String>& available_types, |
| 29 const std::string& type) const; |
| 30 |
| 31 // Clipboard overrides: |
| 32 uint64_t GetSequenceNumber(ui::ClipboardType type) const override; |
| 33 bool IsFormatAvailable(const FormatType& format, |
| 34 ui::ClipboardType type) const override; |
| 35 void Clear(ui::ClipboardType type) override; |
| 36 void ReadAvailableTypes(ui::ClipboardType type, |
| 37 std::vector<base::string16>* types, |
| 38 bool* contains_filenames) const override; |
| 39 void ReadText(ui::ClipboardType type, base::string16* result) const override; |
| 40 void ReadAsciiText(ui::ClipboardType type, |
| 41 std::string* result) const override; |
| 42 void ReadHTML(ui::ClipboardType type, |
| 43 base::string16* markup, |
| 44 std::string* src_url, |
| 45 uint32_t* fragment_start, |
| 46 uint32_t* fragment_end) const override; |
| 47 void ReadRTF(ui::ClipboardType type, std::string* result) const override; |
| 48 SkBitmap ReadImage(ui::ClipboardType type) const override; |
| 49 void ReadCustomData(ui::ClipboardType clipboard_type, |
| 50 const base::string16& type, |
| 51 base::string16* result) const override; |
| 52 void ReadBookmark(base::string16* title, std::string* url) const override; |
| 53 void ReadData(const FormatType& format, std::string* result) const override; |
| 54 void WriteObjects(ui::ClipboardType type, const ObjectMap& objects) override; |
| 55 void WriteText(const char* text_data, size_t text_len) override; |
| 56 void WriteHTML(const char* markup_data, |
| 57 size_t markup_len, |
| 58 const char* url_data, |
| 59 size_t url_len) override; |
| 60 void WriteRTF(const char* rtf_data, size_t data_len) override; |
| 61 void WriteBookmark(const char* title_data, |
| 62 size_t title_len, |
| 63 const char* url_data, |
| 64 size_t url_len) override; |
| 65 void WriteWebSmartPaste() override; |
| 66 void WriteBitmap(const SkBitmap& bitmap) override; |
| 67 void WriteData(const FormatType& format, |
| 68 const char* data_data, |
| 69 size_t data_len) override; |
| 70 |
| 71 static mojo::String GetMimeTypeFor(const FormatType& format); |
| 72 |
| 73 mus::mojom::ClipboardPtr clipboard_; |
| 74 |
| 75 // Internal buffer used to accumulate data types. The public interface is |
| 76 // WriteObjects(), which then calls our base class DispatchObject() which |
| 77 // then calls into each data type specific Write() function. Once we've |
| 78 // collected all the data types, we then pass this to the mus server. |
| 79 std::unique_ptr<mojo::Map<mojo::String, mojo::Array<uint8_t>>> |
| 80 current_clipboard_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(ClipboardMus); |
| 83 }; |
| 84 |
| 85 } // namespace views |
| 86 |
| 87 #endif // UI_VIEWS_MUS_CLIPBOARD_MUS_H_ |
| OLD | NEW |