OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_H_ |
6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_ | 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/process.h" | 14 #include "base/process.h" |
15 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "ui/base/ui_export.h" | 17 #include "ui/base/ui_export.h" |
18 | 18 |
19 #if defined(TOOLKIT_USES_GTK) | 19 #if defined(TOOLKIT_USES_GTK) |
20 #include <gdk/gdk.h> | 20 #include <gdk/gdk.h> |
21 #endif | 21 #endif |
22 | 22 |
23 #if defined(OS_ANDROID) | |
24 #include <jni.h> | |
25 | |
26 #include "base/synchronization/lock.h" | |
dcheng
2012/02/01 19:02:04
I think this can be moved to the .cc file.
Peter Beverloo
2012/02/02 12:16:11
Done.
| |
27 #endif | |
28 | |
23 namespace gfx { | 29 namespace gfx { |
24 class Size; | 30 class Size; |
25 } | 31 } |
26 | 32 |
27 class FilePath; | 33 class FilePath; |
28 class SkBitmap; | 34 class SkBitmap; |
29 | 35 |
30 #if defined(TOOLKIT_USES_GTK) | 36 #if defined(TOOLKIT_USES_GTK) |
31 typedef struct _GtkClipboard GtkClipboard; | 37 typedef struct _GtkClipboard GtkClipboard; |
32 #endif | 38 #endif |
(...skipping 26 matching lines...) Expand all Loading... | |
59 UINT ToUINT() const { return data_; } | 65 UINT ToUINT() const { return data_; } |
60 UINT data_; | 66 UINT data_; |
61 #elif defined(OS_MACOSX) | 67 #elif defined(OS_MACOSX) |
62 public: | 68 public: |
63 FormatType(const FormatType& other); | 69 FormatType(const FormatType& other); |
64 FormatType& operator=(const FormatType& other); | 70 FormatType& operator=(const FormatType& other); |
65 private: | 71 private: |
66 explicit FormatType(NSString* native_format); | 72 explicit FormatType(NSString* native_format); |
67 NSString* ToNSString() const { return data_; } | 73 NSString* ToNSString() const { return data_; } |
68 NSString* data_; | 74 NSString* data_; |
69 #elif defined(USE_AURA) | 75 #elif defined(USE_AURA) || defined(OS_ANDROID) |
70 explicit FormatType(const std::string& native_format); | 76 explicit FormatType(const std::string& native_format); |
71 const std::string& ToString() const { return data_; } | 77 const std::string& ToString() const { return data_; } |
72 std::string data_; | 78 std::string data_; |
79 #if defined(OS_ANDROID) | |
80 int compare(const std::string& str) const { return data_.compare(str); } | |
81 #endif | |
73 #elif defined(TOOLKIT_USES_GTK) | 82 #elif defined(TOOLKIT_USES_GTK) |
74 explicit FormatType(const std::string& native_format); | 83 explicit FormatType(const std::string& native_format); |
75 explicit FormatType(const GdkAtom& native_format); | 84 explicit FormatType(const GdkAtom& native_format); |
76 const GdkAtom& ToGdkAtom() const { return data_; } | 85 const GdkAtom& ToGdkAtom() const { return data_; } |
77 GdkAtom data_; | 86 GdkAtom data_; |
78 #else | 87 #else |
79 #error No FormatType definition. | 88 #error No FormatType definition. |
80 #endif | 89 #endif |
81 }; | 90 }; |
82 | 91 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 ~Clipboard(); | 167 ~Clipboard(); |
159 | 168 |
160 // Write a bunch of objects to the system clipboard. Copies are made of the | 169 // Write a bunch of objects to the system clipboard. Copies are made of the |
161 // contents of |objects|. On Windows they are copied to the system clipboard. | 170 // contents of |objects|. On Windows they are copied to the system clipboard. |
162 // On linux they are copied into a structure owned by the Clipboard object and | 171 // On linux they are copied into a structure owned by the Clipboard object and |
163 // kept until the system clipboard is set again. | 172 // kept until the system clipboard is set again. |
164 void WriteObjects(const ObjectMap& objects); | 173 void WriteObjects(const ObjectMap& objects); |
165 | 174 |
166 // On Linux/BSD, we need to know when the clipboard is set to a URL. Most | 175 // On Linux/BSD, we need to know when the clipboard is set to a URL. Most |
167 // platforms don't care. | 176 // platforms don't care. |
168 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_AURA) | 177 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_AURA) \ |
178 || defined(OS_ANDROID) | |
169 void DidWriteURL(const std::string& utf8_text) {} | 179 void DidWriteURL(const std::string& utf8_text) {} |
170 #else // !defined(OS_WIN) && !defined(OS_MACOSX) | 180 #else // !defined(OS_WIN) && !defined(OS_MACOSX) |
171 void DidWriteURL(const std::string& utf8_text); | 181 void DidWriteURL(const std::string& utf8_text); |
172 #endif | 182 #endif |
173 | 183 |
174 // Returns a sequence number which uniquely identifies clipboard state. | 184 // Returns a sequence number which uniquely identifies clipboard state. |
175 // This can be used to version the data on the clipboard and determine | 185 // This can be used to version the data on the clipboard and determine |
176 // whether it has changed. | 186 // whether it has changed. |
177 uint64 GetSequenceNumber(Buffer buffer); | 187 uint64 GetSequenceNumber(Buffer buffer); |
178 | 188 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 void SetGtkClipboard(); | 324 void SetGtkClipboard(); |
315 // Insert a mapping into clipboard_data_. | 325 // Insert a mapping into clipboard_data_. |
316 void InsertMapping(const char* key, char* data, size_t data_len); | 326 void InsertMapping(const char* key, char* data, size_t data_len); |
317 | 327 |
318 // Find the gtk clipboard for the passed buffer enum. | 328 // Find the gtk clipboard for the passed buffer enum. |
319 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const; | 329 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const; |
320 | 330 |
321 TargetMap* clipboard_data_; | 331 TargetMap* clipboard_data_; |
322 GtkClipboard* clipboard_; | 332 GtkClipboard* clipboard_; |
323 GtkClipboard* primary_selection_; | 333 GtkClipboard* primary_selection_; |
334 #elif defined(OS_ANDROID) | |
335 // Returns whether some text is available from the Android Clipboard | |
336 bool IsTextAvailableFromAndroid() const; | |
337 | |
338 // Make sure that the Android Clipboard contents matches what we think it | |
339 // should contain. If it changed, a copy occured from another application and | |
340 // all internal data is dropped. | |
341 void ValidateInternalClipboard() const; | |
342 | |
343 // Clear the Clipboard for all types. Both for Android and internal | |
344 void Clear(); | |
345 | |
346 // Clear the internal clipboard | |
347 void ClearInternalClipboard() const; | |
348 | |
349 // This private method is used to set non text key/value | |
350 void Set(const std::string& key, const std::string& value); | |
351 | |
352 // Java class and methods for the Android ClipboardManager | |
353 jobject clipboard_manager_; | |
354 jmethodID set_text_; | |
355 jmethodID has_text_; | |
356 jmethodID get_text_; | |
357 jmethodID to_string_; | |
324 #endif | 358 #endif |
325 | 359 |
326 // MIME type constants. | 360 // MIME type constants. |
327 static const char kMimeTypeText[]; | 361 static const char kMimeTypeText[]; |
328 static const char kMimeTypeHTML[]; | 362 static const char kMimeTypeHTML[]; |
329 static const char kMimeTypePNG[]; | 363 static const char kMimeTypePNG[]; |
330 | 364 |
331 DISALLOW_COPY_AND_ASSIGN(Clipboard); | 365 DISALLOW_COPY_AND_ASSIGN(Clipboard); |
332 }; | 366 }; |
333 | 367 |
334 } // namespace ui | 368 } // namespace ui |
335 | 369 |
336 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ | 370 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ |
OLD | NEW |