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

Side by Side Diff: chrome/common/favicon/fallback_icon_url_parser.cc

Issue 1200053004: Move more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/common/favicon/fallback_icon_url_parser.h" 5 #include "chrome/common/favicon/fallback_icon_url_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "third_party/skia/include/utils/SkParse.h" 14 #include "third_party/skia/include/utils/SkParse.h"
15 #include "ui/gfx/favicon_size.h" 15 #include "ui/gfx/favicon_size.h"
16 16
17 namespace { 17 namespace {
18 18
19 // List of sizes corresponding to RGB, ARGB, RRGGBB, AARRGGBB. 19 // List of sizes corresponding to RGB, ARGB, RRGGBB, AARRGGBB.
20 const size_t kValidHexColorSizes[] = {3, 4, 6, 8}; 20 const size_t kValidHexColorSizes[] = {3, 4, 6, 8};
21 21
22 // Returns whether |color_str| is a valid CSS color in hex format if we prepend 22 // Returns whether |color_str| is a valid CSS color in hex format if we prepend
23 // '#', i.e., whether |color_str| matches /^[0-9A-Fa-f]{3,4,6,8}$/. 23 // '#', i.e., whether |color_str| matches /^[0-9A-Fa-f]{3,4,6,8}$/.
24 bool IsHexColorString(const std::string& color_str) { 24 bool IsHexColorString(const std::string& color_str) {
25 size_t len = color_str.length(); 25 size_t len = color_str.length();
26 const size_t* end = kValidHexColorSizes + arraysize(kValidHexColorSizes); 26 const size_t* end = kValidHexColorSizes + arraysize(kValidHexColorSizes);
27 if (std::find(kValidHexColorSizes, end, len) == end) 27 if (std::find(kValidHexColorSizes, end, len) == end)
28 return false; 28 return false;
29 for (auto ch : color_str) 29 for (auto ch : color_str) {
30 if (!IsHexDigit(ch)) 30 if (!base::IsHexDigit(ch))
31 return false; 31 return false;
32 }
32 return true; 33 return true;
33 } 34 }
34 35
35 } // namespace 36 } // namespace
36 37
37 namespace chrome { 38 namespace chrome {
38 39
39 ParsedFallbackIconPath::ParsedFallbackIconPath() 40 ParsedFallbackIconPath::ParsedFallbackIconPath()
40 : size_in_pixels_(gfx::kFaviconSize) { 41 : size_in_pixels_(gfx::kFaviconSize) {
41 } 42 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 SkColor temp_color = SK_ColorWHITE; 128 SkColor temp_color = SK_ColorWHITE;
128 const char* end = SkParse::FindColor(color_str.c_str(), &temp_color); 129 const char* end = SkParse::FindColor(color_str.c_str(), &temp_color);
129 if (end && !*end) { // Successful if call succeeds and string is consumed. 130 if (end && !*end) { // Successful if call succeeds and string is consumed.
130 *color = temp_color; 131 *color = temp_color;
131 return true; 132 return true;
132 } 133 }
133 return false; 134 return false;
134 } 135 }
135 136
136 } // namespace chrome 137 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router.cc ('k') | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698