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

Side by Side Diff: chrome/browser/ui/webui/favicon_source.cc

Issue 2856093004: Generalize content::URLDataSource so that it can be used by the network service. (Closed)
Patch Set: review comments Created 3 years, 7 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
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698