blob: 4fd02b530174a7b6f36fc861809553f717febd83 [file] [log] [blame]
// Copyright 2012 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.
#ifndef ANDROID_WEBVIEW_RENDERER_AW_CONTENT_RENDERER_CLIENT_H_
#define ANDROID_WEBVIEW_RENDERER_AW_CONTENT_RENDERER_CLIENT_H_
#include <memory>
#include <string>
#include "android_webview/renderer/aw_render_thread_observer.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "content/public/renderer/content_renderer_client.h"
#include "services/service_manager/public/cpp/local_interface_provider.h"
#if BUILDFLAG(ENABLE_SPELLCHECK)
class SpellCheck;
#endif
namespace service_manager {
class Connector;
}
namespace visitedlink {
class VisitedLinkSlave;
}
namespace android_webview {
class AwContentRendererClient : public content::ContentRendererClient,
public service_manager::LocalInterfaceProvider {
public:
AwContentRendererClient();
~AwContentRendererClient() override;
// ContentRendererClient implementation.
void RenderThreadStarted() override;
void RenderFrameCreated(content::RenderFrame* render_frame) override;
void RenderViewCreated(content::RenderView* render_view) override;
bool HasErrorPage(int http_status_code) override;
bool ShouldSuppressErrorPage(content::RenderFrame* render_frame,
const GURL& url) override;
void PrepareErrorPage(content::RenderFrame* render_frame,
const blink::WebURLError& error,
const std::string& http_method,
bool ignoring_cache,
std::string* error_html) override;
uint64_t VisitedLinkHash(const char* canonical_url, size_t length) override;
bool IsLinkVisited(uint64_t link_hash) override;
void AddSupportedKeySystems(
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems)
override;
std::unique_ptr<content::WebSocketHandshakeThrottleProvider>
CreateWebSocketHandshakeThrottleProvider() override;
bool HandleNavigation(content::RenderFrame* render_frame,
bool is_content_initiated,
bool render_view_was_created_by_renderer,
blink::WebFrame* frame,
const blink::WebURLRequest& request,
blink::WebNavigationType type,
blink::WebNavigationPolicy default_policy,
bool is_redirect) override;
std::unique_ptr<content::URLLoaderThrottleProvider>
CreateURLLoaderThrottleProvider(
content::URLLoaderThrottleProviderType provider_type) override;
private:
// service_manager::LocalInterfaceProvider:
void GetInterface(const std::string& name,
mojo::ScopedMessagePipeHandle request_handle) override;
std::unique_ptr<AwRenderThreadObserver> aw_render_thread_observer_;
std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
// These are initialized in RenderThreadStarted() and used to create throttle
// providers on the IO thread.
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
std::unique_ptr<service_manager::Connector>
render_thread_connector_for_io_thread_;
#if BUILDFLAG(ENABLE_SPELLCHECK)
std::unique_ptr<SpellCheck> spellcheck_;
#endif
DISALLOW_COPY_AND_ASSIGN(AwContentRendererClient);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_RENDERER_AW_CONTENT_RENDERER_CLIENT_H_