Chromium Code Reviews| 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 mojo::String GetMimeTypeFor(const FormatType& format) const; | |
| 29 | |
| 30 bool HasMimeType(const mojo::Array<mojo::String>& available_types, | |
| 31 const std::string& type) const; | |
| 32 | |
| 33 // Clipboard overrides: | |
| 34 uint64_t GetSequenceNumber(ui::ClipboardType type) const override; | |
| 35 bool IsFormatAvailable(const FormatType& format, | |
| 36 ui::ClipboardType type) const override; | |
| 37 void Clear(ui::ClipboardType type) override; | |
| 38 void ReadAvailableTypes(ui::ClipboardType type, | |
| 39 std::vector<base::string16>* types, | |
| 40 bool* contains_filenames) const override; | |
| 41 void ReadText(ui::ClipboardType type, base::string16* result) const override; | |
| 42 void ReadAsciiText(ui::ClipboardType type, | |
| 43 std::string* result) const override; | |
| 44 void ReadHTML(ui::ClipboardType type, | |
| 45 base::string16* markup, | |
| 46 std::string* src_url, | |
| 47 uint32_t* fragment_start, | |
| 48 uint32_t* fragment_end) const override; | |
| 49 void ReadRTF(ui::ClipboardType type, std::string* result) const override; | |
| 50 SkBitmap ReadImage(ui::ClipboardType type) const override; | |
| 51 void ReadCustomData(ui::ClipboardType clipboard_type, | |
| 52 const base::string16& type, | |
| 53 base::string16* result) const override; | |
| 54 void ReadBookmark(base::string16* title, std::string* url) const override; | |
| 55 void ReadData(const FormatType& format, std::string* result) const override; | |
| 56 void WriteObjects(ui::ClipboardType type, const ObjectMap& objects) override; | |
| 57 void WriteText(const char* text_data, size_t text_len) override; | |
| 58 void WriteHTML(const char* markup_data, | |
| 59 size_t markup_len, | |
| 60 const char* url_data, | |
| 61 size_t url_len) override; | |
| 62 void WriteRTF(const char* rtf_data, size_t data_len) override; | |
| 63 void WriteBookmark(const char* title_data, | |
| 64 size_t title_len, | |
| 65 const char* url_data, | |
| 66 size_t url_len) override; | |
| 67 void WriteWebSmartPaste() override; | |
| 68 void WriteBitmap(const SkBitmap& bitmap) override; | |
| 69 void WriteData(const FormatType& format, | |
| 70 const char* data_data, | |
| 71 size_t data_len) override; | |
| 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 mojo::Map<mojo::String, mojo::Array<uint8_t>> current_clipboard_; | |
|
sky
2016/05/31 20:50:24
std::unique_ptr and DCHECK that non-null in all wr
| |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(ClipboardMus); | |
| 82 }; | |
| 83 | |
| 84 } // namespace views | |
| 85 | |
| 86 #endif // UI_VIEWS_MUS_CLIPBOARD_MUS_H_ | |
| OLD | NEW |