2015-07-16 23:40:01 +02:00
|
|
|
// Copyright 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions 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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
2015-08-14 16:41:08 +02:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/extension_system.h"
|
|
|
|
#include "extensions/common/one_shot_event.h"
|
|
|
|
|
|
|
|
class BrowserContextKeyedServiceFactory;
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class FilePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace content {
|
|
|
|
class BrowserContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
class ExtensionRegistry;
|
|
|
|
class InfoMap;
|
|
|
|
class ProcessManager;
|
|
|
|
class RendererStartupHelper;
|
|
|
|
class SharedUserScriptMaster;
|
2016-04-27 22:38:52 +02:00
|
|
|
class ValueStoreFactory;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
// Used to manage extensions.
|
|
|
|
class CefExtensionSystem : public ExtensionSystem {
|
|
|
|
public:
|
|
|
|
explicit CefExtensionSystem(content::BrowserContext* browser_context);
|
|
|
|
~CefExtensionSystem() override;
|
|
|
|
|
|
|
|
// Initializes the extension system.
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
// Add an extension. Returns the new Extension object on success or NULL on
|
|
|
|
// failure.
|
|
|
|
const Extension* AddExtension(const std::string& manifest_contents,
|
|
|
|
const base::FilePath& root_directory);
|
|
|
|
|
|
|
|
// Remove an extension.
|
|
|
|
void RemoveExtension(const std::string& extension_id);
|
|
|
|
|
|
|
|
// KeyedService implementation:
|
|
|
|
void Shutdown() override;
|
|
|
|
|
|
|
|
// ExtensionSystem implementation:
|
|
|
|
void InitForRegularProfile(bool extensions_enabled) override;
|
|
|
|
ExtensionService* extension_service() override;
|
|
|
|
RuntimeData* runtime_data() override;
|
|
|
|
ManagementPolicy* management_policy() override;
|
2015-10-09 17:23:12 +02:00
|
|
|
ServiceWorkerManager* service_worker_manager() override;
|
2015-07-16 23:40:01 +02:00
|
|
|
SharedUserScriptMaster* shared_user_script_master() override;
|
|
|
|
StateStore* state_store() override;
|
|
|
|
StateStore* rules_store() override;
|
2016-04-27 22:38:52 +02:00
|
|
|
scoped_refptr<ValueStoreFactory> store_factory() override;
|
2015-07-16 23:40:01 +02:00
|
|
|
InfoMap* info_map() override;
|
|
|
|
QuotaService* quota_service() override;
|
2015-08-14 16:41:08 +02:00
|
|
|
AppSorting* app_sorting() override;
|
2015-07-16 23:40:01 +02:00
|
|
|
void RegisterExtensionWithRequestContexts(
|
2015-08-14 16:41:08 +02:00
|
|
|
const Extension* extension,
|
|
|
|
const base::Closure& callback) override;
|
2015-07-16 23:40:01 +02:00
|
|
|
void UnregisterExtensionWithRequestContexts(
|
|
|
|
const std::string& extension_id,
|
2017-05-31 17:33:30 +02:00
|
|
|
const UnloadedExtensionReason reason) override;
|
2015-07-16 23:40:01 +02:00
|
|
|
const OneShotEvent& ready() const override;
|
|
|
|
ContentVerifier* content_verifier() override;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<ExtensionSet> GetDependentExtensions(
|
2015-07-16 23:40:01 +02:00
|
|
|
const Extension* extension) override;
|
2015-11-10 21:18:16 +01:00
|
|
|
void InstallUpdate(const std::string& extension_id,
|
|
|
|
const base::FilePath& temp_dir) override;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2016-08-24 11:28:52 +02:00
|
|
|
bool initialized() const { return initialized_; }
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
private:
|
|
|
|
// Information about a registered component extension.
|
|
|
|
struct ComponentExtensionInfo {
|
|
|
|
ComponentExtensionInfo(const base::DictionaryValue* manifest,
|
|
|
|
const base::FilePath& root_directory);
|
|
|
|
|
|
|
|
// The parsed contents of the extensions's manifest file.
|
|
|
|
const base::DictionaryValue* manifest;
|
|
|
|
|
|
|
|
// Directory where the extension is stored.
|
|
|
|
base::FilePath root_directory;
|
|
|
|
|
|
|
|
// The component extension's ID.
|
|
|
|
std::string extension_id;
|
|
|
|
};
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
scoped_refptr<const Extension> CreateExtension(
|
2017-05-17 11:29:28 +02:00
|
|
|
const ComponentExtensionInfo& info,
|
|
|
|
std::string* utf8_error);
|
2015-07-24 02:06:56 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
// Loads a registered component extension.
|
|
|
|
const Extension* LoadExtension(const ComponentExtensionInfo& info);
|
|
|
|
|
|
|
|
// Unload the specified extension.
|
2017-05-17 11:29:28 +02:00
|
|
|
void UnloadExtension(const std::string& extension_id,
|
2017-05-31 17:33:30 +02:00
|
|
|
extensions::UnloadedExtensionReason reason);
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
// Handles sending notification that |extension| was loaded.
|
|
|
|
void NotifyExtensionLoaded(const Extension* extension);
|
|
|
|
|
|
|
|
// Handles sending notification that |extension| was unloaded.
|
2017-05-17 11:29:28 +02:00
|
|
|
void NotifyExtensionUnloaded(const Extension* extension,
|
2017-05-31 17:33:30 +02:00
|
|
|
UnloadedExtensionReason reason);
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2015-08-14 16:41:08 +02:00
|
|
|
// Completes extension loading after URLRequestContexts have been updated
|
|
|
|
// on the IO thread.
|
|
|
|
void OnExtensionRegisteredWithRequestContexts(
|
|
|
|
scoped_refptr<const extensions::Extension> extension);
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
content::BrowserContext* browser_context_; // Not owned.
|
|
|
|
|
2016-08-24 11:28:52 +02:00
|
|
|
bool initialized_;
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
// Data to be accessed on the IO thread. Must outlive process_manager_.
|
|
|
|
scoped_refptr<InfoMap> info_map_;
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<ServiceWorkerManager> service_worker_manager_;
|
|
|
|
std::unique_ptr<RuntimeData> runtime_data_;
|
|
|
|
std::unique_ptr<QuotaService> quota_service_;
|
|
|
|
std::unique_ptr<AppSorting> app_sorting_;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
// Signaled when the extension system has completed its startup tasks.
|
|
|
|
OneShotEvent ready_;
|
|
|
|
|
|
|
|
// Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
|
|
|
|
ExtensionRegistry* registry_;
|
|
|
|
|
2017-04-20 21:28:17 +02:00
|
|
|
// The associated RendererStartupHelper. Guaranteed to outlive the
|
|
|
|
// ExtensionSystem, and thus us.
|
|
|
|
extensions::RendererStartupHelper* renderer_helper_;
|
|
|
|
|
2015-08-14 16:41:08 +02:00
|
|
|
// Must be the last member.
|
|
|
|
base::WeakPtrFactory<CefExtensionSystem> weak_ptr_factory_;
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefExtensionSystem);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace extensions
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_
|