bf6e4b1247
* chore: bump chromium in DEPS to 46d2d82e84d73806da623c5333dae4dd218172df * chore: bump chromium in DEPS to cbafe74731a5d1e59844ca59e0fc28f4a5f80a33 * chore: bump chromium in DEPS to d5dcd6b5cc76f4e1732083d775cdd7b533f0abe9 * Update patches * update for lint * Fix compilation errors * chore: bump chromium in DEPS to 1c19360fdaaf65d4ed006736c7f9804104095990 * Replace removed constant * chore: bump chromium in DEPS to 3b6639f5da26c1772c5d4f3ba634aca65df75fec * chore: bump chromium in DEPS to cc6b1b930d4b5eca06701820dac54fa0f41e8999 * chore: bump chromium in DEPS to 7d1445641ad1032c67f731ba6ff7798f29349ade * chore: bump chromium in DEPS to 6f7e5e79cefe982ad84a88927565a88db2e592be * chore: bump chromium in DEPS to bfb25dafff19cb41bf9781331d19ef0be819d1e4 * chore: bump chromium in DEPS to 1a8196b39f0e0cdc4935fd122fff5625d5fab06e * chore: bump chromium in DEPS to 9a03d8d2bb38ad8c0cbb9550ca81b2f94ff60c15 * chore: bump chromium in DEPS to 4c67f3505dab2d5457adb418cd3270a4f3236fd0 * chore: bump chromium in DEPS to 652394e7626fc1ae895a53fb34c64070494e648e * chore: bump chromium in DEPS to 07653652c58cc019af7f833bd63eb0c2eceaab5e * chore: bump chromium in DEPS to 451a1c5fec1fb073a5bae12a033bb342c72c905f * chore: bump chromium in DEPS to 86cdba00e233899a232868b412b333d08db63478 * chore: bump chromium in DEPS to 7c322faad1aee8abef2330d74aabf09ecf8c11af * Update patches * chore: bump chromium in DEPS to d0044fae7efc29eb201cfdd5fdbed77d48aba212 * Replace IsProcessingUserGesture with HasTransientUserActivation4baa9a6e85
* Fix 10.15 sdk build0eaa6db358
* Remove CancelPrerender5eb3329719
* Remove no longer used WebFloatPoint43ab96ce6b
* Use base::span<const uint8_t> for devtools messages in content/public21e19401af
* Update renamed header files * TODO: update with upstream changes This code needs to be updated to handle the changes made in:19be6547a9
* chore: bump chromium in DEPS to 82e5a2c6bd33c2e53634a09fbcbc9fcac1e7ff93 * chore: bump chromium in DEPS to 91f877cadd2995201c276e952b3bf2c60b226c64 * chore: bump chromium in DEPS to 43fcd2ab2677a06d38246b42761dc5b40cf87177 * chore: bump chromium in DEPS to e30957dcb710c0977a7ff95b8d3cf65843df12ca * chore: bump chromium in DEPS to 6a8335a56db12aae2fd06296f82579d804d92217 * chore: bump chromium in DEPS to a4a436cbc28ace88d71752f8f479e59559e54e46 * chore: bump chromium in DEPS to 982bbd0e4b2e1d57d515f384f6483ffc0d7073ad * chore: bump chromium in DEPS to 92bb7a99f84ffcdf41d4edca57e90b1f0c7c6c8b * update patches * add checkout_google_benchmark gclient var * FIXME: workaround grit bug * chore: bump chromium in DEPS to d3623fc53615739e6b59340a5d349e4b397cb7c5 * update patches * Remove color arg from DidChangeThemeColor(). https://chromium-review.googlesource.com/c/chromium/src/+/1982623 * update CreateFileURLLoader with new suffix CL: https://chromium-review.googlesource.com/c/chromium/src/+/1981414 * add node patch for removal of task API in v8 CL: https://chromium-review.googlesource.com/c/v8/v8/+/1868620 * add disable_secure_dns param for WillCreateURLLoaderFactory CL: https://chromium-review.googlesource.com/c/chromium/src/+/1888099 * switch to mojo-ified PrintMsg_PrintPreview CL: https://chromium-review.googlesource.com/c/chromium/src/+/1972307 * chore: bump chromium in DEPS to e7a6d173632660b6aeb9806e9132c34a315331c2 * update missing chrome/browser/ssl:proto dependency after chrome removal CL: https://chromium-review.googlesource.com/c/chromium/src/+/1986082 * chore: add libvulkan.so to the linux manifest CL: https://chromium-review.googlesource.com/c/chromium/src/+/1973042 * revert DidChangeThemeColor ternary change due to templates * match Chrome's mojo-ified implementation in geolocation_permission_context.cc CL: https://chromium-review.googlesource.com/c/chromium/src/+/1963371 * add vulkan-1.dll to zips2d6f74c6d4
* add bug link to fixme_grit_conflicts.patch * Introduce device.mojom.DeviceService https://chromium-review.googlesource.com/c/chromium/src/+/1956277 * PDF Compositor rename to Print Compositor https://chromium-review.googlesource.com/c/chromium/src/+/1981135 * chore: bump chromium_version 00362ea584735b4acf4c5a0e1912d7987f8645ab * chore: update patches * Use a virtual base class to provide GetWidget(). https://chromium-review.googlesource.com/c/chromium/src/+/1996948 * [base] Remove usage of base::CurrentThread https://chromium-review.googlesource.com/c/chromium/src/+/1962019 * chore: gn format * Revert "ci: Use Visual Studio Build Tools instead of VS Studio (#21771)" This reverts commit9c1310dadc
. * fix: trigger resize when iframe requests fullscreen * fix: Locking scheme registry is not necessary https://chromium-review.googlesource.com/c/chromium/src/+/1973198 * chore: bump chromium f707f1d6d428f84cf14b64bc2ca74372e25c6ce7 * chore: update patches * ui/base/clipboard: Remove redundant ANSI format functions https://chromium-review.googlesource.com/c/chromium/src/+/1992015 * [base] Prepare //chrome for Value::GetList() switch https://chromium-review.googlesource.com/c/chromium/src/+/1962255 Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: loc <andy@slack-corp.com> Co-authored-by: Jeremy Apthorp <nornagon@nornagon.net> Co-authored-by: Robo <hop2deep@gmail.com>
294 lines
12 KiB
C++
294 lines
12 KiB
C++
// Copyright (c) 2013 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SHELL_BROWSER_ATOM_BROWSER_CLIENT_H_
|
|
#define SHELL_BROWSER_ATOM_BROWSER_CLIENT_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/files/file_path.h"
|
|
#include "base/synchronization/lock.h"
|
|
#include "content/public/browser/content_browser_client.h"
|
|
#include "content/public/browser/render_process_host_observer.h"
|
|
#include "content/public/browser/web_contents.h"
|
|
#include "electron/buildflags/buildflags.h"
|
|
#include "net/ssl/client_cert_identity.h"
|
|
|
|
namespace content {
|
|
class ClientCertificateDelegate;
|
|
class QuotaPermissionContext;
|
|
} // namespace content
|
|
|
|
namespace net {
|
|
class SSLCertRequestInfo;
|
|
}
|
|
|
|
namespace electron {
|
|
|
|
class NotificationPresenter;
|
|
class PlatformNotificationService;
|
|
|
|
class AtomBrowserClient : public content::ContentBrowserClient,
|
|
public content::RenderProcessHostObserver {
|
|
public:
|
|
static AtomBrowserClient* Get();
|
|
static void SetApplicationLocale(const std::string& locale);
|
|
|
|
AtomBrowserClient();
|
|
~AtomBrowserClient() override;
|
|
|
|
using Delegate = content::ContentBrowserClient;
|
|
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
|
|
|
|
// Returns the WebContents for pending render processes.
|
|
content::WebContents* GetWebContentsFromProcessID(int process_id);
|
|
|
|
// Don't force renderer process to restart for once.
|
|
static void SuppressRendererProcessRestartForOnce();
|
|
|
|
NotificationPresenter* GetNotificationPresenter();
|
|
|
|
void WebNotificationAllowed(int render_process_id,
|
|
base::OnceCallback<void(bool, bool)> callback);
|
|
|
|
// content::NavigatorDelegate
|
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
|
CreateThrottlesForNavigation(content::NavigationHandle* handle) override;
|
|
|
|
// content::ContentBrowserClient:
|
|
std::string GetApplicationLocale() override;
|
|
base::FilePath GetFontLookupTableCacheDir() override;
|
|
bool ShouldEnableStrictSiteIsolation() override;
|
|
void BindHostReceiverForRenderer(
|
|
content::RenderProcessHost* render_process_host,
|
|
mojo::GenericPendingReceiver receiver) override;
|
|
void RegisterBrowserInterfaceBindersForFrame(
|
|
content::RenderFrameHost* render_frame_host,
|
|
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map)
|
|
override;
|
|
|
|
std::string GetUserAgent() override;
|
|
void SetUserAgent(const std::string& user_agent);
|
|
|
|
void SetCanUseCustomSiteInstance(bool should_disable);
|
|
bool CanUseCustomSiteInstance() override;
|
|
|
|
protected:
|
|
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
|
content::SpeechRecognitionManagerDelegate*
|
|
CreateSpeechRecognitionManagerDelegate() override;
|
|
content::TtsControllerDelegate* GetTtsControllerDelegate() override;
|
|
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
|
content::WebPreferences* prefs) override;
|
|
SiteInstanceForNavigationType ShouldOverrideSiteInstanceForNavigation(
|
|
content::RenderFrameHost* current_rfh,
|
|
content::RenderFrameHost* speculative_rfh,
|
|
content::BrowserContext* browser_context,
|
|
const GURL& url,
|
|
bool has_navigation_started,
|
|
bool has_request_started,
|
|
content::SiteInstance** affinity_site_instance) const override;
|
|
void RegisterPendingSiteInstance(
|
|
content::RenderFrameHost* render_frame_host,
|
|
content::SiteInstance* pending_site_instance) override;
|
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
|
int child_process_id) override;
|
|
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
|
std::string GetGeolocationApiKey() override;
|
|
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
|
|
override;
|
|
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
|
|
content::BrowserContext* context) override;
|
|
void AllowCertificateError(
|
|
content::WebContents* web_contents,
|
|
int cert_error,
|
|
const net::SSLInfo& ssl_info,
|
|
const GURL& request_url,
|
|
bool is_main_frame_request,
|
|
bool strict_enforcement,
|
|
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
|
|
override;
|
|
base::OnceClosure SelectClientCertificate(
|
|
content::WebContents* web_contents,
|
|
net::SSLCertRequestInfo* cert_request_info,
|
|
net::ClientCertIdentityList client_certs,
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
|
const GURL& opener_url,
|
|
const GURL& opener_top_level_frame_url,
|
|
const url::Origin& source_origin,
|
|
content::mojom::WindowContainerType container_type,
|
|
const GURL& target_url,
|
|
const content::Referrer& referrer,
|
|
const std::string& frame_name,
|
|
WindowOpenDisposition disposition,
|
|
const blink::mojom::WindowFeatures& features,
|
|
const std::vector<std::string>& additional_features,
|
|
const scoped_refptr<network::ResourceRequestBody>& body,
|
|
bool user_gesture,
|
|
bool opener_suppressed,
|
|
bool* no_javascript_access) override;
|
|
#if BUILDFLAG(ENABLE_PICTURE_IN_PICTURE)
|
|
std::unique_ptr<content::OverlayWindow> CreateWindowForPictureInPicture(
|
|
content::PictureInPictureWindowController* controller) override;
|
|
#endif
|
|
void GetAdditionalAllowedSchemesForFileSystem(
|
|
std::vector<std::string>* additional_schemes) override;
|
|
void GetAdditionalWebUISchemes(
|
|
std::vector<std::string>* additional_schemes) override;
|
|
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
|
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
|
content::BrowserContext* browser_context) override;
|
|
std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider()
|
|
override;
|
|
mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext(
|
|
content::BrowserContext* browser_context,
|
|
bool in_memory,
|
|
const base::FilePath& relative_partition_path) override;
|
|
network::mojom::NetworkContext* GetSystemNetworkContext() override;
|
|
base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
|
|
base::StringPiece name) override;
|
|
content::MediaObserver* GetMediaObserver() override;
|
|
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
|
content::PlatformNotificationService* GetPlatformNotificationService(
|
|
content::BrowserContext* browser_context) override;
|
|
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
|
|
const content::MainFunctionParams&) override;
|
|
base::FilePath GetDefaultDownloadDirectory() override;
|
|
scoped_refptr<network::SharedURLLoaderFactory>
|
|
GetSystemSharedURLLoaderFactory() override;
|
|
void OnNetworkServiceCreated(
|
|
network::mojom::NetworkService* network_service) override;
|
|
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
|
std::string GetProduct() override;
|
|
void RegisterNonNetworkNavigationURLLoaderFactories(
|
|
int frame_tree_node_id,
|
|
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
|
int render_process_id,
|
|
int render_frame_id,
|
|
NonNetworkURLLoaderFactoryMap* factories) override;
|
|
bool WillCreateURLLoaderFactory(
|
|
content::BrowserContext* browser_context,
|
|
content::RenderFrameHost* frame,
|
|
int render_process_id,
|
|
URLLoaderFactoryType type,
|
|
const url::Origin& request_initiator,
|
|
base::Optional<int64_t> navigation_id,
|
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
|
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
|
header_client,
|
|
bool* bypass_redirect_checks,
|
|
bool* disable_secure_dns,
|
|
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
|
|
void OverrideURLLoaderFactoryParams(
|
|
content::BrowserContext* browser_context,
|
|
const url::Origin& origin,
|
|
bool is_for_isolated_world,
|
|
network::mojom::URLLoaderFactoryParams* factory_params) override;
|
|
#if defined(OS_WIN)
|
|
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
|
|
RendererSpawnFlags flags) override;
|
|
#endif
|
|
bool BindAssociatedReceiverFromFrame(
|
|
content::RenderFrameHost* render_frame_host,
|
|
const std::string& interface_name,
|
|
mojo::ScopedInterfaceEndpointHandle* handle) override;
|
|
|
|
bool HandleExternalProtocol(
|
|
const GURL& url,
|
|
content::WebContents::OnceGetter web_contents_getter,
|
|
int child_id,
|
|
content::NavigationUIData* navigation_data,
|
|
bool is_main_frame,
|
|
ui::PageTransition page_transition,
|
|
bool has_user_gesture,
|
|
const base::Optional<url::Origin>& initiating_origin,
|
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
|
override;
|
|
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
|
|
const net::AuthChallengeInfo& auth_info,
|
|
content::WebContents* web_contents,
|
|
const content::GlobalRequestID& request_id,
|
|
bool is_main_frame,
|
|
const GURL& url,
|
|
scoped_refptr<net::HttpResponseHeaders> response_headers,
|
|
bool first_auth_attempt,
|
|
LoginAuthRequiredCallback auth_required_callback) override;
|
|
void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
|
|
|
|
// content::RenderProcessHostObserver:
|
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
|
void RenderProcessReady(content::RenderProcessHost* host) override;
|
|
void RenderProcessExited(
|
|
content::RenderProcessHost* host,
|
|
const content::ChildProcessTerminationInfo& info) override;
|
|
|
|
private:
|
|
struct ProcessPreferences {
|
|
bool sandbox = false;
|
|
bool native_window_open = false;
|
|
bool disable_popups = false;
|
|
bool web_security = true;
|
|
content::BrowserContext* browser_context = nullptr;
|
|
};
|
|
|
|
bool ShouldForceNewSiteInstance(content::RenderFrameHost* current_rfh,
|
|
content::RenderFrameHost* speculative_rfh,
|
|
content::BrowserContext* browser_context,
|
|
const GURL& dest_url,
|
|
bool has_request_started) const;
|
|
bool NavigationWasRedirectedCrossSite(
|
|
content::BrowserContext* browser_context,
|
|
content::SiteInstance* current_instance,
|
|
content::SiteInstance* speculative_instance,
|
|
const GURL& dest_url,
|
|
bool has_request_started) const;
|
|
void AddProcessPreferences(int process_id, ProcessPreferences prefs);
|
|
void RemoveProcessPreferences(int process_id);
|
|
bool IsProcessObserved(int process_id) const;
|
|
bool IsRendererSandboxed(int process_id) const;
|
|
bool RendererUsesNativeWindowOpen(int process_id) const;
|
|
bool RendererDisablesPopups(int process_id) const;
|
|
std::string GetAffinityPreference(content::RenderFrameHost* rfh) const;
|
|
content::SiteInstance* GetSiteInstanceFromAffinity(
|
|
content::BrowserContext* browser_context,
|
|
const GURL& url,
|
|
content::RenderFrameHost* rfh) const;
|
|
void ConsiderSiteInstanceForAffinity(content::RenderFrameHost* rfh,
|
|
content::SiteInstance* site_instance);
|
|
|
|
bool IsRendererSubFrame(int process_id) const;
|
|
|
|
// pending_render_process => web contents.
|
|
std::map<int, content::WebContents*> pending_processes_;
|
|
|
|
std::map<int, base::ProcessId> render_process_host_pids_;
|
|
|
|
std::set<int> renderer_is_subframe_;
|
|
|
|
// list of site per affinity. weak_ptr to prevent instance locking
|
|
std::map<std::string, content::SiteInstance*> site_per_affinities_;
|
|
|
|
std::unique_ptr<PlatformNotificationService> notification_service_;
|
|
std::unique_ptr<NotificationPresenter> notification_presenter_;
|
|
|
|
Delegate* delegate_ = nullptr;
|
|
|
|
std::map<int, ProcessPreferences> process_preferences_;
|
|
|
|
std::string user_agent_override_ = "";
|
|
|
|
bool disable_process_restart_tricks_ = false;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // SHELL_BROWSER_ATOM_BROWSER_CLIENT_H_
|