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

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

Issue 335233003: Convert ui::ScaleFactor -> float in favicon/history code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix size_t Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 } // namespace 31 } // namespace
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->scale_factor = 1.0f; 41 parsed->device_scale_factor = 1.0f;
42 parsed->path_index = -1; 42 parsed->path_index = -1;
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)) {
(...skipping 18 matching lines...) Expand all
70 70
71 if (!base::StringToInt(size_str, &parsed->size_in_dip)) 71 if (!base::StringToInt(size_str, &parsed->size_in_dip))
72 return false; 72 return false;
73 73
74 if (parsed->size_in_dip != (gfx::kFaviconSize * 4) && 74 if (parsed->size_in_dip != (gfx::kFaviconSize * 4) &&
75 parsed->size_in_dip != (gfx::kFaviconSize * 2)) { 75 parsed->size_in_dip != (gfx::kFaviconSize * 2)) {
76 // Only 64x64, 32x32 and 16x16 icons are supported. 76 // Only 64x64, 32x32 and 16x16 icons are supported.
77 parsed->size_in_dip = gfx::kFaviconSize; 77 parsed->size_in_dip = gfx::kFaviconSize;
78 } 78 }
79 if (!scale_str.empty()) 79 if (!scale_str.empty())
80 webui::ParseScaleFactor(scale_str, &parsed->scale_factor); 80 webui::ParseScaleFactor(scale_str, &parsed->device_scale_factor);
81 81
82 // Return the default favicon (as opposed to a resized favicon) for 82 // Return the default favicon (as opposed to a resized favicon) for
83 // favicon sizes which are not cached by the favicon service. 83 // favicon sizes which are not cached by the favicon service.
84 // Currently the favicon service caches: 84 // Currently the favicon service caches:
85 // - favicons of sizes "gfx::kFaviconSize * scale factor" px of type FAVICON 85 // - favicons of sizes "gfx::kFaviconSize * scale factor" px of type FAVICON
86 // where scale factor is one of FaviconUtil::GetFaviconScaleFactors(). 86 // where scale factor is one of FaviconUtil::GetFaviconScales().
87 // - the largest TOUCH_ICON / TOUCH_PRECOMPOSED_ICON 87 // - the largest TOUCH_ICON / TOUCH_PRECOMPOSED_ICON
88 if (parsed->size_in_dip != gfx::kFaviconSize && 88 if (parsed->size_in_dip != gfx::kFaviconSize &&
89 icon_types == favicon_base::FAVICON) 89 icon_types == favicon_base::FAVICON)
90 return false; 90 return false;
91 91
92 parsed_index = slash + 1; 92 parsed_index = slash + 1;
93 } 93 }
94 94
95 if (HasSubstringAt(path, parsed_index, kIconURLParameter)) { 95 if (HasSubstringAt(path, parsed_index, kIconURLParameter)) {
96 parsed_index += strlen(kIconURLParameter); 96 parsed_index += strlen(kIconURLParameter);
(...skipping 23 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698