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

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: 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))
yzshen1 2017/05/03 21:00:18 Style nit: the if-body is multiple lines, therefor
jam 2017/05/03 21:14:41 Done.
150 return InstantIOContext::ShouldServiceRequest(url, resource_context,
151 render_process_id);
152 return URLDataSource::ShouldServiceRequest(url, resource_context,
153 render_process_id);
149 } 154 }
150 155
151 bool FaviconSource::HandleMissingResource(const IconRequest& request) { 156 bool FaviconSource::HandleMissingResource(const IconRequest& request) {
152 // If the favicon is not available, try to use the synced favicon. 157 // If the favicon is not available, try to use the synced favicon.
153 browser_sync::ProfileSyncService* sync_service = 158 browser_sync::ProfileSyncService* sync_service =
154 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 159 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
155 sync_sessions::OpenTabsUIDelegate* open_tabs = 160 sync_sessions::OpenTabsUIDelegate* open_tabs =
156 sync_service ? sync_service->GetOpenTabsUIDelegate() : nullptr; 161 sync_service ? sync_service->GetOpenTabsUIDelegate() : nullptr;
157 162
158 scoped_refptr<base::RefCountedMemory> response; 163 scoped_refptr<base::RefCountedMemory> response;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 break; 200 break;
196 } 201 }
197 202
198 base::RefCountedMemory* default_favicon = 203 base::RefCountedMemory* default_favicon =
199 ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 204 ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
200 resource_id, 205 resource_id,
201 ui::GetSupportedScaleFactor(icon_request.device_scale_factor)); 206 ui::GetSupportedScaleFactor(icon_request.device_scale_factor));
202 207
203 icon_request.callback.Run(default_favicon); 208 icon_request.callback.Run(default_favicon);
204 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698