1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_BROWSER_CLIENT_EXTENSIONS_PART_H_
#define CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_BROWSER_CLIENT_EXTENSIONS_PART_H_
#include <memory>
#include "base/auto_reset.h"
#include "base/feature_list.h"
#include "base/gtest_prod_util.h"
#include "chrome/browser/chrome_content_browser_client_parts.h"
#include "components/download/public/common/quarantine_connection.h"
#include "content/public/browser/browser_or_resource_context.h"
#include "services/network/public/mojom/network_context.mojom-forward.h"
#include "services/network/public/mojom/url_loader_factory.mojom-forward.h"
#include "ui/base/page_transition_types.h"
namespace content {
class RenderFrameHost;
class RenderProcessHost;
class VpnServiceProxy;
class WebContents;
}
namespace url {
class Origin;
}
namespace blink {
class AssociatedInterfaceRegistry;
}
namespace service_manager {
template <typename...>
class BinderRegistryWithArgs;
using BinderRegistry = BinderRegistryWithArgs<>;
} // namespace service_manager
class Profile;
namespace extensions {
// Implements the extensions portion of ChromeContentBrowserClient.
class ChromeContentBrowserClientExtensionsPart
: public ChromeContentBrowserClientParts {
public:
ChromeContentBrowserClientExtensionsPart();
ChromeContentBrowserClientExtensionsPart(
const ChromeContentBrowserClientExtensionsPart&) = delete;
ChromeContentBrowserClientExtensionsPart& operator=(
const ChromeContentBrowserClientExtensionsPart&) = delete;
~ChromeContentBrowserClientExtensionsPart() override;
// Corresponds to the ChromeContentBrowserClient function of the same name.
static GURL GetEffectiveURL(Profile* profile, const GURL& url);
static bool ShouldCompareEffectiveURLsForSiteInstanceSelection(
content::BrowserContext* browser_context,
content::SiteInstance* candidate_site_instance,
bool is_outermost_main_frame,
const GURL& candidate_url,
const GURL& destination_url);
static bool ShouldUseProcessPerSite(Profile* profile, const GURL& site_url);
static bool ShouldUseSpareRenderProcessHost(Profile* profile,
const GURL& site_url);
static bool DoesSiteRequireDedicatedProcess(
content::BrowserContext* browser_context,
const GURL& effective_site_url);
static bool ShouldAllowCrossProcessSandboxedFrameForPrecursor(
content::BrowserContext* browser_context,
const GURL& precursor,
const GURL& url);
static bool CanCommitURL(content::RenderProcessHost* process_host,
const GURL& url);
static bool IsSuitableHost(Profile* profile,
content::RenderProcessHost* process_host,
const GURL& site_url);
static size_t GetProcessCountToIgnoreForLimit();
static bool ShouldEmbeddedFramesTryToReuseExistingProcess(
content::RenderFrameHost* outermost_main_frame);
static bool ShouldSwapBrowsingInstancesForNavigation(
content::SiteInstance* site_instance,
const GURL& current_effective_url,
const GURL& destination_effective_url);
static bool AllowServiceWorker(const GURL& scope,
const GURL& first_party_url,
const GURL& script_url,
content::BrowserContext* context);
static bool MayDeleteServiceWorkerRegistration(
const GURL& scope,
content::BrowserContext* browser_context);
static bool ShouldTryToUpdateServiceWorkerRegistration(
const GURL& scope,
content::BrowserContext* browser_context);
static std::vector<url::Origin> GetOriginsRequiringDedicatedProcess();
// Helper function to call InfoMap::SetSigninProcess().
static void SetSigninProcess(content::SiteInstance* site_instance);
// Creates a new VpnServiceProxy. The caller owns the returned value. It's
// valid to return nullptr.
static std::unique_ptr<content::VpnServiceProxy> GetVpnServiceProxy(
content::BrowserContext* browser_context);
static void OverrideURLLoaderFactoryParams(
content::BrowserContext* browser_context,
const url::Origin& origin,
bool is_for_isolated_world,
bool is_for_service_worker,
network::mojom::URLLoaderFactoryParams* factory_params);
// Checks if the component is a loaded component extension or the ODFS
// external component extension.
static bool IsBuiltinComponent(content::BrowserContext* browser_context,
const url::Origin& origin);
// Checks if the given context support extensions, based on the profile type.
static bool AreExtensionsDisabledForProfile(
content::BrowserContext* browser_context);
// Temporarily allows unregistration of the service worker with the given
// `scope` for testing purposes; unregistration is allowed while the returned
// AutoReset remains in scope.
static base::AutoReset<const GURL*>
AllowServiceWorkerUnregistrationForScopeForTesting(const GURL* scope);
private:
FRIEND_TEST_ALL_PREFIXES(ChromeContentBrowserClientExtensionsPartTest,
IsolatedOriginsAndHostedAppWebExtents);
// ChromeContentBrowserClientParts:
void SiteInstanceGotProcessAndSite(
content::SiteInstance* site_instance) override;
void OverrideWebPreferences(
content::WebContents* web_contents,
content::SiteInstance& main_frame_site,
blink::web_pref::WebPreferences* web_prefs) override;
bool OverrideWebPreferencesAfterNavigation(
content::WebContents* web_contents,
content::SiteInstance& main_frame_site,
blink::web_pref::WebPreferences* web_prefs) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_allowed_schemes) override;
void GetURLRequestAutoMountHandlers(
std::vector<storage::URLRequestAutoMountHandler>* handlers) override;
void GetAdditionalFileSystemBackends(
content::BrowserContext* browser_context,
const base::FilePath& storage_partition_path,
download::QuarantineConnectionCallback quarantine_connection_callback,
std::vector<std::unique_ptr<storage::FileSystemBackend>>*
additional_backends) override;
void AppendExtraRendererCommandLineSwitches(
base::CommandLine* command_line,
content::RenderProcessHost& process) override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* render_process_host) override;
void ExposeInterfacesToRendererForServiceWorker(
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
blink::AssociatedInterfaceRegistry& associated_registry) override;
void ExposeInterfacesToRendererForRenderFrameHost(
content::RenderFrameHost& frame_host,
blink::AssociatedInterfaceRegistry& associated_registry) override;
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_BROWSER_CLIENT_EXTENSIONS_PART_H_
|