Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ui/base/clipboard/clipboard.h

Issue 9264014: Upstream the clipboard implementation for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed dcheng's comments Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #endif
26
23 namespace gfx { 27 namespace gfx {
24 class Size; 28 class Size;
25 } 29 }
26 30
27 class FilePath; 31 class FilePath;
28 class SkBitmap; 32 class SkBitmap;
29 33
30 #if defined(TOOLKIT_USES_GTK) 34 #if defined(TOOLKIT_USES_GTK)
31 typedef struct _GtkClipboard GtkClipboard; 35 typedef struct _GtkClipboard GtkClipboard;
32 #endif 36 #endif
(...skipping 26 matching lines...) Expand all
59 UINT ToUINT() const { return data_; } 63 UINT ToUINT() const { return data_; }
60 UINT data_; 64 UINT data_;
61 #elif defined(OS_MACOSX) 65 #elif defined(OS_MACOSX)
62 public: 66 public:
63 FormatType(const FormatType& other); 67 FormatType(const FormatType& other);
64 FormatType& operator=(const FormatType& other); 68 FormatType& operator=(const FormatType& other);
65 private: 69 private:
66 explicit FormatType(NSString* native_format); 70 explicit FormatType(NSString* native_format);
67 NSString* ToNSString() const { return data_; } 71 NSString* ToNSString() const { return data_; }
68 NSString* data_; 72 NSString* data_;
69 #elif defined(USE_AURA) 73 #elif defined(USE_AURA) || defined(OS_ANDROID)
sky 2012/02/03 17:14:35 Remove defined(OS_ANDROID) here, and instead creat
Peter Beverloo 2012/02/07 12:25:03 Done.
70 explicit FormatType(const std::string& native_format); 74 explicit FormatType(const std::string& native_format);
71 const std::string& ToString() const { return data_; } 75 const std::string& ToString() const { return data_; }
72 std::string data_; 76 std::string data_;
77 #if defined(OS_ANDROID)
78 int compare(const std::string& str) const { return data_.compare(str); }
79 #endif
73 #elif defined(TOOLKIT_USES_GTK) 80 #elif defined(TOOLKIT_USES_GTK)
74 explicit FormatType(const std::string& native_format); 81 explicit FormatType(const std::string& native_format);
75 explicit FormatType(const GdkAtom& native_format); 82 explicit FormatType(const GdkAtom& native_format);
76 const GdkAtom& ToGdkAtom() const { return data_; } 83 const GdkAtom& ToGdkAtom() const { return data_; }
77 GdkAtom data_; 84 GdkAtom data_;
78 #else 85 #else
79 #error No FormatType definition. 86 #error No FormatType definition.
80 #endif 87 #endif
81 }; 88 };
82 89
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ~Clipboard(); 165 ~Clipboard();
159 166
160 // Write a bunch of objects to the system clipboard. Copies are made of the 167 // 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. 168 // 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 169 // On linux they are copied into a structure owned by the Clipboard object and
163 // kept until the system clipboard is set again. 170 // kept until the system clipboard is set again.
164 void WriteObjects(const ObjectMap& objects); 171 void WriteObjects(const ObjectMap& objects);
165 172
166 // On Linux/BSD, we need to know when the clipboard is set to a URL. Most 173 // On Linux/BSD, we need to know when the clipboard is set to a URL. Most
167 // platforms don't care. 174 // platforms don't care.
168 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_AURA) 175 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(USE_AURA) \
176 || defined(OS_ANDROID)
169 void DidWriteURL(const std::string& utf8_text) {} 177 void DidWriteURL(const std::string& utf8_text) {}
170 #else // !defined(OS_WIN) && !defined(OS_MACOSX) 178 #else // !defined(OS_WIN) && !defined(OS_MACOSX)
171 void DidWriteURL(const std::string& utf8_text); 179 void DidWriteURL(const std::string& utf8_text);
172 #endif 180 #endif
173 181
174 // Returns a sequence number which uniquely identifies clipboard state. 182 // Returns a sequence number which uniquely identifies clipboard state.
175 // This can be used to version the data on the clipboard and determine 183 // This can be used to version the data on the clipboard and determine
176 // whether it has changed. 184 // whether it has changed.
177 uint64 GetSequenceNumber(Buffer buffer); 185 uint64 GetSequenceNumber(Buffer buffer);
178 186
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 void SetGtkClipboard(); 322 void SetGtkClipboard();
315 // Insert a mapping into clipboard_data_. 323 // Insert a mapping into clipboard_data_.
316 void InsertMapping(const char* key, char* data, size_t data_len); 324 void InsertMapping(const char* key, char* data, size_t data_len);
317 325
318 // Find the gtk clipboard for the passed buffer enum. 326 // Find the gtk clipboard for the passed buffer enum.
319 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const; 327 GtkClipboard* LookupBackingClipboard(Buffer clipboard) const;
320 328
321 TargetMap* clipboard_data_; 329 TargetMap* clipboard_data_;
322 GtkClipboard* clipboard_; 330 GtkClipboard* clipboard_;
323 GtkClipboard* primary_selection_; 331 GtkClipboard* primary_selection_;
332 #elif defined(OS_ANDROID)
333 // Returns whether some text is available from the Android Clipboard
334 bool IsTextAvailableFromAndroid() const;
335
336 // Make sure that the Android Clipboard contents matches what we think it
337 // should contain. If it changed, a copy occured from another application and
338 // all internal data is dropped.
339 void ValidateInternalClipboard() const;
340
341 // Clear the Clipboard for all types. Both for Android and internal
sky 2012/02/03 17:14:35 End sentence with '.' here and everywhere.
Peter Beverloo 2012/02/07 12:25:03 Done.
342 void Clear();
343
344 // Clear the internal clipboard
345 void ClearInternalClipboard() const;
346
347 // This private method is used to set non text key/value
348 void Set(const std::string& key, const std::string& value);
349
350 // Java class and methods for the Android ClipboardManager
351 jobject clipboard_manager_;
352 jmethodID set_text_;
353 jmethodID has_text_;
354 jmethodID get_text_;
355 jmethodID to_string_;
324 #endif 356 #endif
325 357
326 // MIME type constants. 358 // MIME type constants.
327 static const char kMimeTypeText[]; 359 static const char kMimeTypeText[];
328 static const char kMimeTypeHTML[]; 360 static const char kMimeTypeHTML[];
329 static const char kMimeTypePNG[]; 361 static const char kMimeTypePNG[];
330 362
331 DISALLOW_COPY_AND_ASSIGN(Clipboard); 363 DISALLOW_COPY_AND_ASSIGN(Clipboard);
332 }; 364 };
333 365
334 } // namespace ui 366 } // namespace ui
335 367
336 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_ 368 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698