| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/x/selection_utils.h" | 5 #include "ui/base/x/selection_utils.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/i18n/icu_string_conversions.h" | 12 #include "base/i18n/icu_string_conversions.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
| 18 #include "ui/base/x/x11_util.h" | 18 #include "ui/base/x/x11_util.h" |
| 19 #include "ui/gfx/x/x11_atom_cache.h" | 19 #include "ui/gfx/x/x11_atom_cache.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 | 22 |
| 23 const char kMimeTypeMozillaURL[] = "text/x-moz-url"; |
| 23 const char kString[] = "STRING"; | 24 const char kString[] = "STRING"; |
| 24 const char kText[] = "TEXT"; | 25 const char kText[] = "TEXT"; |
| 25 const char kTextPlain[] = "text/plain"; | 26 const char kTextPlain[] = "text/plain"; |
| 26 const char kTextPlainUtf8[] = "text/plain;charset=utf-8"; | 27 const char kTextPlainUtf8[] = "text/plain;charset=utf-8"; |
| 27 const char kUtf8String[] = "UTF8_STRING"; | 28 const char kUtf8String[] = "UTF8_STRING"; |
| 28 | 29 |
| 29 const char* kSelectionDataAtoms[] = { | 30 const char* kSelectionDataAtoms[] = { |
| 30 Clipboard::kMimeTypeHTML, | 31 Clipboard::kMimeTypeHTML, |
| 31 kString, | 32 kString, |
| 32 kText, | 33 kText, |
| 33 kTextPlain, | 34 kTextPlain, |
| 34 kTextPlainUtf8, | 35 kTextPlainUtf8, |
| 35 kUtf8String, | 36 kUtf8String, |
| 36 NULL | 37 NULL |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache) { | 40 std::vector< ::Atom> GetTextAtomsFrom(const X11AtomCache* atom_cache) { |
| 40 std::vector< ::Atom> atoms; | 41 std::vector< ::Atom> atoms; |
| 41 atoms.push_back(atom_cache->GetAtom(kUtf8String)); | 42 atoms.push_back(atom_cache->GetAtom(kUtf8String)); |
| 42 atoms.push_back(atom_cache->GetAtom(kString)); | 43 atoms.push_back(atom_cache->GetAtom(kString)); |
| 43 atoms.push_back(atom_cache->GetAtom(kText)); | 44 atoms.push_back(atom_cache->GetAtom(kText)); |
| 44 atoms.push_back(atom_cache->GetAtom(kTextPlain)); | 45 atoms.push_back(atom_cache->GetAtom(kTextPlain)); |
| 45 atoms.push_back(atom_cache->GetAtom(kTextPlainUtf8)); | 46 atoms.push_back(atom_cache->GetAtom(kTextPlainUtf8)); |
| 46 return atoms; | 47 return atoms; |
| 47 } | 48 } |
| 48 | 49 |
| 49 std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache) { | 50 std::vector< ::Atom> GetURLAtomsFrom(const X11AtomCache* atom_cache) { |
| 50 std::vector< ::Atom> atoms; | 51 std::vector< ::Atom> atoms; |
| 51 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList)); | 52 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList)); |
| 52 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeMozillaURL)); | 53 atoms.push_back(atom_cache->GetAtom(kMimeTypeMozillaURL)); |
| 53 return atoms; | 54 return atoms; |
| 54 } | 55 } |
| 55 | 56 |
| 56 std::vector< ::Atom> GetURIListAtomsFrom(const X11AtomCache* atom_cache) { | 57 std::vector< ::Atom> GetURIListAtomsFrom(const X11AtomCache* atom_cache) { |
| 57 std::vector< ::Atom> atoms; | 58 std::vector< ::Atom> atoms; |
| 58 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList)); | 59 atoms.push_back(atom_cache->GetAtom(Clipboard::kMimeTypeURIList)); |
| 59 return atoms; | 60 return atoms; |
| 60 } | 61 } |
| 61 | 62 |
| 62 void GetAtomIntersection(const std::vector< ::Atom>& desired, | 63 void GetAtomIntersection(const std::vector< ::Atom>& desired, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 251 |
| 251 void SelectionData::AssignTo(std::string* result) const { | 252 void SelectionData::AssignTo(std::string* result) const { |
| 252 *result = RefCountedMemoryToString(memory_); | 253 *result = RefCountedMemoryToString(memory_); |
| 253 } | 254 } |
| 254 | 255 |
| 255 void SelectionData::AssignTo(base::string16* result) const { | 256 void SelectionData::AssignTo(base::string16* result) const { |
| 256 *result = RefCountedMemoryToString16(memory_); | 257 *result = RefCountedMemoryToString16(memory_); |
| 257 } | 258 } |
| 258 | 259 |
| 259 } // namespace ui | 260 } // namespace ui |
| OLD | NEW |