OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/ui/webui/favicon_source.h" | 5 #include "chrome/browser/ui/webui/favicon_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "chrome/browser/favicon/favicon_service_factory.h" | 9 #include "chrome/browser/favicon/favicon_service_factory.h" |
10 #include "chrome/browser/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | | 40 history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | |
41 history::FAVICON; | 41 history::FAVICON; |
42 } | 42 } |
43 | 43 |
44 void FaviconSource::StartDataRequest(const std::string& path, | 44 void FaviconSource::StartDataRequest(const std::string& path, |
45 bool is_incognito, | 45 bool is_incognito, |
46 int request_id) { | 46 int request_id) { |
47 FaviconService* favicon_service = | 47 FaviconService* favicon_service = |
48 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 48 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
49 if (!favicon_service || path.empty()) { | 49 if (!favicon_service || path.empty()) { |
50 SendDefaultResponse(IconRequest(request_id, 16, ui::SCALE_FACTOR_NONE)); | 50 SendDefaultResponse(IconRequest(request_id, 16, ui::SCALE_FACTOR_100P)); |
51 return; | 51 return; |
52 } | 52 } |
53 | 53 |
54 int size_in_dip = gfx::kFaviconSize; | 54 int size_in_dip = gfx::kFaviconSize; |
55 ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_NONE; | 55 ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P; |
56 | 56 |
57 FaviconService::Handle handle; | 57 FaviconService::Handle handle; |
58 if (path.size() > 8 && | 58 if (path.size() > 8 && |
59 (path.substr(0, 8) == "iconurl/" || path.substr(0, 8) == "iconurl@")) { | 59 (path.substr(0, 8) == "iconurl/" || path.substr(0, 8) == "iconurl@")) { |
60 size_t prefix_length = 8; | 60 size_t prefix_length = 8; |
61 // Optional scale factor appended to iconurl, which may be @1x or @2x. | 61 // Optional scale factor appended to iconurl, which may be @1x or @2x. |
62 if (path.at(7) == '@') { | 62 if (path.at(7) == '@') { |
63 size_t slash = path.find("/"); | 63 size_t slash = path.find("/"); |
64 std::string scale_str = path.substr(8, slash - 8); | 64 std::string scale_str = path.substr(8, slash - 8); |
65 web_ui_util::ParseScaleFactor(scale_str, &scale_factor); | 65 web_ui_util::ParseScaleFactor(scale_str, &scale_factor); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 if (!default_favicon) { | 194 if (!default_favicon) { |
195 ui::ScaleFactor scale_factor = icon_request.scale_factor; | 195 ui::ScaleFactor scale_factor = icon_request.scale_factor; |
196 default_favicon = ResourceBundle::GetSharedInstance() | 196 default_favicon = ResourceBundle::GetSharedInstance() |
197 .LoadDataResourceBytesForScale(resource_id, scale_factor); | 197 .LoadDataResourceBytesForScale(resource_id, scale_factor); |
198 default_favicons_[favicon_index] = default_favicon; | 198 default_favicons_[favicon_index] = default_favicon; |
199 } | 199 } |
200 | 200 |
201 SendResponse(icon_request.request_id, default_favicon); | 201 SendResponse(icon_request.request_id, default_favicon); |
202 } | 202 } |
OLD | NEW |