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

Unified Diff: components/favicon_base/large_icon_url_parser.cc

Issue 1318523011: [Password Manager] Copiable username and origin. Linkable origin elided from the left. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Icons appearance fixed Created 5 years, 2 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
Index: components/favicon_base/large_icon_url_parser.cc
diff --git a/components/favicon_base/large_icon_url_parser.cc b/components/favicon_base/large_icon_url_parser.cc
index 9f1a9ac80a4e2014e3ebdb6fe5db53fecafb5cb8..7150393df9a464047553fe4063bfe5dc10d75553 100644
--- a/components/favicon_base/large_icon_url_parser.cc
+++ b/components/favicon_base/large_icon_url_parser.cc
@@ -2,42 +2,65 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/favicon_base/large_icon_url_parser.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "components/favicon_base/fallback_icon_url_parser.h"
+#include "components/favicon_base/large_icon_url_parser.h"
#include "third_party/skia/include/utils/SkParse.h"
#include "ui/gfx/favicon_size.h"
+using chrome::ParsedFallbackIconPath;
+
+const char kFallbackIconParameter[] = "fallback/";
+
LargeIconUrlParser::LargeIconUrlParser() : size_in_pixels_(48) {
}
LargeIconUrlParser::~LargeIconUrlParser() {
}
-bool LargeIconUrlParser::Parse(base::StringPiece path) {
+bool LargeIconUrlParser::Parse(std::string path) {
if (path.empty())
return false;
size_t slash = path.find("/", 0); // |path| does not start with '/'.
- if (slash == base::StringPiece::npos)
+ if (slash == std::string::npos)
return false;
- base::StringPiece size_str = path.substr(0, slash);
+
+ std::string size_str = path.substr(0, slash);
// Disallow empty, non-numeric, or non-positive sizes.
- if (size_str.empty() ||
- !base::StringToInt(size_str, &size_in_pixels_) ||
+ if (size_str.empty() || !base::StringToInt(size_str, &size_in_pixels_) ||
size_in_pixels_ <= 0)
return false;
+ path_index_ = slash + 1;
+ // If the content of |kFallbackIconParameter| goes after the size, parse the
+ // parameters of an fallback icon. Example:
+ // 'chrome://large-icon/16/fallback/,777,FFF,0.625,0.4/http://google.com'.
+ if (path.compare(path_index_, strlen(kFallbackIconParameter),
+ kFallbackIconParameter) == 0) {
+ path_index_ += strlen(kFallbackIconParameter);
+ slash = path.find("/", path_index_);
+ // The size of icon was set before. Ignore output of ParseSpecs.
+ int ignored_icon_size;
+ if (slash == std::string::npos ||
+ !ParsedFallbackIconPath::ParseSpecs(
+ path.substr(path_index_, slash - path_index_), &ignored_icon_size,
+ &fallback_icon_style_)) {
+ return false;
+ }
+ path_index_ = slash + 1;
+ }
+
// Need to store the index of the URL field, so Instant Extended can translate
// large icon URLs using advanced parameters.
// Example:
// "chrome-search://large-icon/48/<renderer-id>/<most-visited-id>"
// would be translated to:
// "chrome-search://large-icon/48/<most-visited-item-with-given-id>".
- path_index_ = slash + 1;
- url_string_ = path.substr(path_index_).as_string();
+ url_string_ = path.substr(path_index_);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698