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

Side by Side Diff: chrome/browser/ui/webui/fallback_icon_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/fallback_icon_source.h" 5 #include "chrome/browser/ui/webui/fallback_icon_source.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "chrome/browser/search/instant_io_context.h" 10 #include "chrome/browser/search/instant_io_context.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return false; 59 return false;
60 } 60 }
61 61
62 bool FallbackIconSource::ShouldReplaceExistingSource() const { 62 bool FallbackIconSource::ShouldReplaceExistingSource() const {
63 // Leave the existing DataSource in place, otherwise we'll drop any pending 63 // Leave the existing DataSource in place, otherwise we'll drop any pending
64 // requests on the floor. 64 // requests on the floor.
65 return false; 65 return false;
66 } 66 }
67 67
68 bool FallbackIconSource::ShouldServiceRequest( 68 bool FallbackIconSource::ShouldServiceRequest(
69 const net::URLRequest* request) const { 69 const GURL& url,
70 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) 70 content::ResourceContext* resource_context,
71 return InstantIOContext::ShouldServiceRequest(request); 71 int render_process_id) const {
72 return URLDataSource::ShouldServiceRequest(request); 72 if (url.SchemeIs(chrome::kChromeSearchScheme)) {
73 return InstantIOContext::ShouldServiceRequest(url, resource_context,
74 render_process_id);
75 }
76 return URLDataSource::ShouldServiceRequest(url, resource_context,
77 render_process_id);
73 } 78 }
74 79
75 void FallbackIconSource::SendFallbackIconHelper( 80 void FallbackIconSource::SendFallbackIconHelper(
76 const GURL& url, 81 const GURL& url,
77 int size_in_pixels, 82 int size_in_pixels,
78 const favicon_base::FallbackIconStyle& style, 83 const favicon_base::FallbackIconStyle& style,
79 const content::URLDataSource::GotDataCallback& callback) { 84 const content::URLDataSource::GotDataCallback& callback) {
80 if (!fallback_icon_service_) { // Can be null for tests. 85 if (!fallback_icon_service_) { // Can be null for tests.
81 callback.Run(nullptr); // Trigger "Not Found" response. 86 callback.Run(nullptr); // Trigger "Not Found" response.
82 return; 87 return;
83 } 88 }
84 std::vector<unsigned char> bitmap_data = 89 std::vector<unsigned char> bitmap_data =
85 fallback_icon_service_->RenderFallbackIconBitmap( 90 fallback_icon_service_->RenderFallbackIconBitmap(
86 url, size_in_pixels, style); 91 url, size_in_pixels, style);
87 callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data)); 92 callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data));
88 } 93 }
89 94
90 void FallbackIconSource::SendDefaultResponse( 95 void FallbackIconSource::SendDefaultResponse(
91 const content::URLDataSource::GotDataCallback& callback) { 96 const content::URLDataSource::GotDataCallback& callback) {
92 favicon_base::FallbackIconStyle default_style; 97 favicon_base::FallbackIconStyle default_style;
93 SendFallbackIconHelper(GURL(), gfx::kFaviconSize, default_style, callback); 98 SendFallbackIconHelper(GURL(), gfx::kFaviconSize, default_style, callback);
94 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698