| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
| 99 | 99 |
| 100 SelectionFormatMap::SelectionFormatMap() {} | 100 SelectionFormatMap::SelectionFormatMap() {} |
| 101 | 101 |
| 102 SelectionFormatMap::~SelectionFormatMap() {} | 102 SelectionFormatMap::~SelectionFormatMap() {} |
| 103 | 103 |
| 104 void SelectionFormatMap::Insert( | 104 void SelectionFormatMap::Insert( |
| 105 ::Atom atom, | 105 ::Atom atom, |
| 106 const scoped_refptr<base::RefCountedMemory>& item) { | 106 const scoped_refptr<base::RefCountedMemory>& item) { |
| 107 data_.erase(atom); |
| 107 data_.insert(std::make_pair(atom, item)); | 108 data_.insert(std::make_pair(atom, item)); |
| 108 } | 109 } |
| 109 | 110 |
| 110 ui::SelectionData SelectionFormatMap::GetFirstOf( | 111 ui::SelectionData SelectionFormatMap::GetFirstOf( |
| 111 const std::vector< ::Atom>& requested_types) const { | 112 const std::vector< ::Atom>& requested_types) const { |
| 112 for (std::vector< ::Atom>::const_iterator it = requested_types.begin(); | 113 for (std::vector< ::Atom>::const_iterator it = requested_types.begin(); |
| 113 it != requested_types.end(); ++it) { | 114 it != requested_types.end(); ++it) { |
| 114 const_iterator data_it = data_.find(*it); | 115 const_iterator data_it = data_.find(*it); |
| 115 if (data_it != data_.end()) { | 116 if (data_it != data_.end()) { |
| 116 return SelectionData(data_it->first, data_it->second); | 117 return SelectionData(data_it->first, data_it->second); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 224 |
| 224 void SelectionData::AssignTo(std::string* result) const { | 225 void SelectionData::AssignTo(std::string* result) const { |
| 225 *result = RefCountedMemoryToString(memory_); | 226 *result = RefCountedMemoryToString(memory_); |
| 226 } | 227 } |
| 227 | 228 |
| 228 void SelectionData::AssignTo(string16* result) const { | 229 void SelectionData::AssignTo(string16* result) const { |
| 229 *result = RefCountedMemoryToString16(memory_); | 230 *result = RefCountedMemoryToString16(memory_); |
| 230 } | 231 } |
| 231 | 232 |
| 232 } // namespace ui | 233 } // namespace ui |
| OLD | NEW |