OLD | NEW |
---|---|
(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/large_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 LargeIconUrlParser::LargeIconUrlParser() : size_in_pixels_(48) { | |
17 } | |
18 | |
19 LargeIconUrlParser::~LargeIconUrlParser() { | |
20 } | |
21 | |
22 bool LargeIconUrlParser::Parse(const std::string& path) { | |
23 if (path.empty()) | |
24 return false; | |
25 | |
26 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.
| |
27 if (slash == std::string::npos) | |
28 return false; | |
29 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
| |
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 // large icon URLs using advanced parameters. | |
35 // Example: | |
36 // "chrome-search://large-icon/48/<renderer-id>/<most-visited-id>" | |
37 // would be translated to: | |
38 // "chrome-search://large-icon/48/<most-visited-item-with-given-id>". | |
39 path_index_ = slash + 1; | |
40 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.
| |
41 return true; | |
42 } | |
43 | |
44 } // namespace chrome | |
OLD | NEW |