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

Side by Side Diff: ui/base/x/selection_utils.cc

Issue 2930573005: Use ContainsValue() instead of std::find() in ui/android, ui/base and ui/views (Closed)
Patch Set: Changed EXPECT_FALSE to EXPECT_TRUE Created 3 years, 6 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/resource/resource_bundle.cc ('k') | ui/base/x/x11_util.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) 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>
10 #include <set> 9 #include <set>
11 10
12 #include "base/i18n/icu_string_conversions.h" 11 #include "base/i18n/icu_string_conversions.h"
13 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/stl_util.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 19
20 namespace ui { 20 namespace ui {
21 21
22 const char kString[] = "STRING"; 22 const char kString[] = "STRING";
23 const char kText[] = "TEXT"; 23 const char kText[] = "TEXT";
(...skipping 22 matching lines...) Expand all
46 std::vector< ::Atom> atoms; 46 std::vector< ::Atom> atoms;
47 atoms.push_back(GetAtom(Clipboard::kMimeTypeURIList)); 47 atoms.push_back(GetAtom(Clipboard::kMimeTypeURIList));
48 return atoms; 48 return atoms;
49 } 49 }
50 50
51 void GetAtomIntersection(const std::vector< ::Atom>& desired, 51 void GetAtomIntersection(const std::vector< ::Atom>& desired,
52 const std::vector< ::Atom>& offered, 52 const std::vector< ::Atom>& offered,
53 std::vector< ::Atom>* output) { 53 std::vector< ::Atom>* output) {
54 for (std::vector< ::Atom>::const_iterator it = desired.begin(); 54 for (std::vector< ::Atom>::const_iterator it = desired.begin();
55 it != desired.end(); ++it) { 55 it != desired.end(); ++it) {
56 std::vector< ::Atom>::const_iterator jt = 56 if (base::ContainsValue(offered, *it))
57 std::find(offered.begin(), offered.end(), *it);
58 if (jt != offered.end())
59 output->push_back(*it); 57 output->push_back(*it);
60 } 58 }
61 } 59 }
62 60
63 void AddString16ToVector(const base::string16& str, 61 void AddString16ToVector(const base::string16& str,
64 std::vector<unsigned char>* bytes) { 62 std::vector<unsigned char>* bytes) {
65 const unsigned char* front = 63 const unsigned char* front =
66 reinterpret_cast<const unsigned char*>(str.data()); 64 reinterpret_cast<const unsigned char*>(str.data());
67 bytes->insert(bytes->end(), front, front + (str.size() * 2)); 65 bytes->insert(bytes->end(), front, front + (str.size() * 2));
68 } 66 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 226
229 void SelectionData::AssignTo(std::string* result) const { 227 void SelectionData::AssignTo(std::string* result) const {
230 *result = RefCountedMemoryToString(memory_); 228 *result = RefCountedMemoryToString(memory_);
231 } 229 }
232 230
233 void SelectionData::AssignTo(base::string16* result) const { 231 void SelectionData::AssignTo(base::string16* result) const {
234 *result = RefCountedMemoryToString16(memory_); 232 *result = RefCountedMemoryToString16(memory_);
235 } 233 }
236 234
237 } // namespace ui 235 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | ui/base/x/x11_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698