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

Side by Side Diff: components/favicon_base/fallback_icon_url_parser.cc

Issue 2374753002: Track when fallback icon color is the default. (Closed)
Patch Set: Merge branch 'refs/heads/master' into default-color Created 4 years, 2 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 "components/favicon_base/fallback_icon_url_parser.h" 5 #include "components/favicon_base/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"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 specs_str, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); 78 specs_str, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
79 if (tokens.size() != 5) // Force "," for empty fields. 79 if (tokens.size() != 5) // Force "," for empty fields.
80 return false; 80 return false;
81 81
82 *size = gfx::kFaviconSize; 82 *size = gfx::kFaviconSize;
83 if (!tokens[0].empty() && !base::StringToInt(tokens[0], size)) 83 if (!tokens[0].empty() && !base::StringToInt(tokens[0], size))
84 return false; 84 return false;
85 if (*size <= 0) 85 if (*size <= 0)
86 return false; 86 return false;
87 87
88 if (!tokens[1].empty() && !ParseColor(tokens[1], &style->background_color)) 88 *style = favicon_base::FallbackIconStyle();
89 return false; 89
90 if (!tokens[1].empty()) {
91 style->is_default_background_color = false;
92 if (!ParseColor(tokens[1], &style->background_color))
93 return false;
94 }
90 95
91 if (tokens[2].empty()) 96 if (tokens[2].empty())
92 favicon_base::MatchFallbackIconTextColorAgainstBackgroundColor(style); 97 favicon_base::MatchFallbackIconTextColorAgainstBackgroundColor(style);
93 else if (!ParseColor(tokens[2], &style->text_color)) 98 else if (!ParseColor(tokens[2], &style->text_color))
94 return false; 99 return false;
95 100
96 if (!tokens[3].empty() && 101 if (!tokens[3].empty() &&
97 !base::StringToDouble(tokens[3], &style->font_size_ratio)) 102 !base::StringToDouble(tokens[3], &style->font_size_ratio))
98 return false; 103 return false;
99 104
(...skipping 28 matching lines...) Expand all
128 SkColor temp_color = SK_ColorWHITE; 133 SkColor temp_color = SK_ColorWHITE;
129 const char* end = SkParse::FindColor(color_str.c_str(), &temp_color); 134 const char* end = SkParse::FindColor(color_str.c_str(), &temp_color);
130 if (end && !*end) { // Successful if call succeeds and string is consumed. 135 if (end && !*end) { // Successful if call succeeds and string is consumed.
131 *color = temp_color; 136 *color = temp_color;
132 return true; 137 return true;
133 } 138 }
134 return false; 139 return false;
135 } 140 }
136 141
137 } // namespace chrome 142 } // namespace chrome
OLDNEW
« no previous file with comments | « components/favicon_base/fallback_icon_style.cc ('k') | components/favicon_base/fallback_icon_url_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698