| OLD | NEW |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 SendFallbackIconHelper( | 48 SendFallbackIconHelper( |
| 49 url, parsed.size_in_pixels(), parsed.style(), callback); | 49 url, parsed.size_in_pixels(), parsed.style(), callback); |
| 50 } | 50 } |
| 51 | 51 |
| 52 std::string FallbackIconSource::GetMimeType(const std::string&) const { | 52 std::string FallbackIconSource::GetMimeType(const std::string&) const { |
| 53 // We need to explicitly return a mime type, otherwise if the user tries to | 53 // We need to explicitly return a mime type, otherwise if the user tries to |
| 54 // drag the image they get no extension. | 54 // drag the image they get no extension. |
| 55 return "image/png"; | 55 return "image/png"; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool FallbackIconSource::AllowCaching() const { |
| 59 return false; |
| 60 } |
| 61 |
| 58 bool FallbackIconSource::ShouldReplaceExistingSource() const { | 62 bool FallbackIconSource::ShouldReplaceExistingSource() const { |
| 59 // 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 |
| 60 // requests on the floor. | 64 // requests on the floor. |
| 61 return false; | 65 return false; |
| 62 } | 66 } |
| 63 | 67 |
| 64 bool FallbackIconSource::ShouldServiceRequest( | 68 bool FallbackIconSource::ShouldServiceRequest( |
| 65 const net::URLRequest* request) const { | 69 const net::URLRequest* request) const { |
| 66 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) | 70 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) |
| 67 return InstantIOContext::ShouldServiceRequest(request); | 71 return InstantIOContext::ShouldServiceRequest(request); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 81 fallback_icon_service_->RenderFallbackIconBitmap( | 85 fallback_icon_service_->RenderFallbackIconBitmap( |
| 82 url, size_in_pixels, style); | 86 url, size_in_pixels, style); |
| 83 callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data)); | 87 callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data)); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void FallbackIconSource::SendDefaultResponse( | 90 void FallbackIconSource::SendDefaultResponse( |
| 87 const content::URLDataSource::GotDataCallback& callback) { | 91 const content::URLDataSource::GotDataCallback& callback) { |
| 88 favicon_base::FallbackIconStyle default_style; | 92 favicon_base::FallbackIconStyle default_style; |
| 89 SendFallbackIconHelper(GURL(), gfx::kFaviconSize, default_style, callback); | 93 SendFallbackIconHelper(GURL(), gfx::kFaviconSize, default_style, callback); |
| 90 } | 94 } |
| OLD | NEW |