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

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

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "chrome/browser/history/top_sites.h" 14 #include "chrome/browser/history/top_sites_provider.h"
15 #include "chrome/browser/history/top_sites_service_factory.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search/instant_io_context.h" 17 #include "chrome/browser/search/instant_io_context.h"
17 #include "chrome/browser/thumbnails/thumbnail_service.h" 18 #include "chrome/browser/thumbnails/thumbnail_service.h"
18 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" 19 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
19 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
20 #include "net/base/escape.h" 21 #include "net/base/escape.h"
21 #include "net/url_request/url_request.h" 22 #include "net/url_request/url_request.h"
22 23
23 namespace { 24 namespace {
24 25
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 std::string ThumbnailListSource::GetSource() const { 89 std::string ThumbnailListSource::GetSource() const {
89 return chrome::kChromeUIThumbnailListHost; 90 return chrome::kChromeUIThumbnailListHost;
90 } 91 }
91 92
92 void ThumbnailListSource::StartDataRequest( 93 void ThumbnailListSource::StartDataRequest(
93 const std::string& path, 94 const std::string& path,
94 int render_process_id, 95 int render_process_id,
95 int render_frame_id, 96 int render_frame_id,
96 const content::URLDataSource::GotDataCallback& callback) { 97 const content::URLDataSource::GotDataCallback& callback) {
97 if (!profile_->GetTopSites()) { 98 if (!TopSitesServiceFactory::GetForProfile(profile_)) {
98 callback.Run(NULL); 99 callback.Run(NULL);
99 return; 100 return;
100 } 101 }
101 102
102 profile_->GetTopSites()->GetMostVisitedURLs( 103 TopSitesServiceFactory::GetForProfile(profile_)->GetMostVisitedURLs(
103 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable, 104 base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable,
104 weak_ptr_factory_.GetWeakPtr(), 105 weak_ptr_factory_.GetWeakPtr(), callback),
105 callback), true); 106 true);
106 } 107 }
107 108
108 std::string ThumbnailListSource::GetMimeType(const std::string& path) const { 109 std::string ThumbnailListSource::GetMimeType(const std::string& path) const {
109 return "text/html"; 110 return "text/html";
110 } 111 }
111 112
112 base::MessageLoop* ThumbnailListSource::MessageLoopForRequestPath( 113 base::MessageLoop* ThumbnailListSource::MessageLoopForRequestPath(
113 const std::string& path) const { 114 const std::string& path) const {
114 // TopSites can be accessed from the IO thread. 115 // TopSites can be accessed from the IO thread.
115 return thumbnail_service_.get() ? 116 return thumbnail_service_.get() ?
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 if (num_mv_with_thumb < num_mv) { 156 if (num_mv_with_thumb < num_mv) {
156 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n"); 157 out.push_back("<h2>TopSites URLs without Thumbnails</h2>\n");
157 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out); 158 RenderMostVisitedURLList(mvurl_list, base64_encoded_pngs, false, &out);
158 } 159 }
159 out.push_back(kHtmlFooter); 160 out.push_back(kHtmlFooter);
160 161
161 std::string out_html = JoinString(out, ""); 162 std::string out_html = JoinString(out, "");
162 callback.Run(base::RefCountedString::TakeString(&out_html)); 163 callback.Run(base::RefCountedString::TakeString(&out_html));
163 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698