#include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h"
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/back_forward_cache/back_forward_cache_disable.h"
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/dom_distiller_request_view_base.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/experiments.h"
#include "components/dom_distiller/core/task_tracker.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/dom_distiller/core/url_utils.h"
#include "components/dom_distiller/core/viewer.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/url_util.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "ui/base/l10n/l10n_util.h"
namespace dom_distiller {
class DomDistillerViewerSource::RequestViewerHandle
: public DomDistillerRequestViewBase,
public content::WebContentsObserver { … };
DomDistillerViewerSource::RequestViewerHandle::RequestViewerHandle(
content::WebContents* web_contents,
const GURL& expected_url,
DistilledPagePrefs* distilled_page_prefs)
: … { … }
DomDistillerViewerSource::RequestViewerHandle::~RequestViewerHandle() { … }
void DomDistillerViewerSource::RequestViewerHandle::SendJavaScript(
const std::string& buffer) { … }
void DomDistillerViewerSource::RequestViewerHandle::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void DomDistillerViewerSource::RequestViewerHandle::
PrimaryMainFrameRenderProcessGone(base::TerminationStatus status) { … }
void DomDistillerViewerSource::RequestViewerHandle::WebContentsDestroyed() { … }
void DomDistillerViewerSource::RequestViewerHandle::Cancel() { … }
void DomDistillerViewerSource::RequestViewerHandle::DOMContentLoaded(
content::RenderFrameHost* render_frame_host) { … }
DomDistillerViewerSource::DomDistillerViewerSource(
DomDistillerServiceInterface* dom_distiller_service)
: … { … }
DomDistillerViewerSource::~DomDistillerViewerSource() = default;
std::string DomDistillerViewerSource::GetSource() { … }
void DomDistillerViewerSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) { … }
std::string DomDistillerViewerSource::GetMimeType(const GURL& url) { … }
bool DomDistillerViewerSource::ShouldServiceRequest(
const GURL& url,
content::BrowserContext* browser_context,
int render_process_id) { … }
std::string DomDistillerViewerSource::GetContentSecurityPolicy(
network::mojom::CSPDirectiveName directive) { … }
}