| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 bool FaviconSource::AllowCaching() const { | 135 bool FaviconSource::AllowCaching() const { |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool FaviconSource::ShouldReplaceExistingSource() const { | 139 bool FaviconSource::ShouldReplaceExistingSource() const { |
| 140 // Leave the existing DataSource in place, otherwise we'll drop any pending | 140 // Leave the existing DataSource in place, otherwise we'll drop any pending |
| 141 // requests on the floor. | 141 // requests on the floor. |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool FaviconSource::ShouldServiceRequest(const net::URLRequest* request) const { | 145 bool FaviconSource::ShouldServiceRequest( |
| 146 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) | 146 const GURL& url, |
| 147 return InstantIOContext::ShouldServiceRequest(request); | 147 content::ResourceContext* resource_context, |
| 148 return URLDataSource::ShouldServiceRequest(request); | 148 int render_process_id) const { |
| 149 if (url.SchemeIs(chrome::kChromeSearchScheme)) { |
| 150 return InstantIOContext::ShouldServiceRequest(url, resource_context, |
| 151 render_process_id); |
| 152 } |
| 153 return URLDataSource::ShouldServiceRequest(url, resource_context, |
| 154 render_process_id); |
| 149 } | 155 } |
| 150 | 156 |
| 151 bool FaviconSource::HandleMissingResource(const IconRequest& request) { | 157 bool FaviconSource::HandleMissingResource(const IconRequest& request) { |
| 152 // If the favicon is not available, try to use the synced favicon. | 158 // If the favicon is not available, try to use the synced favicon. |
| 153 browser_sync::ProfileSyncService* sync_service = | 159 browser_sync::ProfileSyncService* sync_service = |
| 154 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 160 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
| 155 sync_sessions::OpenTabsUIDelegate* open_tabs = | 161 sync_sessions::OpenTabsUIDelegate* open_tabs = |
| 156 sync_service ? sync_service->GetOpenTabsUIDelegate() : nullptr; | 162 sync_service ? sync_service->GetOpenTabsUIDelegate() : nullptr; |
| 157 | 163 |
| 158 scoped_refptr<base::RefCountedMemory> response; | 164 scoped_refptr<base::RefCountedMemory> response; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 break; | 201 break; |
| 196 } | 202 } |
| 197 | 203 |
| 198 base::RefCountedMemory* default_favicon = | 204 base::RefCountedMemory* default_favicon = |
| 199 ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( | 205 ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
| 200 resource_id, | 206 resource_id, |
| 201 ui::GetSupportedScaleFactor(icon_request.device_scale_factor)); | 207 ui::GetSupportedScaleFactor(icon_request.device_scale_factor)); |
| 202 | 208 |
| 203 icon_request.callback.Run(default_favicon); | 209 icon_request.callback.Run(default_favicon); |
| 204 } | 210 } |
| OLD | NEW |