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

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: Another clean-up Created 8 years, 11 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 "base/synchronization/lock.h"
25 #include <jni.h>
sky 2012/01/19 21:26:56 include jni.h first, then newline, then lock.h
Peter Beverloo 2012/01/20 15:13:51 Done.
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
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); }
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
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
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)
sky 2012/01/19 21:26:56 Shouldn't this be #elif?
Peter Beverloo 2012/01/20 15:13:51 Done.
335 // Java class and methods for the Android ClipboardManager
sky 2012/01/19 21:26:56 methods first, then fields.
Peter Beverloo 2012/01/20 15:13:51 Done.
336 jobject clipboard_manager_;
337 jmethodID set_text_;
338 jmethodID has_text_;
339 jmethodID get_text_;
340 jmethodID to_string_;
341
342 // Returns whether some text is available from the Android Clipboard
343 bool IsTextAvailableFromAndroid() const;
344
345 // Make sure that the Android Clipboard contents matches what we think it
346 // should contain. If it changed, a copy occured from another application and
347 // all internal data is dropped.
348 void ValidateInternalClipboard() const;
349
350 // Clear the Clipboard for all types. Both for Android and internal
351 void Clear();
352
353 // Clear the internal clipboard
354 void ClearInternalClipboard() const;
355
356 // This private method is used to set non text key/value
357 void Set(const std::string& key, const std::string& value);
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698