2019-07-24 23:01:08 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_
|
|
|
|
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "base/macros.h"
|
|
|
|
#include "build/build_config.h"
|
|
|
|
#include "extensions/browser/extensions_browser_client.h"
|
2020-04-24 01:55:17 +00:00
|
|
|
#include "extensions/browser/kiosk/kiosk_delegate.h"
|
2019-12-11 00:22:35 +00:00
|
|
|
#include "mojo/public/cpp/bindings/pending_remote.h"
|
2020-02-06 07:05:30 +00:00
|
|
|
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
class PrefService;
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
class ExtensionsAPIClient;
|
|
|
|
class KioskDelegate;
|
|
|
|
class ProcessManagerDelegate;
|
2020-01-13 22:55:58 +00:00
|
|
|
class ElectronProcessManagerDelegate;
|
2019-07-24 23:01:08 +00:00
|
|
|
class ProcessMap;
|
2020-02-13 00:39:12 +00:00
|
|
|
class ElectronComponentExtensionResourceManager;
|
2019-07-24 23:01:08 +00:00
|
|
|
} // namespace extensions
|
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
// An ExtensionsBrowserClient that supports a single content::BrowserContext
|
|
|
|
// with no related incognito context.
|
|
|
|
// Must be initialized via InitWithBrowserContext() once the BrowserContext is
|
|
|
|
// created.
|
2020-02-03 22:01:10 +00:00
|
|
|
class ElectronExtensionsBrowserClient
|
|
|
|
: public extensions::ExtensionsBrowserClient {
|
2019-07-24 23:01:08 +00:00
|
|
|
public:
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionsBrowserClient();
|
|
|
|
~ElectronExtensionsBrowserClient() override;
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
// ExtensionsBrowserClient overrides:
|
|
|
|
bool IsShuttingDown() override;
|
|
|
|
bool AreExtensionsDisabled(const base::CommandLine& command_line,
|
|
|
|
content::BrowserContext* context) override;
|
|
|
|
bool IsValidContext(content::BrowserContext* context) override;
|
|
|
|
bool IsSameContext(content::BrowserContext* first,
|
|
|
|
content::BrowserContext* second) override;
|
|
|
|
bool HasOffTheRecordContext(content::BrowserContext* context) override;
|
|
|
|
content::BrowserContext* GetOffTheRecordContext(
|
|
|
|
content::BrowserContext* context) override;
|
|
|
|
content::BrowserContext* GetOriginalContext(
|
|
|
|
content::BrowserContext* context) override;
|
|
|
|
bool IsGuestSession(content::BrowserContext* context) const override;
|
|
|
|
bool IsExtensionIncognitoEnabled(
|
|
|
|
const std::string& extension_id,
|
|
|
|
content::BrowserContext* context) const override;
|
|
|
|
bool CanExtensionCrossIncognito(
|
|
|
|
const extensions::Extension* extension,
|
|
|
|
content::BrowserContext* context) const override;
|
|
|
|
base::FilePath GetBundleResourcePath(
|
|
|
|
const network::ResourceRequest& request,
|
|
|
|
const base::FilePath& extension_resources_path,
|
|
|
|
int* resource_id) const override;
|
|
|
|
void LoadResourceFromResourceBundle(
|
|
|
|
const network::ResourceRequest& request,
|
2019-12-11 00:22:35 +00:00
|
|
|
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
2019-07-24 23:01:08 +00:00
|
|
|
const base::FilePath& resource_relative_path,
|
|
|
|
int resource_id,
|
|
|
|
const std::string& content_security_policy,
|
2019-12-11 00:22:35 +00:00
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
2019-07-24 23:01:08 +00:00
|
|
|
bool send_cors_header) override;
|
|
|
|
bool AllowCrossRendererResourceLoad(
|
|
|
|
const GURL& url,
|
2020-02-06 07:05:30 +00:00
|
|
|
blink::mojom::ResourceType resource_type,
|
2019-07-24 23:01:08 +00:00
|
|
|
ui::PageTransition page_transition,
|
|
|
|
int child_id,
|
|
|
|
bool is_incognito,
|
|
|
|
const extensions::Extension* extension,
|
|
|
|
const extensions::ExtensionSet& extensions,
|
|
|
|
const extensions::ProcessMap& process_map) override;
|
|
|
|
PrefService* GetPrefServiceForContext(
|
|
|
|
content::BrowserContext* context) override;
|
|
|
|
void GetEarlyExtensionPrefsObservers(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
std::vector<extensions::EarlyExtensionPrefsObserver*>* observers)
|
|
|
|
const override;
|
|
|
|
extensions::ProcessManagerDelegate* GetProcessManagerDelegate()
|
|
|
|
const override;
|
|
|
|
std::unique_ptr<extensions::ExtensionHostDelegate>
|
|
|
|
CreateExtensionHostDelegate() override;
|
|
|
|
bool DidVersionUpdate(content::BrowserContext* context) override;
|
|
|
|
void PermitExternalProtocolHandler() override;
|
|
|
|
bool IsInDemoMode() override;
|
|
|
|
bool IsScreensaverInDemoMode(const std::string& app_id) override;
|
|
|
|
bool IsRunningInForcedAppMode() override;
|
|
|
|
bool IsAppModeForcedForApp(
|
|
|
|
const extensions::ExtensionId& extension_id) override;
|
|
|
|
bool IsLoggedInAsPublicAccount() override;
|
|
|
|
extensions::ExtensionSystemProvider* GetExtensionSystemFactory() override;
|
|
|
|
std::unique_ptr<extensions::RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
|
|
|
|
content::BrowserContext* context) const override;
|
|
|
|
const extensions::ComponentExtensionResourceManager*
|
|
|
|
GetComponentExtensionResourceManager() override;
|
|
|
|
void BroadcastEventToRenderers(
|
|
|
|
extensions::events::HistogramValue histogram_value,
|
|
|
|
const std::string& event_name,
|
2019-11-04 23:59:31 +00:00
|
|
|
std::unique_ptr<base::ListValue> args,
|
|
|
|
bool dispatch_to_off_the_record_profiles) override;
|
2019-07-24 23:01:08 +00:00
|
|
|
extensions::ExtensionCache* GetExtensionCache() override;
|
|
|
|
bool IsBackgroundUpdateAllowed() override;
|
|
|
|
bool IsMinBrowserVersionSupported(const std::string& min_version) override;
|
|
|
|
extensions::ExtensionWebContentsObserver* GetExtensionWebContentsObserver(
|
|
|
|
content::WebContents* web_contents) override;
|
|
|
|
extensions::KioskDelegate* GetKioskDelegate() override;
|
|
|
|
bool IsLockScreenContext(content::BrowserContext* context) override;
|
|
|
|
std::string GetApplicationLocale() override;
|
|
|
|
std::string GetUserAgent() const override;
|
2019-12-11 00:22:35 +00:00
|
|
|
void RegisterBrowserInterfaceBindersForFrame(
|
2020-05-26 20:06:26 +00:00
|
|
|
mojo::BinderMapWithContext<content::RenderFrameHost*>* map,
|
2019-12-11 00:22:35 +00:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
|
|
|
const extensions::Extension* extension) const override;
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
// |context| is the single BrowserContext used for IsValidContext().
|
|
|
|
// |pref_service| is used for GetPrefServiceForContext().
|
|
|
|
void InitWithBrowserContext(content::BrowserContext* context,
|
|
|
|
PrefService* pref_service);
|
|
|
|
|
|
|
|
// Sets the API client.
|
|
|
|
void SetAPIClientForTest(extensions::ExtensionsAPIClient* api_client);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Support for extension APIs.
|
|
|
|
std::unique_ptr<extensions::ExtensionsAPIClient> api_client_;
|
|
|
|
|
2020-01-13 22:55:58 +00:00
|
|
|
// Support for ProcessManager.
|
|
|
|
std::unique_ptr<extensions::ElectronProcessManagerDelegate>
|
|
|
|
process_manager_delegate_;
|
|
|
|
|
2019-07-24 23:01:08 +00:00
|
|
|
// The extension cache used for download and installation.
|
|
|
|
std::unique_ptr<extensions::ExtensionCache> extension_cache_;
|
|
|
|
|
2020-04-24 01:55:17 +00:00
|
|
|
std::unique_ptr<extensions::KioskDelegate> kiosk_delegate_;
|
|
|
|
|
2020-02-13 00:39:12 +00:00
|
|
|
std::unique_ptr<extensions::ElectronComponentExtensionResourceManager>
|
|
|
|
resource_manager_;
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsBrowserClient);
|
2019-07-24 23:01:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_
|