OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/favicon/favicon_url_parser.h" | 5 #include "chrome/common/favicon/favicon_url_parser.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "components/favicon_base/favicon_types.h" | 8 #include "components/favicon_base/favicon_types.h" |
9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
10 #include "ui/base/webui/web_ui_util.h" | 10 #include "ui/base/webui/web_ui_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace chrome { | 33 namespace chrome { |
34 | 34 |
35 bool ParseFaviconPath(const std::string& path, | 35 bool ParseFaviconPath(const std::string& path, |
36 int icon_types, | 36 int icon_types, |
37 ParsedFaviconPath* parsed) { | 37 ParsedFaviconPath* parsed) { |
38 parsed->is_icon_url = false; | 38 parsed->is_icon_url = false; |
39 parsed->url = ""; | 39 parsed->url = ""; |
40 parsed->size_in_dip = gfx::kFaviconSize; | 40 parsed->size_in_dip = gfx::kFaviconSize; |
41 parsed->device_scale_factor = 1.0f; | 41 parsed->device_scale_factor = 1.0f; |
42 parsed->path_index = -1; | 42 parsed->path_index = std::string::npos; |
43 | 43 |
44 if (path.empty()) | 44 if (path.empty()) |
45 return false; | 45 return false; |
46 | 46 |
47 size_t parsed_index = 0; | 47 size_t parsed_index = 0; |
48 if (HasSubstringAt(path, parsed_index, kLargestParameter)) { | 48 if (HasSubstringAt(path, parsed_index, kLargestParameter)) { |
49 parsed_index += strlen(kLargestParameter); | 49 parsed_index += strlen(kLargestParameter); |
50 parsed->size_in_dip = 0; | 50 parsed->size_in_dip = 0; |
51 } else if (HasSubstringAt(path, parsed_index, kSizeParameter)) { | 51 } else if (HasSubstringAt(path, parsed_index, kSizeParameter)) { |
52 parsed_index += strlen(kSizeParameter); | 52 parsed_index += strlen(kSizeParameter); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // to translate favicon URLs using advanced parameters. | 120 // to translate favicon URLs using advanced parameters. |
121 // Example: | 121 // Example: |
122 // "chrome-search://favicon/size/16@2x/<renderer-id>/<most-visited-id>" | 122 // "chrome-search://favicon/size/16@2x/<renderer-id>/<most-visited-id>" |
123 // would be translated to: | 123 // would be translated to: |
124 // "chrome-search://favicon/size/16@2x/<most-visited-item-with-given-id>". | 124 // "chrome-search://favicon/size/16@2x/<most-visited-item-with-given-id>". |
125 parsed->path_index = parsed_index; | 125 parsed->path_index = parsed_index; |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 } // namespace chrome | 129 } // namespace chrome |
OLD | NEW |