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

Unified Diff: chrome/common/favicon/fallback_icon_url_parser.h

Issue 924063003: [Favicon] Adding FallbackIconUrlParser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync, to include the fix from https://codereview.chromium.org/971623003 . Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/common/favicon/fallback_icon_url_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/favicon/fallback_icon_url_parser.h
diff --git a/chrome/common/favicon/fallback_icon_url_parser.h b/chrome/common/favicon/fallback_icon_url_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..12a068f4e928e29b53fdab4ea657c7dc166cb44d
--- /dev/null
+++ b/chrome/common/favicon/fallback_icon_url_parser.h
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
+#define CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
+
+#include <string>
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "components/favicon_base/fallback_icon_style.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "url/gurl.h"
+
+namespace chrome {
+
+class ParsedFallbackIconPath {
+ public:
+ ParsedFallbackIconPath();
+ ~ParsedFallbackIconPath();
+
+ const GURL& url() const { return url_; }
+
+ int size_in_pixels() const { return size_in_pixels_; }
+
+ const favicon_base::FallbackIconStyle& style() const { return style_; }
+
+ // Parses |path|, which should be in the format described at the top of the
+ // file "chrome/browser/ui/webui/fallback_icon_source.h".
+ bool Parse(const std::string& path);
+
+ private:
+ // Parses |specs_str|, which should be the comma-separated value portion
+ // in the format described at the top of the file
+ // "chrome/browser/ui/webui/fallback_icon_source.h".
+ static bool ParseSpecs(const std::string& specs_str,
+ int *size,
+ favicon_base::FallbackIconStyle* style);
+
+ // Helper to parse color string (e.g., "red", "#f00", "#fF0000"). Returns true
+ // on success.
+ static bool ParseColor(const std::string& color_str, SkColor* color);
+
+ friend class FallbackIconUrlParserTest;
+ FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorSuccess);
+ FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseColorFailure);
+ FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsEmpty);
+ FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsPartial);
+ FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFull);
+ FRIEND_TEST_ALL_PREFIXES(FallbackIconUrlParserTest, ParseSpecsFailure);
+
+ // The page URL the fallback icon is requested for.
+ GURL url_;
+
+ // The size of the requested fallback icon in pixels.
+ int size_in_pixels_;
+
+ // Styling specifications of fallback icon.
+ favicon_base::FallbackIconStyle style_;
+
+ DISALLOW_COPY_AND_ASSIGN(ParsedFallbackIconPath);
+};
+
+} // namespace chrome
+
+#endif // CHROME_COMMON_FAVICON_FALLBACK_ICON_URL_PARSER_H_
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/common/favicon/fallback_icon_url_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698