| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ | 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ |
| 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ | 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ |
| 7 | 7 |
| 8 #include "ui/base/clipboard/clipboard.h" | 8 #include "ui/base/clipboard/clipboard.h" |
| 9 | 9 |
| 10 #include <jni.h> | 10 #include <jni.h> |
| 11 #include <stddef.h> | 11 #include <stddef.h> |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/time/time.h" |
| 15 | 17 |
| 16 namespace ui { | 18 namespace ui { |
| 17 | 19 |
| 18 class ClipboardAndroid : public Clipboard { | 20 class ClipboardAndroid : public Clipboard { |
| 21 public: |
| 22 // Called by Java when the Java Clipboard is notified that the clipboard has |
| 23 // changed. |
| 24 void OnPrimaryClipChanged(JNIEnv* env, |
| 25 const base::android::JavaParamRef<jobject>& obj); |
| 26 |
| 19 private: | 27 private: |
| 20 friend class Clipboard; | 28 friend class Clipboard; |
| 21 | 29 |
| 22 ClipboardAndroid(); | 30 ClipboardAndroid(); |
| 23 ~ClipboardAndroid() override; | 31 ~ClipboardAndroid() override; |
| 24 | 32 |
| 25 // Clipboard overrides: | 33 // Clipboard overrides: |
| 26 void OnPreShutdown() override; | 34 void OnPreShutdown() override; |
| 27 uint64_t GetSequenceNumber(ClipboardType type) const override; | 35 uint64_t GetSequenceNumber(ClipboardType type) const override; |
| 28 bool IsFormatAvailable(const FormatType& format, | 36 bool IsFormatAvailable(const FormatType& format, |
| 29 ClipboardType type) const override; | 37 ClipboardType type) const override; |
| 30 void Clear(ClipboardType type) override; | 38 void Clear(ClipboardType type) override; |
| 31 void ReadAvailableTypes(ClipboardType type, | 39 void ReadAvailableTypes(ClipboardType type, |
| 32 std::vector<base::string16>* types, | 40 std::vector<base::string16>* types, |
| 33 bool* contains_filenames) const override; | 41 bool* contains_filenames) const override; |
| 34 void ReadText(ClipboardType type, base::string16* result) const override; | 42 void ReadText(ClipboardType type, base::string16* result) const override; |
| 35 void ReadAsciiText(ClipboardType type, std::string* result) const override; | 43 void ReadAsciiText(ClipboardType type, std::string* result) const override; |
| 36 void ReadHTML(ClipboardType type, | 44 void ReadHTML(ClipboardType type, |
| 37 base::string16* markup, | 45 base::string16* markup, |
| 38 std::string* src_url, | 46 std::string* src_url, |
| 39 uint32_t* fragment_start, | 47 uint32_t* fragment_start, |
| 40 uint32_t* fragment_end) const override; | 48 uint32_t* fragment_end) const override; |
| 41 void ReadRTF(ClipboardType type, std::string* result) const override; | 49 void ReadRTF(ClipboardType type, std::string* result) const override; |
| 42 SkBitmap ReadImage(ClipboardType type) const override; | 50 SkBitmap ReadImage(ClipboardType type) const override; |
| 43 void ReadCustomData(ClipboardType clipboard_type, | 51 void ReadCustomData(ClipboardType clipboard_type, |
| 44 const base::string16& type, | 52 const base::string16& type, |
| 45 base::string16* result) const override; | 53 base::string16* result) const override; |
| 46 void ReadBookmark(base::string16* title, std::string* url) const override; | 54 void ReadBookmark(base::string16* title, std::string* url) const override; |
| 47 void ReadData(const FormatType& format, std::string* result) const override; | 55 void ReadData(const FormatType& format, std::string* result) const override; |
| 48 base::Time GetClipboardLastModifiedTime() const override; | 56 base::Time GetLastModifiedTime() const override; |
| 57 void ClearLastModifiedTime() override; |
| 49 void WriteObjects(ClipboardType type, const ObjectMap& objects) override; | 58 void WriteObjects(ClipboardType type, const ObjectMap& objects) override; |
| 50 void WriteText(const char* text_data, size_t text_len) override; | 59 void WriteText(const char* text_data, size_t text_len) override; |
| 51 void WriteHTML(const char* markup_data, | 60 void WriteHTML(const char* markup_data, |
| 52 size_t markup_len, | 61 size_t markup_len, |
| 53 const char* url_data, | 62 const char* url_data, |
| 54 size_t url_len) override; | 63 size_t url_len) override; |
| 55 void WriteRTF(const char* rtf_data, size_t data_len) override; | 64 void WriteRTF(const char* rtf_data, size_t data_len) override; |
| 56 void WriteBookmark(const char* title_data, | 65 void WriteBookmark(const char* title_data, |
| 57 size_t title_len, | 66 size_t title_len, |
| 58 const char* url_data, | 67 const char* url_data, |
| 59 size_t url_len) override; | 68 size_t url_len) override; |
| 60 void WriteWebSmartPaste() override; | 69 void WriteWebSmartPaste() override; |
| 61 void WriteBitmap(const SkBitmap& bitmap) override; | 70 void WriteBitmap(const SkBitmap& bitmap) override; |
| 62 void WriteData(const FormatType& format, | 71 void WriteData(const FormatType& format, |
| 63 const char* data_data, | 72 const char* data_data, |
| 64 size_t data_len) override; | 73 size_t data_len) override; |
| 65 | 74 |
| 66 DISALLOW_COPY_AND_ASSIGN(ClipboardAndroid); | 75 DISALLOW_COPY_AND_ASSIGN(ClipboardAndroid); |
| 67 }; | 76 }; |
| 68 | 77 |
| 78 // Registers the ClipboardAndroid native method. |
| 79 bool RegisterClipboardAndroid(JNIEnv* env); |
| 80 |
| 69 } // namespace ui | 81 } // namespace ui |
| 70 | 82 |
| 71 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ | 83 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ |
| OLD | NEW |