[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / chrome / common / favicon / fallback_icon_url_parser.h
blob0e6afa9a2b58b975126967f76ef7eb174ba714f6
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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
6 #define CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
8 #include <string>
10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h"
12 #include "components/favicon_base/fallback_icon_style.h"
13 #include "third_party/skia/include/core/SkColor.h"
15 namespace chrome {
17 class ParsedFallbackIconPath {
18 public:
19 ParsedFallbackIconPath();
20 ~ParsedFallbackIconPath();
22 const std::string& url_string() const { return url_string_; }
24 int size_in_pixels() const { return size_in_pixels_; }
26 const favicon_base::FallbackIconStyle& style() const { return style_; }
28 size_t path_index() const { return path_index_; }
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".
32 bool Parse(const std::string& path);
34 private:
35 // Parses |specs_str|, which should be the comma-separated value portion
36 // in the format described at the top of the file
37 // "chrome/browser/ui/webui/fallback_icon_source.h".
38 static bool ParseSpecs(const std::string& specs_str,
39 int *size,
40 favicon_base::FallbackIconStyle* style);
42 // Helper to parse color string (e.g., "red", "#f00", "#aB0137"). On success,
43 // returns true and writes te result to |*color|.
44 static bool ParseColor(const std::string& color_str, SkColor* color);
46 friend class FallbackIconUrlParserTest;
47 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorSuccess);
48 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorFailure);
49 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsEmpty);
50 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsPartial);
51 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFull);
52 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFailure);
54 // The page URL string the fallback icon is requested for.
55 std::string url_string_;
57 // The size of the requested fallback icon in pixels.
58 int size_in_pixels_;
60 // Styling specifications of fallback icon.
61 favicon_base::FallbackIconStyle style_;
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.
65 size_t path_index_;
67 DISALLOW_COPY_AND_ASSIGN(ParsedFallbackIconPath);
70 } // namespace chrome
72 #endif // CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_