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 26 matching lines...) Expand all Loading... |
37 : public ViewRequestDelegate, | 37 : public ViewRequestDelegate, |
38 public content::WebContentsObserver, | 38 public content::WebContentsObserver, |
39 public DistilledPagePrefs::Observer { | 39 public DistilledPagePrefs::Observer { |
40 public: | 40 public: |
41 explicit RequestViewerHandle( | 41 explicit RequestViewerHandle( |
42 content::WebContents* web_contents, | 42 content::WebContents* web_contents, |
43 const std::string& expected_scheme, | 43 const std::string& expected_scheme, |
44 const std::string& expected_request_path, | 44 const std::string& expected_request_path, |
45 const content::URLDataSource::GotDataCallback& callback, | 45 const content::URLDataSource::GotDataCallback& callback, |
46 DistilledPagePrefs* distilled_page_prefs); | 46 DistilledPagePrefs* distilled_page_prefs); |
47 virtual ~RequestViewerHandle(); | 47 ~RequestViewerHandle() override; |
48 | 48 |
49 // ViewRequestDelegate implementation: | 49 // ViewRequestDelegate implementation: |
50 virtual void OnArticleReady( | 50 void OnArticleReady(const DistilledArticleProto* article_proto) override; |
51 const DistilledArticleProto* article_proto) override; | |
52 | 51 |
53 virtual void OnArticleUpdated( | 52 void OnArticleUpdated(ArticleDistillationUpdate article_update) override; |
54 ArticleDistillationUpdate article_update) override; | |
55 | 53 |
56 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); | 54 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); |
57 | 55 |
58 // content::WebContentsObserver implementation: | 56 // content::WebContentsObserver implementation: |
59 virtual void DidNavigateMainFrame( | 57 void DidNavigateMainFrame( |
60 const content::LoadCommittedDetails& details, | 58 const content::LoadCommittedDetails& details, |
61 const content::FrameNavigateParams& params) override; | 59 const content::FrameNavigateParams& params) override; |
62 virtual void RenderProcessGone(base::TerminationStatus status) override; | 60 void RenderProcessGone(base::TerminationStatus status) override; |
63 virtual void WebContentsDestroyed() override; | 61 void WebContentsDestroyed() override; |
64 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 62 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
65 const GURL& validated_url) override; | 63 const GURL& validated_url) override; |
66 | 64 |
67 private: | 65 private: |
68 // Sends JavaScript to the attached Viewer, buffering data if the viewer isn't | 66 // Sends JavaScript to the attached Viewer, buffering data if the viewer isn't |
69 // ready. | 67 // ready. |
70 void SendJavaScript(const std::string& buffer); | 68 void SendJavaScript(const std::string& buffer); |
71 | 69 |
72 // Cancels the current view request. Once called, no updates will be | 70 // Cancels the current view request. Once called, no updates will be |
73 // propagated to the view, and the request to DomDistillerService will be | 71 // propagated to the view, and the request to DomDistillerService will be |
74 // cancelled. | 72 // cancelled. |
75 void Cancel(); | 73 void Cancel(); |
76 | 74 |
77 // DistilledPagePrefs::Observer implementation: | 75 // DistilledPagePrefs::Observer implementation: |
78 virtual void OnChangeFontFamily( | 76 void OnChangeFontFamily( |
79 DistilledPagePrefs::FontFamily new_font_family) override; | 77 DistilledPagePrefs::FontFamily new_font_family) override; |
80 virtual void OnChangeTheme(DistilledPagePrefs::Theme new_theme) override; | 78 void OnChangeTheme(DistilledPagePrefs::Theme new_theme) override; |
81 | 79 |
82 // The handle to the view request towards the DomDistillerService. It | 80 // The handle to the view request towards the DomDistillerService. It |
83 // needs to be kept around to ensure the distillation request finishes. | 81 // needs to be kept around to ensure the distillation request finishes. |
84 scoped_ptr<ViewerHandle> viewer_handle_; | 82 scoped_ptr<ViewerHandle> viewer_handle_; |
85 | 83 |
86 // The scheme hosting the current view request; | 84 // The scheme hosting the current view request; |
87 std::string expected_scheme_; | 85 std::string expected_scheme_; |
88 | 86 |
89 // The query path for the current view request. | 87 // The query path for the current view request. |
90 std::string expected_request_path_; | 88 std::string expected_request_path_; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 const net::URLRequest* request, | 344 const net::URLRequest* request, |
347 std::string* path) const { | 345 std::string* path) const { |
348 } | 346 } |
349 | 347 |
350 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() | 348 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() |
351 const { | 349 const { |
352 return "object-src 'none'; style-src 'self' https://fonts.googleapis.com;"; | 350 return "object-src 'none'; style-src 'self' https://fonts.googleapis.com;"; |
353 } | 351 } |
354 | 352 |
355 } // namespace dom_distiller | 353 } // namespace dom_distiller |
OLD | NEW |