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

Side by Side Diff: chrome/common/favicon/big_icon_url_parser.cc

Issue 1010783002: [Icons NTP] Working prototype to fetch, store, and display big icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/favicon/big_icon_url_parser.h"
6
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h"
11 #include "third_party/skia/include/utils/SkParse.h"
12 #include "ui/gfx/favicon_size.h"
13
14 namespace chrome {
15
16 BigIconUrlParser::BigIconUrlParser() : size_in_pixels_(48) {
17 }
18
19 BigIconUrlParser::~BigIconUrlParser() {
20 }
21
22 bool BigIconUrlParser::Parse(const std::string& path) {
23 if (path.empty())
24 return false;
25
26 size_t slash = path.find("/", 0);
27 if (slash == std::string::npos)
28 return false;
29 std::string size_str = path.substr(0, slash);
30 if (!size_str.empty() && !base::StringToInt(size_str, &size_in_pixels_))
31 return false;
32
33 // Need to store the index of the URL field, so Instant Extended can translate
34 // big icon URLs using advanced parameters.
35 // Example:
36 // "chrome-search://big-icon/48/<renderer-id>/<most-visited-id>"
37 // would be translated to:
38 // "chrome-search://big-icon/48/<most-visited-item-with-given-id>".
39 path_index_ = slash + 1;
40 url_string_ = path.substr(path_index_);
41 return true;
42 }
43
44 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698