| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/thumbnails/thumbnail_list_source.h" | 5 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 scoped_refptr<base::SingleThreadTaskRunner> | 118 scoped_refptr<base::SingleThreadTaskRunner> |
| 119 ThumbnailListSource::TaskRunnerForRequestPath(const std::string& path) const { | 119 ThumbnailListSource::TaskRunnerForRequestPath(const std::string& path) const { |
| 120 // TopSites can be accessed from the IO thread. | 120 // TopSites can be accessed from the IO thread. |
| 121 return thumbnail_service_.get() | 121 return thumbnail_service_.get() |
| 122 ? nullptr | 122 ? nullptr |
| 123 : content::URLDataSource::TaskRunnerForRequestPath(path); | 123 : content::URLDataSource::TaskRunnerForRequestPath(path); |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool ThumbnailListSource::ShouldServiceRequest( | 126 bool ThumbnailListSource::ShouldServiceRequest( |
| 127 const net::URLRequest* request) const { | 127 const GURL& url, |
| 128 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) | 128 content::ResourceContext* resource_context, |
| 129 return InstantIOContext::ShouldServiceRequest(request); | 129 int render_process_id) const { |
| 130 return URLDataSource::ShouldServiceRequest(request); | 130 if (url.SchemeIs(chrome::kChromeSearchScheme)) { |
| 131 return InstantIOContext::ShouldServiceRequest(url, resource_context, |
| 132 render_process_id); |
| 133 } |
| 134 return URLDataSource::ShouldServiceRequest(url, resource_context, |
| 135 render_process_id); |
| 131 } | 136 } |
| 132 | 137 |
| 133 bool ThumbnailListSource::ShouldReplaceExistingSource() const { | 138 bool ThumbnailListSource::ShouldReplaceExistingSource() const { |
| 134 return false; | 139 return false; |
| 135 } | 140 } |
| 136 | 141 |
| 137 void ThumbnailListSource::OnMostVisitedURLsAvailable( | 142 void ThumbnailListSource::OnMostVisitedURLsAvailable( |
| 138 const content::URLDataSource::GotDataCallback& callback, | 143 const content::URLDataSource::GotDataCallback& callback, |
| 139 const history::MostVisitedURLList& mvurl_list) { | 144 const history::MostVisitedURLList& mvurl_list) { |
| 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 145 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 163 } | 168 } |
| 164 if (num_mv_with_thumb < num_mv) { | 169 if (num_mv_with_thumb < num_mv) { |
| 165 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); | 170 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); |
| 166 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); | 171 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); |
| 167 } | 172 } |
| 168 out.push_back(kHtmlFooter); | 173 out.push_back(kHtmlFooter); |
| 169 | 174 |
| 170 std::string out_html = base::JoinString(out, base::StringPiece()); | 175 std::string out_html = base::JoinString(out, base::StringPiece()); |
| 171 callback.Run(base::RefCountedString::TakeString(&out_html)); | 176 callback.Run(base::RefCountedString::TakeString(&out_html)); |
| 172 } | 177 } |
| OLD | NEW |