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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 std::string ThumbnailListSource::GetSource() const { | 94 std::string ThumbnailListSource::GetSource() const { |
95 return chrome::kChromeUIThumbnailListHost; | 95 return chrome::kChromeUIThumbnailListHost; |
96 } | 96 } |
97 | 97 |
98 void ThumbnailListSource::StartDataRequest( | 98 void ThumbnailListSource::StartDataRequest( |
99 const std::string& path, | 99 const std::string& path, |
100 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 100 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
101 const content::URLDataSource::GotDataCallback& callback) { | 101 const content::URLDataSource::GotDataCallback& callback) { |
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 102 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
103 if (!top_sites_) { | 103 if (!top_sites_) { |
104 callback.Run(NULL); | 104 callback.Run(nullptr); |
105 return; | 105 return; |
106 } | 106 } |
107 | 107 |
108 top_sites_->GetMostVisitedURLs( | 108 top_sites_->GetMostVisitedURLs( |
109 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable, | 109 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable, |
110 weak_ptr_factory_.GetWeakPtr(), callback), | 110 weak_ptr_factory_.GetWeakPtr(), callback), |
111 true); | 111 true); |
112 } | 112 } |
113 | 113 |
114 std::string ThumbnailListSource::GetMimeType(const std::string& path) const { | 114 std::string ThumbnailListSource::GetMimeType(const std::string& path) const { |
115 return "text/html"; | 115 return "text/html"; |
116 } | 116 } |
117 | 117 |
118 base::MessageLoop* ThumbnailListSource::MessageLoopForRequestPath( | 118 scoped_refptr<base::SingleThreadTaskRunner> |
119 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 NULL : content::URLDataSource::MessageLoopForRequestPath(path); | 122 ? nullptr |
| 123 : content::URLDataSource::TaskRunnerForRequestPath(path); |
123 } | 124 } |
124 | 125 |
125 bool ThumbnailListSource::ShouldServiceRequest( | 126 bool ThumbnailListSource::ShouldServiceRequest( |
126 const net::URLRequest* request) const { | 127 const net::URLRequest* request) const { |
127 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) | 128 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) |
128 return InstantIOContext::ShouldServiceRequest(request); | 129 return InstantIOContext::ShouldServiceRequest(request); |
129 return URLDataSource::ShouldServiceRequest(request); | 130 return URLDataSource::ShouldServiceRequest(request); |
130 } | 131 } |
131 | 132 |
132 bool ThumbnailListSource::ShouldReplaceExistingSource() const { | 133 bool ThumbnailListSource::ShouldReplaceExistingSource() const { |
(...skipping 29 matching lines...) Expand all Loading... |
162 } | 163 } |
163 if (num_mv_with_thumb < num_mv) { | 164 if (num_mv_with_thumb < num_mv) { |
164 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); | 165 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); |
165 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); | 166 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); |
166 } | 167 } |
167 out.push_back(kHtmlFooter); | 168 out.push_back(kHtmlFooter); |
168 | 169 |
169 std::string out_html = base::JoinString(out, base::StringPiece()); | 170 std::string out_html = base::JoinString(out, base::StringPiece()); |
170 callback.Run(base::RefCountedString::TakeString(&out_html)); | 171 callback.Run(base::RefCountedString::TakeString(&out_html)); |
171 } | 172 } |
OLD | NEW |