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 "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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 class RequestViewerHandle : public ViewRequestDelegate { | 51 class RequestViewerHandle : public ViewRequestDelegate { |
52 public: | 52 public: |
53 explicit RequestViewerHandle( | 53 explicit RequestViewerHandle( |
54 const content::URLDataSource::GotDataCallback& callback); | 54 const content::URLDataSource::GotDataCallback& callback); |
55 virtual ~RequestViewerHandle(); | 55 virtual ~RequestViewerHandle(); |
56 | 56 |
57 // ViewRequestDelegate implementation. | 57 // ViewRequestDelegate implementation. |
58 virtual void OnArticleReady(const DistilledArticleProto* article_proto) | 58 virtual void OnArticleReady(const DistilledArticleProto* article_proto) |
59 OVERRIDE; | 59 OVERRIDE; |
60 | 60 |
| 61 virtual void OnArticleUpdated(ArticleDistillationUpdate article_update) |
| 62 OVERRIDE; |
| 63 |
61 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); | 64 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); |
62 | 65 |
63 private: | 66 private: |
64 // The handle to the view request towards the DomDistillerService. It | 67 // The handle to the view request towards the DomDistillerService. It |
65 // needs to be kept around to ensure the distillation request finishes. | 68 // needs to be kept around to ensure the distillation request finishes. |
66 scoped_ptr<ViewerHandle> viewer_handle_; | 69 scoped_ptr<ViewerHandle> viewer_handle_; |
67 | 70 |
68 // This holds the callback to where the data retrieved is sent back. | 71 // This holds the callback to where the data retrieved is sent back. |
69 content::URLDataSource::GotDataCallback callback_; | 72 content::URLDataSource::GotDataCallback callback_; |
70 }; | 73 }; |
(...skipping 23 matching lines...) Expand all Loading... |
94 title = l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); | 97 title = l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); |
95 unsafe_article_html = | 98 unsafe_article_html = |
96 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); | 99 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); |
97 } | 100 } |
98 std::string unsafe_page_html = | 101 std::string unsafe_page_html = |
99 ReplaceHtmlTemplateValues(title, unsafe_article_html); | 102 ReplaceHtmlTemplateValues(title, unsafe_article_html); |
100 callback_.Run(base::RefCountedString::TakeString(&unsafe_page_html)); | 103 callback_.Run(base::RefCountedString::TakeString(&unsafe_page_html)); |
101 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 104 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
102 } | 105 } |
103 | 106 |
| 107 void RequestViewerHandle::OnArticleUpdated( |
| 108 ArticleDistillationUpdate article_update) { |
| 109 // TODO(nyquist): Add support for displaying pages incrementally. |
| 110 } |
| 111 |
104 void RequestViewerHandle::TakeViewerHandle( | 112 void RequestViewerHandle::TakeViewerHandle( |
105 scoped_ptr<ViewerHandle> viewer_handle) { | 113 scoped_ptr<ViewerHandle> viewer_handle) { |
106 viewer_handle_ = viewer_handle.Pass(); | 114 viewer_handle_ = viewer_handle.Pass(); |
107 } | 115 } |
108 | 116 |
109 DomDistillerViewerSource::DomDistillerViewerSource( | 117 DomDistillerViewerSource::DomDistillerViewerSource( |
110 DomDistillerService* dom_distiller_service, | 118 DomDistillerService* dom_distiller_service, |
111 const std::string& scheme) | 119 const std::string& scheme) |
112 : scheme_(scheme), dom_distiller_service_(dom_distiller_service) {} | 120 : scheme_(scheme), dom_distiller_service_(dom_distiller_service) {} |
113 | 121 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 *path = request->url().host(); | 192 *path = request->url().host(); |
185 } | 193 } |
186 }; | 194 }; |
187 | 195 |
188 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() | 196 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() |
189 const { | 197 const { |
190 return "object-src 'none'; style-src 'self'"; | 198 return "object-src 'none'; style-src 'self'"; |
191 } | 199 } |
192 | 200 |
193 } // namespace dom_distiller | 201 } // namespace dom_distiller |
OLD | NEW |