Index: chrome/common/favicon/favicon_url_parser.cc |
diff --git a/chrome/common/favicon/favicon_url_parser.cc b/chrome/common/favicon/favicon_url_parser.cc |
index 16d78af4e9f816f4b8984310c7bd4518c5fe9118..091a4371bcd950d316652ebcf71f052312241b02 100644 |
--- a/chrome/common/favicon/favicon_url_parser.cc |
+++ b/chrome/common/favicon/favicon_url_parser.cc |
@@ -15,6 +15,7 @@ namespace { |
// Parameters which can be used in chrome://favicon path. See file |
// "chrome/browser/ui/webui/favicon_source.h" for a description of |
// what each does. |
+const char kFallbackParameter[] = "fallback/"; |
const char kIconURLParameter[] = "iconurl/"; |
const char kLargestParameter[] = "largest/"; |
const char kOriginParameter[] = "origin/"; |
@@ -40,6 +41,7 @@ bool ParseFaviconPath(const std::string& path, |
parsed->size_in_dip = gfx::kFaviconSize; |
parsed->device_scale_factor = 1.0f; |
parsed->path_index = std::string::npos; |
+ parsed->fallback_specs_builder.reset(nullptr); |
if (path.empty()) |
return false; |
@@ -92,28 +94,39 @@ bool ParseFaviconPath(const std::string& path, |
parsed_index = slash + 1; |
} |
+ if (HasSubstringAt(path, parsed_index, kFallbackParameter)) { |
+ parsed_index += strlen(kFallbackParameter); |
+ size_t slash = path.find("/", parsed_index); |
+ if (slash == std::string::npos) |
+ return false; |
+ std::string fallback_str = path.substr(parsed_index, slash - parsed_index); |
+ parsed->fallback_specs_builder.reset( |
+ new favicon_base::FallbackIconSpecsBuilder()); |
+ if (!parsed->fallback_specs_builder->Parse(fallback_str)) |
+ return false; // Parse failed. |
+ parsed_index = slash + 1; |
+ } |
+ |
if (HasSubstringAt(path, parsed_index, kIconURLParameter)) { |
parsed_index += strlen(kIconURLParameter); |
parsed->is_icon_url = true; |
parsed->url = path.substr(parsed_index); |
- } else { |
+ } else if (HasSubstringAt(path, parsed_index, kOriginParameter)) { |
// URL requests prefixed with "origin/" are converted to a form with an |
// empty path and a valid scheme. (e.g., example.com --> |
// http://example.com/ or http://example.com/a --> http://example.com/) |
- if (HasSubstringAt(path, parsed_index, kOriginParameter)) { |
- parsed_index += strlen(kOriginParameter); |
- std::string possibly_invalid_url = path.substr(parsed_index); |
+ parsed_index += strlen(kOriginParameter); |
+ std::string possibly_invalid_url = path.substr(parsed_index); |
- // If the URL does not specify a scheme (e.g., example.com instead of |
- // http://example.com), add "http://" as a default. |
- if (!GURL(possibly_invalid_url).has_scheme()) |
- possibly_invalid_url = "http://" + possibly_invalid_url; |
+ // If the URL does not specify a scheme (e.g., example.com instead of |
+ // http://example.com), add "http://" as a default. |
+ if (!GURL(possibly_invalid_url).has_scheme()) |
+ possibly_invalid_url = "http://" + possibly_invalid_url; |
- // Strip the path beyond the top-level domain. |
- parsed->url = GURL(possibly_invalid_url).GetOrigin().spec(); |
- } else { |
- parsed->url = path.substr(parsed_index); |
- } |
+ // Strip the path beyond the top-level domain. |
+ parsed->url = GURL(possibly_invalid_url).GetOrigin().spec(); |
+ } else { |
+ parsed->url = path.substr(parsed_index); |
} |
// The parsed index needs to be returned in order to allow Instant Extended |