| 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 "base/metrics/user_metrics.h" |
| 11 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" | 11 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" |
| 12 #include "components/dom_distiller/core/feedback_reporter.h" | 12 #include "components/dom_distiller/core/feedback_reporter.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( | |
| 26 bool animate) { | |
| 27 base::RecordAction(base::UserMetricsAction("DomDistiller_ViewOriginal")); | |
| 28 if (!distiller_ui_handle_) { | |
| 29 return; | |
| 30 } | |
| 31 distiller_ui_handle_->ClosePanel(animate); | |
| 32 } | |
| 33 | |
| 34 void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() { | 25 void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() { |
| 35 if (!distiller_ui_handle_) { | 26 if (!distiller_ui_handle_) { |
| 36 return; | 27 return; |
| 37 } | 28 } |
| 38 content::WebContents* contents = | 29 content::WebContents* contents = |
| 39 content::WebContents::FromRenderFrameHost(render_frame_host_); | 30 content::WebContents::FromRenderFrameHost(render_frame_host_); |
| 40 distiller_ui_handle_->OpenSettings(contents); | 31 distiller_ui_handle_->OpenSettings(contents); |
| 41 } | 32 } |
| 42 | 33 |
| 43 void CreateDistillerJavaScriptService( | 34 void CreateDistillerJavaScriptService( |
| 44 content::RenderFrameHost* render_frame_host, | 35 content::RenderFrameHost* render_frame_host, |
| 45 DistillerUIHandle* distiller_ui_handle, | 36 DistillerUIHandle* distiller_ui_handle, |
| 46 const service_manager::BindSourceInfo& source_info, | 37 const service_manager::BindSourceInfo& source_info, |
| 47 mojom::DistillerJavaScriptServiceRequest request) { | 38 mojom::DistillerJavaScriptServiceRequest request) { |
| 48 mojo::MakeStrongBinding(base::MakeUnique<DistillerJavaScriptServiceImpl>( | 39 mojo::MakeStrongBinding(base::MakeUnique<DistillerJavaScriptServiceImpl>( |
| 49 render_frame_host, distiller_ui_handle), | 40 render_frame_host, distiller_ui_handle), |
| 50 std::move(request)); | 41 std::move(request)); |
| 51 } | 42 } |
| 52 | 43 |
| 53 } // namespace dom_distiller | 44 } // namespace dom_distiller |
| OLD | NEW |