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