OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 package org.chromium.ui.base; | 5 package org.chromium.ui.base; |
6 | 6 |
| 7 import android.annotation.SuppressLint; |
7 import android.content.ClipData; | 8 import android.content.ClipData; |
8 import android.content.ClipDescription; | 9 import android.content.ClipDescription; |
9 import android.content.ClipboardManager; | 10 import android.content.ClipboardManager; |
10 import android.content.Context; | 11 import android.content.Context; |
11 import android.text.Html; | 12 import android.text.Html; |
12 import android.text.Spanned; | 13 import android.text.Spanned; |
13 import android.text.style.CharacterStyle; | 14 import android.text.style.CharacterStyle; |
14 import android.text.style.ParagraphStyle; | 15 import android.text.style.ParagraphStyle; |
15 import android.text.style.UpdateAppearance; | 16 import android.text.style.UpdateAppearance; |
16 | 17 |
17 import org.chromium.base.ApiCompatibilityUtils; | 18 import org.chromium.base.ApiCompatibilityUtils; |
18 import org.chromium.base.ContextUtils; | 19 import org.chromium.base.ContextUtils; |
19 import org.chromium.base.annotations.CalledByNative; | 20 import org.chromium.base.annotations.CalledByNative; |
20 import org.chromium.base.annotations.JNINamespace; | 21 import org.chromium.base.annotations.JNINamespace; |
21 import org.chromium.base.annotations.SuppressFBWarnings; | 22 import org.chromium.base.annotations.SuppressFBWarnings; |
22 import org.chromium.base.metrics.RecordUserAction; | 23 import org.chromium.base.metrics.RecordUserAction; |
23 import org.chromium.ui.R; | 24 import org.chromium.ui.R; |
24 import org.chromium.ui.widget.Toast; | 25 import org.chromium.ui.widget.Toast; |
25 | 26 |
26 /** | 27 /** |
27 * Simple proxy that provides C++ code with an access pathway to the Android cli
pboard. | 28 * Simple proxy that provides C++ code with an access pathway to the Android cli
pboard. |
28 */ | 29 */ |
29 @JNINamespace("ui") | 30 @JNINamespace("ui") |
30 public class Clipboard implements ClipboardManager.OnPrimaryClipChangedListener
{ | 31 public class Clipboard implements ClipboardManager.OnPrimaryClipChangedListener
{ |
| 32 @SuppressLint("StaticFieldLeak") |
31 private static Clipboard sInstance; | 33 private static Clipboard sInstance; |
32 | 34 |
33 // Necessary for coercing clipboard contents to text if they require | 35 // Necessary for coercing clipboard contents to text if they require |
34 // access to network resources, etceteras (e.g., URI in clipboard) | 36 // access to network resources, etceteras (e.g., URI in clipboard) |
35 private final Context mContext; | 37 private final Context mContext; |
36 | 38 |
37 private final ClipboardManager mClipboardManager; | 39 private final ClipboardManager mClipboardManager; |
38 | 40 |
39 /** | 41 /** |
40 * Get the singleton Clipboard instance (creating it if needed). | 42 * Get the singleton Clipboard instance (creating it if needed). |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 @Override | 190 @Override |
189 public void onPrimaryClipChanged() { | 191 public void onPrimaryClipChanged() { |
190 RecordUserAction.record("MobileClipboardChanged"); | 192 RecordUserAction.record("MobileClipboardChanged"); |
191 long nativeClipboardAndroid = nativeInit(); | 193 long nativeClipboardAndroid = nativeInit(); |
192 if (nativeClipboardAndroid != 0) nativeOnPrimaryClipChanged(nativeClipbo
ardAndroid); | 194 if (nativeClipboardAndroid != 0) nativeOnPrimaryClipChanged(nativeClipbo
ardAndroid); |
193 } | 195 } |
194 | 196 |
195 private native long nativeInit(); | 197 private native long nativeInit(); |
196 private native void nativeOnPrimaryClipChanged(long nativeClipboardAndroid); | 198 private native void nativeOnPrimaryClipChanged(long nativeClipboardAndroid); |
197 } | 199 } |
OLD | NEW |