2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#ifndef CEF_LIBCEF_RENDERER_ALLOY_ALLOY_CONTENT_RENDERER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_ALLOY_ALLOY_CONTENT_RENDERER_CLIENT_H_
|
2012-04-03 03:34:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
#include <list>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <map>
|
2016-10-21 21:52:29 +02:00
|
|
|
#include <memory>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
2012-12-31 11:41:15 +01:00
|
|
|
#include <vector>
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#include "libcef/renderer/browser_impl.h"
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
#include "base/task/current_thread.h"
|
2021-11-10 22:57:31 +01:00
|
|
|
#include "base/task/single_thread_task_runner.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/common/plugin.mojom.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/renderer/content_renderer_client.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "content/public/renderer/render_thread.h"
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "services/service_manager/public/cpp/local_interface_provider.h"
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
namespace extensions {
|
2015-11-10 21:18:16 +01:00
|
|
|
class CefExtensionsRendererClient;
|
2015-07-16 23:40:01 +02:00
|
|
|
class Dispatcher;
|
|
|
|
class DispatcherDelegate;
|
|
|
|
class ExtensionsClient;
|
|
|
|
class ExtensionsRendererClient;
|
2015-10-12 20:13:13 +02:00
|
|
|
class ResourceRequestPolicy;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace extensions
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
namespace visitedlink {
|
|
|
|
class VisitedLinkReader;
|
|
|
|
}
|
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
namespace web_cache {
|
2016-05-25 01:35:43 +02:00
|
|
|
class WebCacheImpl;
|
2014-09-27 01:48:19 +02:00
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
class AlloyRenderThreadObserver;
|
|
|
|
class CefRenderManager;
|
2014-10-07 22:44:33 +02:00
|
|
|
class SpellCheck;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
class AlloyContentRendererClient
|
2018-11-30 23:21:07 +01:00
|
|
|
: public content::ContentRendererClient,
|
|
|
|
public service_manager::LocalInterfaceProvider,
|
2020-08-29 00:39:23 +02:00
|
|
|
public base::CurrentThread::DestructionObserver {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentRendererClient();
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
AlloyContentRendererClient(const AlloyContentRendererClient&) = delete;
|
|
|
|
AlloyContentRendererClient& operator=(const AlloyContentRendererClient&) =
|
|
|
|
delete;
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
~AlloyContentRendererClient() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
// Returns the singleton AlloyContentRendererClient instance.
|
2020-06-28 23:05:36 +02:00
|
|
|
// This method is deprecated and should not be used in new callsites.
|
2020-06-28 20:29:44 +02:00
|
|
|
static AlloyContentRendererClient* Get();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
// Render thread task runner.
|
2017-09-21 13:57:40 +02:00
|
|
|
base::SingleThreadTaskRunner* render_task_runner() const {
|
2013-01-03 18:24:24 +01:00
|
|
|
return render_task_runner_.get();
|
|
|
|
}
|
|
|
|
|
2015-10-09 17:23:12 +02:00
|
|
|
// Returns the task runner for the current thread. Returns NULL if the current
|
|
|
|
// thread is not the main render process thread.
|
2017-09-21 13:57:40 +02:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
|
2013-01-03 18:24:24 +01:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Perform cleanup work that needs to occur before shutdown when running in
|
|
|
|
// single-process mode. Blocks until cleanup is complete.
|
|
|
|
void RunSingleProcessCleanup();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// ContentRendererClient implementation.
|
2020-07-20 20:16:48 +02:00
|
|
|
void PostIOThreadCreated(
|
|
|
|
base::SingleThreadTaskRunner* io_thread_task_runner) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void RenderThreadStarted() override;
|
2020-02-10 18:10:17 +01:00
|
|
|
void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override;
|
2017-05-31 17:33:30 +02:00
|
|
|
void RenderThreadConnected() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void RenderFrameCreated(content::RenderFrame* render_frame) override;
|
2022-07-25 19:49:32 +02:00
|
|
|
void WebViewCreated(blink::WebView* web_view,
|
2022-09-26 21:30:45 +02:00
|
|
|
bool was_created_by_renderer,
|
|
|
|
const url::Origin* outermost_origin) override;
|
2019-07-24 23:12:00 +02:00
|
|
|
bool IsPluginHandledExternally(content::RenderFrame* render_frame,
|
|
|
|
const blink::WebElement& plugin_element,
|
|
|
|
const GURL& original_url,
|
|
|
|
const std::string& mime_type) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
|
|
|
|
const blink::WebPluginParams& params,
|
|
|
|
blink::WebPlugin** plugin) override;
|
2018-04-19 17:44:42 +02:00
|
|
|
void WillSendRequest(blink::WebLocalFrame* frame,
|
2018-02-15 01:12:09 +01:00
|
|
|
ui::PageTransition transition_type,
|
|
|
|
const blink::WebURL& url,
|
2020-03-04 01:29:39 +01:00
|
|
|
const net::SiteForCookies& site_for_cookies,
|
2018-04-19 17:44:42 +02:00
|
|
|
const url::Origin* initiator_origin,
|
2021-01-28 00:13:12 +01:00
|
|
|
GURL* new_url) override;
|
2019-04-16 16:38:48 +02:00
|
|
|
uint64_t VisitedLinkHash(const char* canonical_url, size_t length) override;
|
|
|
|
bool IsLinkVisited(uint64_t link_hash) override;
|
2018-04-19 17:44:42 +02:00
|
|
|
bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override;
|
2022-02-21 23:23:40 +01:00
|
|
|
void GetSupportedKeySystems(media::GetSupportedKeySystemsCB cb) override;
|
2016-04-27 22:38:52 +02:00
|
|
|
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
|
|
|
|
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
|
2017-04-20 21:28:17 +02:00
|
|
|
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
|
2018-02-15 01:12:09 +01:00
|
|
|
void DevToolsAgentAttached() override;
|
|
|
|
void DevToolsAgentDetached() override;
|
2021-04-21 00:52:34 +02:00
|
|
|
std::unique_ptr<blink::URLLoaderThrottleProvider>
|
2019-07-24 23:12:00 +02:00
|
|
|
CreateURLLoaderThrottleProvider(
|
2021-04-21 00:52:34 +02:00
|
|
|
blink::URLLoaderThrottleProviderType provider_type) override;
|
2022-02-21 23:23:40 +01:00
|
|
|
void AppendContentSecurityPolicy(
|
|
|
|
const blink::WebURL& url,
|
|
|
|
blink::WebVector<blink::WebContentSecurityPolicyHeader>* csp) override;
|
2017-12-07 22:44:24 +01:00
|
|
|
|
|
|
|
// service_manager::LocalInterfaceProvider implementation.
|
|
|
|
void GetInterface(const std::string& name,
|
|
|
|
mojo::ScopedMessagePipeHandle request_handle) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2018-11-30 23:21:07 +01:00
|
|
|
// MessageLoopCurrent::DestructionObserver implementation.
|
2014-11-12 20:25:15 +01:00
|
|
|
void WillDestroyCurrentMessageLoop() override;
|
2013-02-02 01:21:59 +01:00
|
|
|
|
2023-04-26 21:55:59 +02:00
|
|
|
AlloyRenderThreadObserver* GetAlloyObserver() const {
|
|
|
|
return observer_.get();
|
|
|
|
}
|
|
|
|
|
2014-04-04 18:50:38 +02:00
|
|
|
private:
|
2022-07-21 19:26:10 +02:00
|
|
|
void OnBrowserCreated(blink::WebView* web_view,
|
2021-06-04 03:34:56 +02:00
|
|
|
absl::optional<bool> is_windowless);
|
2014-01-02 23:41:11 +01:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Perform cleanup work for single-process mode.
|
|
|
|
void RunSingleProcessCleanupOnUIThread();
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
// Time at which this object was created. This is very close to the time at
|
|
|
|
// which the RendererMain function was entered.
|
|
|
|
base::TimeTicks main_entry_time_;
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
std::unique_ptr<CefRenderManager> render_manager_;
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2017-09-21 13:57:40 +02:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
|
2021-05-14 18:58:55 +02:00
|
|
|
std::unique_ptr<AlloyRenderThreadObserver> observer_;
|
2016-05-25 01:35:43 +02:00
|
|
|
std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<SpellCheck> spellcheck_;
|
2020-02-10 18:10:17 +01:00
|
|
|
std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_slave_;
|
2019-05-11 00:14:48 +02:00
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
|
|
|
std::unique_ptr<extensions::CefExtensionsRendererClient>
|
2015-11-10 21:18:16 +01:00
|
|
|
extensions_renderer_client_;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Used in single-process mode to test when cleanup is complete.
|
|
|
|
// Access must be protected by |single_process_cleanup_lock_|.
|
2020-09-25 03:40:47 +02:00
|
|
|
bool single_process_cleanup_complete_ = false;
|
2013-02-02 01:21:59 +01:00
|
|
|
base::Lock single_process_cleanup_lock_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#endif // CEF_LIBCEF_RENDERER_ALLOY_ALLOY_CONTENT_RENDERER_CLIENT_H_
|