| OLD | NEW |
| 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 #ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_URL_PARSER_H_ | 5 #ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_URL_PARSER_H_ |
| 6 #define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_URL_PARSER_H_ | 6 #define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_URL_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 int size_in_pixels() const { return size_in_pixels_; } | 24 int size_in_pixels() const { return size_in_pixels_; } |
| 25 | 25 |
| 26 const favicon_base::FallbackIconStyle& style() const { return style_; } | 26 const favicon_base::FallbackIconStyle& style() const { return style_; } |
| 27 | 27 |
| 28 size_t path_index() const { return path_index_; } | 28 size_t path_index() const { return path_index_; } |
| 29 | 29 |
| 30 // Parses |path|, which should be in the format described at the top of the | 30 // Parses |path|, which should be in the format described at the top of the |
| 31 // file "chrome/browser/ui/webui/fallback_icon_source.h". | 31 // file "chrome/browser/ui/webui/fallback_icon_source.h". |
| 32 bool Parse(const std::string& path); | 32 bool Parse(const std::string& path); |
| 33 | 33 |
| 34 private: | |
| 35 // Parses |specs_str|, which should be the comma-separated value portion | 34 // Parses |specs_str|, which should be the comma-separated value portion |
| 36 // in the format described at the top of the file | 35 // in the format described at the top of the file |
| 37 // "chrome/browser/ui/webui/fallback_icon_source.h". | 36 // "chrome/browser/ui/webui/fallback_icon_source.h". |
| 38 static bool ParseSpecs(const std::string& specs_str, | 37 static bool ParseSpecs(const std::string& specs_str, |
| 39 int *size, | 38 int *size, |
| 40 favicon_base::FallbackIconStyle* style); | 39 favicon_base::FallbackIconStyle* style); |
| 41 | 40 |
| 41 private: |
| 42 // Helper to parse color string (e.g., "red", "#f00", "#aB0137"). On success, | 42 // Helper to parse color string (e.g., "red", "#f00", "#aB0137"). On success, |
| 43 // returns true and writes te result to |*color|. | 43 // returns true and writes te result to |*color|. |
| 44 static bool ParseColor(const std::string& color_str, SkColor* color); | 44 static bool ParseColor(const std::string& color_str, SkColor* color); |
| 45 | 45 |
| 46 friend class FallbackIconUrlParserTest; | 46 friend class FallbackIconUrlParserTest; |
| 47 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorSuccess); | 47 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorSuccess); |
| 48 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorFailure); | 48 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorFailure); |
| 49 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsEmpty); | 49 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsEmpty); |
| 50 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsPartial); | 50 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsPartial); |
| 51 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFull); | 51 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFull); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 63 // The index of the first character (relative to the path) where the the URL | 63 // The index of the first character (relative to the path) where the the URL |
| 64 // from which the fallback icon is being requested is located. | 64 // from which the fallback icon is being requested is located. |
| 65 size_t path_index_; | 65 size_t path_index_; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(ParsedFallbackIconPath); | 67 DISALLOW_COPY_AND_ASSIGN(ParsedFallbackIconPath); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace chrome | 70 } // namespace chrome |
| 71 | 71 |
| 72 #endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_URL_PARSER_H_ | 72 #endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_URL_PARSER_H_ |
| OLD | NEW |