OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/distiller_javascript_service_
impl.h" | 5 #include "components/dom_distiller/content/browser/distiller_javascript_service_
impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/user_metrics.h" |
10 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" | 11 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" |
11 #include "components/dom_distiller/core/feedback_reporter.h" | 12 #include "components/dom_distiller/core/feedback_reporter.h" |
12 #include "content/public/browser/user_metrics.h" | |
13 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
14 | 14 |
15 namespace dom_distiller { | 15 namespace dom_distiller { |
16 | 16 |
17 DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl( | 17 DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl( |
18 content::RenderFrameHost* render_frame_host, | 18 content::RenderFrameHost* render_frame_host, |
19 DistillerUIHandle* distiller_ui_handle) | 19 DistillerUIHandle* distiller_ui_handle) |
20 : render_frame_host_(render_frame_host), | 20 : render_frame_host_(render_frame_host), |
21 distiller_ui_handle_(distiller_ui_handle) {} | 21 distiller_ui_handle_(distiller_ui_handle) {} |
22 | 22 |
23 DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {} | 23 DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {} |
24 | 24 |
25 void DistillerJavaScriptServiceImpl::HandleDistillerClosePanelCall( | 25 void DistillerJavaScriptServiceImpl::HandleDistillerClosePanelCall( |
26 bool animate) { | 26 bool animate) { |
27 content::RecordAction(base::UserMetricsAction("DomDistiller_ViewOriginal")); | 27 base::RecordAction(base::UserMetricsAction("DomDistiller_ViewOriginal")); |
28 if (!distiller_ui_handle_) { | 28 if (!distiller_ui_handle_) { |
29 return; | 29 return; |
30 } | 30 } |
31 distiller_ui_handle_->ClosePanel(animate); | 31 distiller_ui_handle_->ClosePanel(animate); |
32 } | 32 } |
33 | 33 |
34 void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() { | 34 void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() { |
35 if (!distiller_ui_handle_) { | 35 if (!distiller_ui_handle_) { |
36 return; | 36 return; |
37 } | 37 } |
38 content::WebContents* contents = | 38 content::WebContents* contents = |
39 content::WebContents::FromRenderFrameHost(render_frame_host_); | 39 content::WebContents::FromRenderFrameHost(render_frame_host_); |
40 distiller_ui_handle_->OpenSettings(contents); | 40 distiller_ui_handle_->OpenSettings(contents); |
41 } | 41 } |
42 | 42 |
43 void CreateDistillerJavaScriptService( | 43 void CreateDistillerJavaScriptService( |
44 content::RenderFrameHost* render_frame_host, | 44 content::RenderFrameHost* render_frame_host, |
45 DistillerUIHandle* distiller_ui_handle, | 45 DistillerUIHandle* distiller_ui_handle, |
46 mojo::InterfaceRequest<mojom::DistillerJavaScriptService> request) { | 46 mojo::InterfaceRequest<mojom::DistillerJavaScriptService> request) { |
47 mojo::MakeStrongBinding(base::MakeUnique<DistillerJavaScriptServiceImpl>( | 47 mojo::MakeStrongBinding(base::MakeUnique<DistillerJavaScriptServiceImpl>( |
48 render_frame_host, distiller_ui_handle), | 48 render_frame_host, distiller_ui_handle), |
49 std::move(request)); | 49 std::move(request)); |
50 } | 50 } |
51 | 51 |
52 } // namespace dom_distiller | 52 } // namespace dom_distiller |
OLD | NEW |