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

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

Issue 1010783002: [Icons NTP] Working prototype to fetch, store, and display big icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaks and unit test fix. Created 5 years, 9 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 #ifndef CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_ 5 #ifndef CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
6 #define CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_ 6 #define CHROME_COMMON_FAVICON_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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "components/favicon_base/fallback_icon_style.h" 12 #include "components/favicon_base/fallback_icon_style.h"
13 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
14 #include "url/gurl.h"
15 14
16 namespace chrome { 15 namespace chrome {
17 16
18 class ParsedFallbackIconPath { 17 class ParsedFallbackIconPath {
19 public: 18 public:
20 ParsedFallbackIconPath(); 19 ParsedFallbackIconPath();
21 ~ParsedFallbackIconPath(); 20 ~ParsedFallbackIconPath();
22 21
23 const GURL& url() const { return url_; } 22 const std::string& url_string() const { return url_string_; }
24 23
25 int size_in_pixels() const { return size_in_pixels_; } 24 int size_in_pixels() const { return size_in_pixels_; }
26 25
27 const favicon_base::FallbackIconStyle& style() const { return style_; } 26 const favicon_base::FallbackIconStyle& style() const { return style_; }
28 27
28 size_t path_index() const { return path_index_; }
29
29 // 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
30 // file "chrome/browser/ui/webui/fallback_icon_source.h". 31 // file "chrome/browser/ui/webui/fallback_icon_source.h".
31 bool Parse(const std::string& path); 32 bool Parse(const std::string& path);
32 33
33 private: 34 private:
34 // Parses |specs_str|, which should be the comma-separated value portion 35 // Parses |specs_str|, which should be the comma-separated value portion
35 // in the format described at the top of the file 36 // in the format described at the top of the file
36 // "chrome/browser/ui/webui/fallback_icon_source.h". 37 // "chrome/browser/ui/webui/fallback_icon_source.h".
37 static bool ParseSpecs(const std::string& specs_str, 38 static bool ParseSpecs(const std::string& specs_str,
38 int *size, 39 int *size,
39 favicon_base::FallbackIconStyle* style); 40 favicon_base::FallbackIconStyle* style);
40 41
41 // 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,
42 // returns true and writes te result to |*color|. 43 // returns true and writes te result to |*color|.
43 static bool ParseColor(const std::string& color_str, SkColor* color); 44 static bool ParseColor(const std::string& color_str, SkColor* color);
44 45
45 friend class FallbackIconUrlParserTest; 46 friend class FallbackIconUrlParserTest;
46 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorSuccess); 47 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorSuccess);
47 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorFailure); 48 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorFailure);
48 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsEmpty); 49 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsEmpty);
49 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsPartial); 50 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsPartial);
50 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFull); 51 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFull);
51 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFailure); 52 FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFailure);
52 53
53 // The page URL the fallback icon is requested for. 54 // The page URL string the fallback icon is requested for.
54 GURL url_; 55 std::string url_string_;
55 56
56 // The size of the requested fallback icon in pixels. 57 // The size of the requested fallback icon in pixels.
57 int size_in_pixels_; 58 int size_in_pixels_;
58 59
59 // Styling specifications of fallback icon. 60 // Styling specifications of fallback icon.
60 favicon_base::FallbackIconStyle style_; 61 favicon_base::FallbackIconStyle style_;
61 62
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_;
66
62 DISALLOW_COPY_AND_ASSIGN(ParsedFallbackIconPath); 67 DISALLOW_COPY_AND_ASSIGN(ParsedFallbackIconPath);
63 }; 68 };
64 69
65 } // namespace chrome 70 } // namespace chrome
66 71
67 #endif // CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_ 72 #endif // CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/fallback_icon_source.cc ('k') | chrome/common/favicon/fallback_icon_url_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698