Index: chrome/common/favicon/big_icon_url_parser.cc |
diff --git a/chrome/common/favicon/big_icon_url_parser.cc b/chrome/common/favicon/big_icon_url_parser.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c8b2dc5817bfcddd7ddaa99b244ef2515ba00ede |
--- /dev/null |
+++ b/chrome/common/favicon/big_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/big_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 { |
+ |
+BigIconUrlParser::BigIconUrlParser() : size_in_pixels_(48) { |
+} |
+ |
+BigIconUrlParser::~BigIconUrlParser() { |
+} |
+ |
+bool BigIconUrlParser::Parse(const std::string& path) { |
+ if (path.empty()) |
+ return false; |
+ |
+ size_t slash = path.find("/", 0); |
+ if (slash == std::string::npos) |
+ return false; |
+ std::string size_str = path.substr(0, slash); |
+ 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 |
+ // big icon URLs using advanced parameters. |
+ // Example: |
+ // "chrome-search://big-icon/48/<renderer-id>/<most-visited-id>" |
+ // would be translated to: |
+ // "chrome-search://big-icon/48/<most-visited-item-with-given-id>". |
+ path_index_ = slash + 1; |
+ url_string_ = path.substr(path_index_); |
+ return true; |
+} |
+ |
+} // namespace chrome |