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/browser/dom_distiller_viewer_source.h
" | 5 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h
" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/location.h" |
12 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
13 #include "base/message_loop/message_loop.h" | |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" |
18 #include "components/dom_distiller/content/browser/distiller_javascript_service_
impl.h" | 20 #include "components/dom_distiller/content/browser/distiller_javascript_service_
impl.h" |
19 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 21 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
20 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" | 22 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" |
21 #include "components/dom_distiller/content/common/distiller_page_notifier_servic
e.mojom.h" | 23 #include "components/dom_distiller/content/common/distiller_page_notifier_servic
e.mojom.h" |
22 #include "components/dom_distiller/core/distilled_page_prefs.h" | 24 #include "components/dom_distiller/core/distilled_page_prefs.h" |
23 #include "components/dom_distiller/core/dom_distiller_request_view_base.h" | 25 #include "components/dom_distiller/core/dom_distiller_request_view_base.h" |
24 #include "components/dom_distiller/core/dom_distiller_service.h" | 26 #include "components/dom_distiller/core/dom_distiller_service.h" |
25 #include "components/dom_distiller/core/experiments.h" | 27 #include "components/dom_distiller/core/experiments.h" |
26 #include "components/dom_distiller/core/feedback_reporter.h" | 28 #include "components/dom_distiller/core/feedback_reporter.h" |
27 #include "components/dom_distiller/core/task_tracker.h" | 29 #include "components/dom_distiller/core/task_tracker.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void DomDistillerViewerSource::RequestViewerHandle::WebContentsDestroyed() { | 142 void DomDistillerViewerSource::RequestViewerHandle::WebContentsDestroyed() { |
141 Cancel(); | 143 Cancel(); |
142 } | 144 } |
143 | 145 |
144 void DomDistillerViewerSource::RequestViewerHandle::Cancel() { | 146 void DomDistillerViewerSource::RequestViewerHandle::Cancel() { |
145 // No need to listen for notifications. | 147 // No need to listen for notifications. |
146 content::WebContentsObserver::Observe(NULL); | 148 content::WebContentsObserver::Observe(NULL); |
147 | 149 |
148 // Schedule the Viewer for deletion. Ensures distillation is cancelled, and | 150 // Schedule the Viewer for deletion. Ensures distillation is cancelled, and |
149 // any pending data stored in |buffer_| is released. | 151 // any pending data stored in |buffer_| is released. |
150 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 152 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
151 } | 153 } |
152 | 154 |
153 void DomDistillerViewerSource::RequestViewerHandle::DidFinishLoad( | 155 void DomDistillerViewerSource::RequestViewerHandle::DidFinishLoad( |
154 content::RenderFrameHost* render_frame_host, | 156 content::RenderFrameHost* render_frame_host, |
155 const GURL& validated_url) { | 157 const GURL& validated_url) { |
156 if (render_frame_host->GetParent()) { | 158 if (render_frame_host->GetParent()) { |
157 return; | 159 return; |
158 } | 160 } |
159 | 161 |
160 int64_t start_time_ms = url_utils::GetTimeFromDistillerUrl(validated_url); | 162 int64_t start_time_ms = url_utils::GetTimeFromDistillerUrl(validated_url); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 std::string DomDistillerViewerSource::GetContentSecurityPolicyStyleSrc() | 294 std::string DomDistillerViewerSource::GetContentSecurityPolicyStyleSrc() |
293 const { | 295 const { |
294 return "style-src 'self' https://fonts.googleapis.com;"; | 296 return "style-src 'self' https://fonts.googleapis.com;"; |
295 } | 297 } |
296 | 298 |
297 std::string DomDistillerViewerSource::GetContentSecurityPolicyChildSrc() const { | 299 std::string DomDistillerViewerSource::GetContentSecurityPolicyChildSrc() const { |
298 return "child-src *;"; | 300 return "child-src *;"; |
299 } | 301 } |
300 | 302 |
301 } // namespace dom_distiller | 303 } // namespace dom_distiller |
OLD | NEW |