| 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 #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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 std::string Clipboard::FormatType::Serialize() const { | 191 std::string Clipboard::FormatType::Serialize() const { |
| 192 return data_; | 192 return data_; |
| 193 } | 193 } |
| 194 | 194 |
| 195 // static | 195 // static |
| 196 Clipboard::FormatType Clipboard::FormatType::Deserialize( | 196 Clipboard::FormatType Clipboard::FormatType::Deserialize( |
| 197 const std::string& serialization) { | 197 const std::string& serialization) { |
| 198 return FormatType(serialization); | 198 return FormatType(serialization); |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool Clipboard::FormatType::operator<(const FormatType& other) const { |
| 202 return data_ < other.data_; |
| 203 } |
| 204 |
| 201 bool Clipboard::FormatType::Equals(const FormatType& other) const { | 205 bool Clipboard::FormatType::Equals(const FormatType& other) const { |
| 202 return data_ == other.data_; | 206 return data_ == other.data_; |
| 203 } | 207 } |
| 204 | 208 |
| 205 Clipboard::Clipboard() { | 209 Clipboard::Clipboard() { |
| 206 DCHECK(CalledOnValidThread()); | 210 DCHECK(CalledOnValidThread()); |
| 207 } | 211 } |
| 208 | 212 |
| 209 Clipboard::~Clipboard() { | 213 Clipboard::~Clipboard() { |
| 210 DCHECK(CalledOnValidThread()); | 214 DCHECK(CalledOnValidThread()); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 NOTIMPLEMENTED(); | 332 NOTIMPLEMENTED(); |
| 329 } | 333 } |
| 330 | 334 |
| 331 void Clipboard::ReadData(const Clipboard::FormatType& format, | 335 void Clipboard::ReadData(const Clipboard::FormatType& format, |
| 332 std::string* result) const { | 336 std::string* result) const { |
| 333 DCHECK(CalledOnValidThread()); | 337 DCHECK(CalledOnValidThread()); |
| 334 *result = g_map.Get().Get(format.data()); | 338 *result = g_map.Get().Get(format.data()); |
| 335 } | 339 } |
| 336 | 340 |
| 337 // static | 341 // static |
| 338 Clipboard::FormatType Clipboard::GetFormatType( | 342 Clipboard::FormatType Clipboard::GetFormatTypeInternal( |
| 339 const std::string& format_string) { | 343 const std::string& format_string) { |
| 340 return FormatType::Deserialize(format_string); | 344 return FormatType::Deserialize(format_string); |
| 341 } | 345 } |
| 342 | 346 |
| 343 // static | 347 // static |
| 344 const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() { | 348 const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() { |
| 345 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPlainTextFormat)); | 349 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPlainTextFormat)); |
| 346 return type; | 350 return type; |
| 347 } | 351 } |
| 348 | 352 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 371 } | 375 } |
| 372 | 376 |
| 373 // static | 377 // static |
| 374 const Clipboard::FormatType& Clipboard::GetBitmapFormatType() { | 378 const Clipboard::FormatType& Clipboard::GetBitmapFormatType() { |
| 375 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kBitmapFormat)); | 379 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kBitmapFormat)); |
| 376 return type; | 380 return type; |
| 377 } | 381 } |
| 378 | 382 |
| 379 // static | 383 // static |
| 380 const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() { | 384 const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() { |
| 381 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData)); | 385 CR_DEFINE_STATIC_LOCAL( |
| 386 FormatType, type, (GetFormatType(kMimeTypeWebCustomData))); |
| 382 return type; | 387 return type; |
| 383 } | 388 } |
| 384 | 389 |
| 385 // static | 390 // static |
| 386 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { | 391 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { |
| 387 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); | 392 CR_DEFINE_STATIC_LOCAL( |
| 393 FormatType, type, (GetFormatType(kMimeTypePepperCustomData))); |
| 388 return type; | 394 return type; |
| 389 } | 395 } |
| 390 | 396 |
| 391 void Clipboard::WriteText(const char* text_data, size_t text_len) { | 397 void Clipboard::WriteText(const char* text_data, size_t text_len) { |
| 392 g_map.Get().Set(kPlainTextFormat, std::string(text_data, text_len)); | 398 g_map.Get().Set(kPlainTextFormat, std::string(text_data, text_len)); |
| 393 } | 399 } |
| 394 | 400 |
| 395 void Clipboard::WriteHTML(const char* markup_data, | 401 void Clipboard::WriteHTML(const char* markup_data, |
| 396 size_t markup_len, | 402 size_t markup_len, |
| 397 const char* url_data, | 403 const char* url_data, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 const char* data_data, size_t data_len) { | 440 const char* data_data, size_t data_len) { |
| 435 g_map.Get().Set(format.data(), std::string(data_data, data_len)); | 441 g_map.Get().Set(format.data(), std::string(data_data, data_len)); |
| 436 } | 442 } |
| 437 | 443 |
| 438 // See clipboard_android_initialization.h for more information. | 444 // See clipboard_android_initialization.h for more information. |
| 439 bool RegisterClipboardAndroid(JNIEnv* env) { | 445 bool RegisterClipboardAndroid(JNIEnv* env) { |
| 440 return RegisterNativesImpl(env); | 446 return RegisterNativesImpl(env); |
| 441 } | 447 } |
| 442 | 448 |
| 443 } // namespace ui | 449 } // namespace ui |
| OLD | NEW |