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
|
// 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.
#include "extensions/shell/browser/shell_extension_system.h"
#include <memory>
#include <string>
#include "apps/launcher.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "components/value_store/value_store_factory_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/app_runtime/app_runtime_api.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/null_app_sorting.h"
#include "extensions/browser/quota_service.h"
#include "extensions/browser/service_worker_manager.h"
#include "extensions/browser/user_script_manager.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/file_util.h"
#include "extensions/shell/browser/shell_extension_loader.h"
using content::BrowserContext;
namespace extensions {
ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context)
: browser_context_(browser_context),
store_factory_(
new value_store::ValueStoreFactoryImpl(browser_context->GetPath())) {}
ShellExtensionSystem::~ShellExtensionSystem() = default;
const Extension* ShellExtensionSystem::LoadExtension(
const base::FilePath& extension_dir) {
return extension_loader_->LoadExtension(extension_dir);
}
const Extension* ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) {
return LoadExtension(app_dir);
}
void ShellExtensionSystem::FinishInitialization() {
// Inform the rest of the extensions system to start.
ready_.Signal();
}
void ShellExtensionSystem::LaunchApp(const ExtensionId& extension_id) {
// Send the onLaunched event.
DCHECK(ExtensionRegistry::Get(browser_context_)
->enabled_extensions()
.Contains(extension_id));
const Extension* extension = ExtensionRegistry::Get(browser_context_)
->enabled_extensions()
.GetByID(extension_id);
apps::LaunchPlatformApp(browser_context_, extension,
AppLaunchSource::kSourceUntracked);
}
void ShellExtensionSystem::ReloadExtension(const ExtensionId& extension_id) {
extension_loader_->ReloadExtension(extension_id);
}
void ShellExtensionSystem::Shutdown() {
extension_loader_.reset();
}
void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
service_worker_manager_ =
std::make_unique<ServiceWorkerManager>(browser_context_);
quota_service_ = std::make_unique<QuotaService>();
app_sorting_ = std::make_unique<NullAppSorting>();
extension_loader_ = std::make_unique<ShellExtensionLoader>(browser_context_);
user_script_manager_ = std::make_unique<UserScriptManager>(browser_context_);
}
ExtensionService* ShellExtensionSystem::extension_service() {
return nullptr;
}
ManagementPolicy* ShellExtensionSystem::management_policy() {
return nullptr;
}
ServiceWorkerManager* ShellExtensionSystem::service_worker_manager() {
return service_worker_manager_.get();
}
UserScriptManager* ShellExtensionSystem::user_script_manager() {
return user_script_manager_.get();
}
StateStore* ShellExtensionSystem::state_store() {
return nullptr;
}
StateStore* ShellExtensionSystem::rules_store() {
return nullptr;
}
StateStore* ShellExtensionSystem::dynamic_user_scripts_store() {
return nullptr;
}
scoped_refptr<value_store::ValueStoreFactory>
ShellExtensionSystem::store_factory() {
return store_factory_;
}
QuotaService* ShellExtensionSystem::quota_service() {
return quota_service_.get();
}
AppSorting* ShellExtensionSystem::app_sorting() {
return app_sorting_.get();
}
const base::OneShotEvent& ShellExtensionSystem::ready() const {
return ready_;
}
bool ShellExtensionSystem::is_ready() const {
return ready_.is_signaled();
}
ContentVerifier* ShellExtensionSystem::content_verifier() {
return nullptr;
}
std::unique_ptr<ExtensionSet> ShellExtensionSystem::GetDependentExtensions(
const Extension* extension) {
return std::make_unique<ExtensionSet>();
}
void ShellExtensionSystem::InstallUpdate(
const ExtensionId& extension_id,
const std::string& public_key,
const base::FilePath& temp_dir,
bool install_immediately,
InstallUpdateCallback install_update_callback) {
NOTREACHED();
}
void ShellExtensionSystem::PerformActionBasedOnOmahaAttributes(
const ExtensionId& extension_id,
const base::Value::Dict& attributes) {
NOTREACHED();
}
} // namespace extensions
|