Index: chrome/common/favicon/large_icon_url_parser.cc |
diff --git a/chrome/common/favicon/large_icon_url_parser.cc b/chrome/common/favicon/large_icon_url_parser.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f45da8da42150b62a4c3160caa65ea61397dc295 |
--- /dev/null |
+++ b/chrome/common/favicon/large_icon_url_parser.cc |
@@ -0,0 +1,44 @@ |
+// 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. |
+ |
+#include "chrome/common/favicon/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 "third_party/skia/include/utils/SkParse.h" |
+#include "ui/gfx/favicon_size.h" |
+ |
+namespace chrome { |
+ |
+LargeIconUrlParser::LargeIconUrlParser() : size_in_pixels_(48) { |
+} |
+ |
+LargeIconUrlParser::~LargeIconUrlParser() { |
+} |
+ |
+bool LargeIconUrlParser::Parse(const std::string& path) { |
+ if (path.empty()) |
+ return false; |
+ |
+ size_t slash = path.find("/", 0); |
Roger McFarlane (Chromium)
2015/03/17 20:21:41
A comment that the path you expect to be given act
huangs
2015/03/18 18:01:48
Added comment in .h file and here.
|
+ if (slash == std::string::npos) |
+ return false; |
+ std::string size_str = path.substr(0, slash); |
Roger McFarlane (Chromium)
2015/03/17 20:21:41
micro-optimization:
StringPiece size_str(path.c
huangs
2015/03/18 18:01:48
Done, made Parse() take StringPiece(), and added c
|
+ if (!size_str.empty() && !base::StringToInt(size_str, &size_in_pixels_)) |
+ return false; |
+ |
+ // 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_); |
beaudoin
2015/03/17 23:59:14
url_string_ is a bit misleading here, since it's n
huangs
2015/03/18 18:01:48
I'd prefer to to this as a separate refactoring ta
beaudoin
2015/03/18 18:35:29
Acknowledged.
|
+ return true; |
+} |
+ |
+} // namespace chrome |