| 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/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 12 #include "grit/locale_settings.h" | 13 #include "grit/locale_settings.h" |
| 13 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/layout.h" | 16 #include "ui/base/layout.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 | 18 |
| 18 FaviconSource::FaviconSource(Profile* profile, IconType type) | 19 FaviconSource::FaviconSource(Profile* profile, IconType type) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 profile_ = profile->GetOriginalProfile(); | 37 profile_ = profile->GetOriginalProfile(); |
| 37 icon_types_ = type == FAVICON ? history::FAVICON : | 38 icon_types_ = type == FAVICON ? history::FAVICON : |
| 38 history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | | 39 history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | |
| 39 history::FAVICON; | 40 history::FAVICON; |
| 40 } | 41 } |
| 41 | 42 |
| 42 void FaviconSource::StartDataRequest(const std::string& path, | 43 void FaviconSource::StartDataRequest(const std::string& path, |
| 43 bool is_incognito, | 44 bool is_incognito, |
| 44 int request_id) { | 45 int request_id) { |
| 45 FaviconService* favicon_service = | 46 FaviconService* favicon_service = |
| 46 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 47 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 47 if (!favicon_service || path.empty()) { | 48 if (!favicon_service || path.empty()) { |
| 48 SendDefaultResponse(request_id); | 49 SendDefaultResponse(request_id); |
| 49 return; | 50 return; |
| 50 } | 51 } |
| 51 | 52 |
| 52 FaviconService::Handle handle; | 53 FaviconService::Handle handle; |
| 53 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") { | 54 if (path.size() > 8 && path.substr(0, 8) == "iconurl/") { |
| 54 // TODO : Change GetFavicon to support combination of IconType. | 55 // TODO : Change GetFavicon to support combination of IconType. |
| 55 handle = favicon_service->GetFavicon( | 56 handle = favicon_service->GetFavicon( |
| 56 GURL(path.substr(8)), | 57 GURL(path.substr(8)), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool FaviconSource::ShouldReplaceExistingSource() const { | 126 bool FaviconSource::ShouldReplaceExistingSource() const { |
| 126 // Leave the existing DataSource in place, otherwise we'll drop any pending | 127 // Leave the existing DataSource in place, otherwise we'll drop any pending |
| 127 // requests on the floor. | 128 // requests on the floor. |
| 128 return false; | 129 return false; |
| 129 } | 130 } |
| 130 | 131 |
| 131 void FaviconSource::OnFaviconDataAvailable( | 132 void FaviconSource::OnFaviconDataAvailable( |
| 132 FaviconService::Handle request_handle, | 133 FaviconService::Handle request_handle, |
| 133 history::FaviconData favicon) { | 134 history::FaviconData favicon) { |
| 134 FaviconService* favicon_service = | 135 FaviconService* favicon_service = |
| 135 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 136 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 136 int request_id = cancelable_consumer_.GetClientData(favicon_service, | 137 int request_id = cancelable_consumer_.GetClientData(favicon_service, |
| 137 request_handle); | 138 request_handle); |
| 138 | 139 |
| 139 if (favicon.is_valid()) { | 140 if (favicon.is_valid()) { |
| 140 // Forward the data along to the networking system. | 141 // Forward the data along to the networking system. |
| 141 SendResponse(request_id, favicon.image_data); | 142 SendResponse(request_id, favicon.image_data); |
| 142 } else { | 143 } else { |
| 143 SendDefaultResponse(request_id); | 144 SendDefaultResponse(request_id); |
| 144 } | 145 } |
| 145 } | 146 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 158 default_favicon_ = | 159 default_favicon_ = |
| 159 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 160 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 160 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); | 161 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P); |
| 161 } | 162 } |
| 162 bytes = default_favicon_; | 163 bytes = default_favicon_; |
| 163 } | 164 } |
| 164 request_size_map_.erase(request_id); | 165 request_size_map_.erase(request_id); |
| 165 | 166 |
| 166 SendResponse(request_id, bytes); | 167 SendResponse(request_id, bytes); |
| 167 } | 168 } |
| OLD | NEW |