Chromium Code Reviews| 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/android/scoped_java_ref.h" |
| 15 #include "base/callback_forward.h" | |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 20 class ClipboardAndroid : public Clipboard { | 21 class ClipboardAndroid : public Clipboard { |
| 21 public: | 22 public: |
| 23 // Callback called whenever the clipboard is modified. The parameter | |
| 24 // represents the time of the modification. | |
| 25 typedef base::Callback<void(base::Time)> Modified; | |
|
Bernhard Bauer
2017/04/27 09:27:17
Nit: ModifiedCallback? Or just inline the type; it
dcheng
2017/04/27 15:25:39
Nit 2: prefer using A = B; over typedef B A;
Mark P
2017/04/27 19:25:59
Sounds good to me. Done.
| |
| 26 | |
| 22 // Called by Java when the Java Clipboard is notified that the clipboard has | 27 // Called by Java when the Java Clipboard is notified that the clipboard has |
| 23 // changed. | 28 // changed. |
| 24 void OnPrimaryClipChanged(JNIEnv* env, | 29 void OnPrimaryClipChanged(JNIEnv* env, |
| 25 const base::android::JavaParamRef<jobject>& obj); | 30 const base::android::JavaParamRef<jobject>& obj); |
| 26 | 31 |
| 32 // Sets the callback called whenever the clipboard is modified. | |
| 33 UI_BASE_EXPORT void SetModifiedCallback(Modified cb); | |
| 34 | |
| 35 // Sets the last modified time without calling the above callback. | |
| 36 UI_BASE_EXPORT void SetLastModifiedTimeWithoutRunningCallback( | |
| 37 base::Time time); | |
| 38 | |
| 27 private: | 39 private: |
| 28 friend class Clipboard; | 40 friend class Clipboard; |
| 29 | 41 |
| 30 ClipboardAndroid(); | 42 ClipboardAndroid(); |
| 31 ~ClipboardAndroid() override; | 43 ~ClipboardAndroid() override; |
| 32 | 44 |
| 33 // Clipboard overrides: | 45 // Clipboard overrides: |
| 34 void OnPreShutdown() override; | 46 void OnPreShutdown() override; |
| 35 uint64_t GetSequenceNumber(ClipboardType type) const override; | 47 uint64_t GetSequenceNumber(ClipboardType type) const override; |
| 36 bool IsFormatAvailable(const FormatType& format, | 48 bool IsFormatAvailable(const FormatType& format, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 86 |
| 75 DISALLOW_COPY_AND_ASSIGN(ClipboardAndroid); | 87 DISALLOW_COPY_AND_ASSIGN(ClipboardAndroid); |
| 76 }; | 88 }; |
| 77 | 89 |
| 78 // Registers the ClipboardAndroid native method. | 90 // Registers the ClipboardAndroid native method. |
| 79 bool RegisterClipboardAndroid(JNIEnv* env); | 91 bool RegisterClipboardAndroid(JNIEnv* env); |
| 80 | 92 |
| 81 } // namespace ui | 93 } // namespace ui |
| 82 | 94 |
| 83 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ | 95 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_ANDROID_H_ |
| OLD | NEW |