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

Side by Side Diff: ui/base/clipboard/clipboard_android.cc

Issue 12041078: Clear the clipboard closing Incognito window (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge and compilation fixes Created 7 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
« no previous file with comments | « ui/base/clipboard/clipboard.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/base/clipboard/clipboard.h" 5 #include "ui/base/clipboard/clipboard.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 22 matching lines...) Expand all
33 namespace { 33 namespace {
34 // Various formats we support. 34 // Various formats we support.
35 const char kPlainTextFormat[] = "text"; 35 const char kPlainTextFormat[] = "text";
36 const char kHTMLFormat[] = "html"; 36 const char kHTMLFormat[] = "html";
37 const char kRTFFormat[] = "rtf"; 37 const char kRTFFormat[] = "rtf";
38 const char kBitmapFormat[] = "bitmap"; 38 const char kBitmapFormat[] = "bitmap";
39 const char kWebKitSmartPasteFormat[] = "webkit_smart"; 39 const char kWebKitSmartPasteFormat[] = "webkit_smart";
40 const char kBookmarkFormat[] = "bookmark"; 40 const char kBookmarkFormat[] = "bookmark";
41 const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data"; 41 const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
42 const char kMimeTypeWebCustomData[] = "chromium/x-web-custom-data"; 42 const char kMimeTypeWebCustomData[] = "chromium/x-web-custom-data";
43 const char kSourceTagFormat[] = "source_tag";
43 44
44 class ClipboardMap { 45 class ClipboardMap {
45 public: 46 public:
46 ClipboardMap(); 47 ClipboardMap();
47 std::string Get(const std::string& format); 48 std::string Get(const std::string& format);
48 bool HasFormat(const std::string& format); 49 bool HasFormat(const std::string& format);
49 void Set(const std::string& format, const std::string& data); 50 void Set(const std::string& format, const std::string& data);
50 void Clear(); 51 void Clear();
51 52
52 private: 53 private:
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return data_ == other.data_; 192 return data_ == other.data_;
192 } 193 }
193 194
194 Clipboard::Clipboard() { 195 Clipboard::Clipboard() {
195 } 196 }
196 197
197 Clipboard::~Clipboard() { 198 Clipboard::~Clipboard() {
198 } 199 }
199 200
200 // Main entry point used to write several values in the clipboard. 201 // Main entry point used to write several values in the clipboard.
201 void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) { 202 void Clipboard::WriteObjectsImpl(Buffer buffer,
203 const ObjectMap& objects,
204 SourceTag tag) {
202 DCHECK_EQ(buffer, BUFFER_STANDARD); 205 DCHECK_EQ(buffer, BUFFER_STANDARD);
203 g_map.Get().Clear(); 206 g_map.Get().Clear();
204 for (ObjectMap::const_iterator iter = objects.begin(); 207 for (ObjectMap::const_iterator iter = objects.begin();
205 iter != objects.end(); ++iter) { 208 iter != objects.end(); ++iter) {
206 DispatchObject(static_cast<ObjectType>(iter->first), iter->second); 209 DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
207 } 210 }
211 WriteSourceTag(tag);
208 } 212 }
209 213
210 uint64 Clipboard::GetSequenceNumber(Clipboard::Buffer /* buffer */) { 214 uint64 Clipboard::GetSequenceNumber(Clipboard::Buffer /* buffer */) {
211 // TODO: implement this. For now this interface will advertise 215 // TODO: implement this. For now this interface will advertise
212 // that the clipboard never changes. That's fine as long as we 216 // that the clipboard never changes. That's fine as long as we
213 // don't rely on this signal. 217 // don't rely on this signal.
214 return 0; 218 return 0;
215 } 219 }
216 220
217 bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format, 221 bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 307
304 void Clipboard::ReadBookmark(string16* title, std::string* url) const { 308 void Clipboard::ReadBookmark(string16* title, std::string* url) const {
305 NOTIMPLEMENTED(); 309 NOTIMPLEMENTED();
306 } 310 }
307 311
308 void Clipboard::ReadData(const Clipboard::FormatType& format, 312 void Clipboard::ReadData(const Clipboard::FormatType& format,
309 std::string* result) const { 313 std::string* result) const {
310 *result = g_map.Get().Get(format.data()); 314 *result = g_map.Get().Get(format.data());
311 } 315 }
312 316
317 Clipboard::SourceTag Clipboard::ReadSourceTag(Buffer buffer) const {
318 DCHECK_EQ(buffer, BUFFER_STANDARD);
319 std::string result;
320 ReadData(GetSourceTagFormatType(), &result);
321 return Binary2SourceTag(result);
322 }
323
313 // static 324 // static
314 Clipboard::FormatType Clipboard::GetFormatType( 325 Clipboard::FormatType Clipboard::GetFormatType(
315 const std::string& format_string) { 326 const std::string& format_string) {
316 return FormatType::Deserialize(format_string); 327 return FormatType::Deserialize(format_string);
317 } 328 }
318 329
319 // static 330 // static
320 const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() { 331 const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() {
321 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPlainTextFormat)); 332 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPlainTextFormat));
322 return type; 333 return type;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData)); 368 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
358 return type; 369 return type;
359 } 370 }
360 371
361 // static 372 // static
362 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { 373 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
363 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); 374 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
364 return type; 375 return type;
365 } 376 }
366 377
378 // static
379 const Clipboard::FormatType& Clipboard::GetSourceTagFormatType() {
380 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kSourceTagFormat));
381 return type;
382 }
383
367 void Clipboard::WriteText(const char* text_data, size_t text_len) { 384 void Clipboard::WriteText(const char* text_data, size_t text_len) {
368 g_map.Get().Set(kPlainTextFormat, std::string(text_data, text_len)); 385 g_map.Get().Set(kPlainTextFormat, std::string(text_data, text_len));
369 } 386 }
370 387
371 void Clipboard::WriteHTML(const char* markup_data, 388 void Clipboard::WriteHTML(const char* markup_data,
372 size_t markup_len, 389 size_t markup_len,
373 const char* url_data, 390 const char* url_data,
374 size_t url_len) { 391 size_t url_len) {
375 g_map.Get().Set(kHTMLFormat, std::string(markup_data, markup_len)); 392 g_map.Get().Set(kHTMLFormat, std::string(markup_data, markup_len));
376 } 393 }
(...skipping 26 matching lines...) Expand all
403 std::string packed(size_data, sizeof(gfx::Size)); 420 std::string packed(size_data, sizeof(gfx::Size));
404 packed += std::string(pixel_data, bm_size); 421 packed += std::string(pixel_data, bm_size);
405 g_map.Get().Set(kBitmapFormat, packed); 422 g_map.Get().Set(kBitmapFormat, packed);
406 } 423 }
407 424
408 void Clipboard::WriteData(const Clipboard::FormatType& format, 425 void Clipboard::WriteData(const Clipboard::FormatType& format,
409 const char* data_data, size_t data_len) { 426 const char* data_data, size_t data_len) {
410 g_map.Get().Set(format.data(), std::string(data_data, data_len)); 427 g_map.Get().Set(format.data(), std::string(data_data, data_len));
411 } 428 }
412 429
430 void Clipboard::WriteSourceTag(SourceTag tag) {
431 if (tag != SourceTag()) {
432 ObjectMapParam binary = SourceTag2Binary(tag);
433 WriteData(GetSourceTagFormatType(), &binary[0], binary.size());
434 }
435 }
436
413 } // namespace ui 437 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698