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

Side by Side Diff: chrome/browser/thumbnails/thumbnail_list_source.cc

Issue 1021803002: [Thumbnails] Injecting TopSites into ThumbnailListSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 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 <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 out->push_back("</li>\n"); 72 out->push_back("</li>\n");
73 } 73 }
74 } 74 }
75 out->push_back("</ul></div>\n"); 75 out->push_back("</ul></div>\n");
76 } 76 }
77 77
78 } // namespace 78 } // namespace
79 79
80 ThumbnailListSource::ThumbnailListSource(Profile* profile) 80 ThumbnailListSource::ThumbnailListSource(Profile* profile)
81 : thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)), 81 : thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)),
82 profile_(profile), 82 top_sites_(TopSitesFactory::GetForProfile(profile)),
83 weak_ptr_factory_(this) { 83 weak_ptr_factory_(this) {
84 } 84 }
85 85
86 ThumbnailListSource::~ThumbnailListSource() { 86 ThumbnailListSource::~ThumbnailListSource() {
87 } 87 }
88 88
89 std::string ThumbnailListSource::GetSource() const { 89 std::string ThumbnailListSource::GetSource() const {
90 return chrome::kChromeUIThumbnailListHost; 90 return chrome::kChromeUIThumbnailListHost;
91 } 91 }
92 92
93 void ThumbnailListSource::StartDataRequest( 93 void ThumbnailListSource::StartDataRequest(
94 const std::string& path, 94 const std::string& path,
95 int render_process_id, 95 int render_process_id,
96 int render_frame_id, 96 int render_frame_id,
97 const content::URLDataSource::GotDataCallback& callback) { 97 const content::URLDataSource::GotDataCallback& callback) {
98 scoped_refptr<history::TopSites> top_sites = 98 if (!top_sites_) {
99 TopSitesFactory::GetForProfile(profile_);
100 if (!top_sites) {
101 callback.Run(NULL); 99 callback.Run(NULL);
102 return; 100 return;
103 } 101 }
104 102
105 top_sites->GetMostVisitedURLs( 103 top_sites_->GetMostVisitedURLs(
106 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable, 104 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable,
107 weak_ptr_factory_.GetWeakPtr(), callback), 105 weak_ptr_factory_.GetWeakPtr(), callback),
108 true); 106 true);
109 } 107 }
110 108
111 std::string ThumbnailListSource::GetMimeType(const std::string& path) const { 109 std::string ThumbnailListSource::GetMimeType(const std::string& path) const {
112 return "text/html"; 110 return "text/html";
113 } 111 }
114 112
115 base::MessageLoop* ThumbnailListSource::MessageLoopForRequestPath( 113 base::MessageLoop* ThumbnailListSource::MessageLoopForRequestPath(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 155 }
158 if (num_mv_with_thumb < num_mv) { 156 if (num_mv_with_thumb < num_mv) {
159 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); 157 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n");
160 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); 158 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out);
161 } 159 }
162 out.push_back(kHtmlFooter); 160 out.push_back(kHtmlFooter);
163 161
164 std::string out_html = JoinString(out, ""); 162 std::string out_html = JoinString(out, "");
165 callback.Run(base::RefCountedString::TakeString(&out_html)); 163 callback.Run(base::RefCountedString::TakeString(&out_html));
166 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698