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

Side by Side Diff: components/dom_distiller/content/dom_distiller_viewer_source.cc

Issue 178303004: Add incremental updates for multipage distillation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
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 "components/dom_distiller/content/dom_distiller_viewer_source.h" 5 #include "components/dom_distiller/content/dom_distiller_viewer_source.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 : public ViewRequestDelegate { 52 : public ViewRequestDelegate {
53 public: 53 public:
54 explicit RequestViewerHandle( 54 explicit RequestViewerHandle(
55 const content::URLDataSource::GotDataCallback& callback); 55 const content::URLDataSource::GotDataCallback& callback);
56 virtual ~RequestViewerHandle(); 56 virtual ~RequestViewerHandle();
57 57
58 // ViewRequestDelegate implementation. 58 // ViewRequestDelegate implementation.
59 virtual void OnArticleReady(const DistilledArticleProto* article_proto) 59 virtual void OnArticleReady(const DistilledArticleProto* article_proto)
60 OVERRIDE; 60 OVERRIDE;
61 61
62 virtual void OnArticleUpdated(ArticleDistillationUpdate article_update)
63 OVERRIDE;
64
62 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); 65 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle);
63 66
64 private: 67 private:
65 // The handle to the view request towards the DomDistillerService. It 68 // The handle to the view request towards the DomDistillerService. It
66 // needs to be kept around to ensure the distillation request finishes. 69 // needs to be kept around to ensure the distillation request finishes.
67 scoped_ptr<ViewerHandle> viewer_handle_; 70 scoped_ptr<ViewerHandle> viewer_handle_;
68 71
69 // This holds the callback to where the data retrieved is sent back. 72 // This holds the callback to where the data retrieved is sent back.
70 content::URLDataSource::GotDataCallback callback_; 73 content::URLDataSource::GotDataCallback callback_;
71 }; 74 };
(...skipping 23 matching lines...) Expand all
95 title = l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); 98 title = l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE);
96 unsafe_article_html = 99 unsafe_article_html =
97 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); 100 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT);
98 } 101 }
99 std::string unsafe_page_html = 102 std::string unsafe_page_html =
100 ReplaceHtmlTemplateValues(title, unsafe_article_html); 103 ReplaceHtmlTemplateValues(title, unsafe_article_html);
101 callback_.Run(base::RefCountedString::TakeString(&unsafe_page_html)); 104 callback_.Run(base::RefCountedString::TakeString(&unsafe_page_html));
102 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 105 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
103 } 106 }
104 107
108 void DomDistillerViewerSource::RequestViewerHandle::OnArticleUpdated(
109 ArticleDistillationUpdate article_update) {
110 // TODO(nyquist): Add support for displaying pages incrementally.
111 }
112
105 void DomDistillerViewerSource::RequestViewerHandle::TakeViewerHandle( 113 void DomDistillerViewerSource::RequestViewerHandle::TakeViewerHandle(
106 scoped_ptr<ViewerHandle> viewer_handle) { 114 scoped_ptr<ViewerHandle> viewer_handle) {
107 viewer_handle_ = viewer_handle.Pass(); 115 viewer_handle_ = viewer_handle.Pass();
108 } 116 }
109 117
110 DomDistillerViewerSource::DomDistillerViewerSource( 118 DomDistillerViewerSource::DomDistillerViewerSource(
111 DomDistillerServiceInterface* dom_distiller_service, 119 DomDistillerServiceInterface* dom_distiller_service,
112 const std::string& scheme) 120 const std::string& scheme)
113 : scheme_(scheme), dom_distiller_service_(dom_distiller_service) {} 121 : scheme_(scheme), dom_distiller_service_(dom_distiller_service) {}
114 122
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 180 }
173 181
174 bool DomDistillerViewerSource::ShouldServiceRequest( 182 bool DomDistillerViewerSource::ShouldServiceRequest(
175 const net::URLRequest* request) const { 183 const net::URLRequest* request) const {
176 return request->url().SchemeIs(scheme_.c_str()); 184 return request->url().SchemeIs(scheme_.c_str());
177 } 185 }
178 186
179 // TODO(nyquist): Start tracking requests using this method. 187 // TODO(nyquist): Start tracking requests using this method.
180 void DomDistillerViewerSource::WillServiceRequest( 188 void DomDistillerViewerSource::WillServiceRequest(
181 const net::URLRequest* request, 189 const net::URLRequest* request,
182 std::string* path) const {}; 190 std::string* path) const {}
183 191
184 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() 192 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc()
185 const { 193 const {
186 return "object-src 'none'; style-src 'self';"; 194 return "object-src 'none'; style-src 'self';";
187 } 195 }
188 196
189 scoped_ptr<ViewerHandle> DomDistillerViewerSource::CreateViewRequest( 197 scoped_ptr<ViewerHandle> DomDistillerViewerSource::CreateViewRequest(
190 const std::string& path, 198 const std::string& path,
191 ViewRequestDelegate* view_request_delegate) { 199 ViewRequestDelegate* view_request_delegate) {
192 std::string entry_id = 200 std::string entry_id =
(...skipping 18 matching lines...) Expand all
211 } else if (has_valid_url) { 219 } else if (has_valid_url) {
212 return dom_distiller_service_->ViewUrl(view_request_delegate, requested_url) 220 return dom_distiller_service_->ViewUrl(view_request_delegate, requested_url)
213 .Pass(); 221 .Pass();
214 } 222 }
215 223
216 // It is invalid to not specify a query param for |kEntryIdKey| or |kUrlKey|. 224 // It is invalid to not specify a query param for |kEntryIdKey| or |kUrlKey|.
217 return scoped_ptr<ViewerHandle>(); 225 return scoped_ptr<ViewerHandle>();
218 } 226 }
219 227
220 } // namespace dom_distiller 228 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698