blob: 9d993ad87645bac691984d99723fd69c49711170 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h"
#include <memory>
#include <utility>
#include "base/metrics/user_metrics.h"
#include "components/dom_distiller/content/browser/distiller_ui_handle.h"
#include "components/dom_distiller/core/feedback_reporter.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace dom_distiller {
DistillerJavaScriptServiceImpl::DistillerJavaScriptServiceImpl(
content::RenderFrameHost* render_frame_host,
DistillerUIHandle* distiller_ui_handle)
: render_frame_host_(render_frame_host),
distiller_ui_handle_(distiller_ui_handle) {}
DistillerJavaScriptServiceImpl::~DistillerJavaScriptServiceImpl() {}
void DistillerJavaScriptServiceImpl::HandleDistillerOpenSettingsCall() {
if (!distiller_ui_handle_) {
return;
}
content::WebContents* contents =
content::WebContents::FromRenderFrameHost(render_frame_host_);
distiller_ui_handle_->OpenSettings(contents);
}
void CreateDistillerJavaScriptService(
DistillerUIHandle* distiller_ui_handle,
mojo::PendingReceiver<mojom::DistillerJavaScriptService> receiver,
content::RenderFrameHost* render_frame_host) {
mojo::MakeSelfOwnedReceiver(std::make_unique<DistillerJavaScriptServiceImpl>(
render_frame_host, distiller_ui_handle),
std::move(receiver));
}
} // namespace dom_distiller