feat: enable native extensions support (#21814)
This commit is contained in:
parent
bdf65a75d0
commit
a061c87e56
61 changed files with 1054 additions and 941 deletions
|
@ -1,55 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#include "shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "extensions/common/api/runtime.h"
|
||||
#include "shell/browser/extensions/atom_extension_system.h"
|
||||
|
||||
using extensions::api::runtime::PlatformInfo;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
AtomRuntimeAPIDelegate::AtomRuntimeAPIDelegate(
|
||||
content::BrowserContext* browser_context)
|
||||
: browser_context_(browser_context) {
|
||||
DCHECK(browser_context_);
|
||||
}
|
||||
|
||||
AtomRuntimeAPIDelegate::~AtomRuntimeAPIDelegate() = default;
|
||||
|
||||
void AtomRuntimeAPIDelegate::AddUpdateObserver(UpdateObserver* observer) {}
|
||||
|
||||
void AtomRuntimeAPIDelegate::RemoveUpdateObserver(UpdateObserver* observer) {}
|
||||
|
||||
void AtomRuntimeAPIDelegate::ReloadExtension(const std::string& extension_id) {
|
||||
static_cast<AtomExtensionSystem*>(ExtensionSystem::Get(browser_context_))
|
||||
->ReloadExtension(extension_id);
|
||||
}
|
||||
|
||||
bool AtomRuntimeAPIDelegate::CheckForUpdates(
|
||||
const std::string& extension_id,
|
||||
const UpdateCheckCallback& callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtomRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {}
|
||||
|
||||
bool AtomRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
|
||||
// TODO(nornagon): put useful information here.
|
||||
#if defined(OS_LINUX)
|
||||
info->os = api::runtime::PLATFORM_OS_LINUX;
|
||||
#endif
|
||||
return true;
|
||||
} // namespace extensions
|
||||
|
||||
bool AtomRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
|
||||
*error_message = "Restart is not supported in Electron";
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace extensions
|
|
@ -0,0 +1,57 @@
|
|||
// 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.
|
||||
|
||||
#include "shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "extensions/common/api/runtime.h"
|
||||
#include "shell/browser/extensions/electron_extension_system.h"
|
||||
|
||||
using extensions::api::runtime::PlatformInfo;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
ElectronRuntimeAPIDelegate::ElectronRuntimeAPIDelegate(
|
||||
content::BrowserContext* browser_context)
|
||||
: browser_context_(browser_context) {
|
||||
DCHECK(browser_context_);
|
||||
}
|
||||
|
||||
ElectronRuntimeAPIDelegate::~ElectronRuntimeAPIDelegate() = default;
|
||||
|
||||
void ElectronRuntimeAPIDelegate::AddUpdateObserver(UpdateObserver* observer) {}
|
||||
|
||||
void ElectronRuntimeAPIDelegate::RemoveUpdateObserver(
|
||||
UpdateObserver* observer) {}
|
||||
|
||||
void ElectronRuntimeAPIDelegate::ReloadExtension(
|
||||
const std::string& extension_id) {
|
||||
static_cast<ElectronExtensionSystem*>(ExtensionSystem::Get(browser_context_))
|
||||
->ReloadExtension(extension_id);
|
||||
}
|
||||
|
||||
bool ElectronRuntimeAPIDelegate::CheckForUpdates(
|
||||
const std::string& extension_id,
|
||||
const UpdateCheckCallback& callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ElectronRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {}
|
||||
|
||||
bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
|
||||
// TODO(nornagon): put useful information here.
|
||||
#if defined(OS_LINUX)
|
||||
info->os = api::runtime::PLATFORM_OS_LINUX;
|
||||
#endif
|
||||
return true;
|
||||
} // namespace extensions
|
||||
|
||||
bool ElectronRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
|
||||
*error_message = "Restart is not supported in Electron";
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace extensions
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ATOM_RUNTIME_API_DELEGATE_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ATOM_RUNTIME_API_DELEGATE_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ELECTRON_RUNTIME_API_DELEGATE_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ELECTRON_RUNTIME_API_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -16,10 +16,10 @@ class BrowserContext;
|
|||
|
||||
namespace extensions {
|
||||
|
||||
class AtomRuntimeAPIDelegate : public RuntimeAPIDelegate {
|
||||
class ElectronRuntimeAPIDelegate : public RuntimeAPIDelegate {
|
||||
public:
|
||||
explicit AtomRuntimeAPIDelegate(content::BrowserContext* browser_context);
|
||||
~AtomRuntimeAPIDelegate() override;
|
||||
explicit ElectronRuntimeAPIDelegate(content::BrowserContext* browser_context);
|
||||
~ElectronRuntimeAPIDelegate() override;
|
||||
|
||||
// RuntimeAPIDelegate implementation.
|
||||
void AddUpdateObserver(UpdateObserver* observer) override;
|
||||
|
@ -34,9 +34,9 @@ class AtomRuntimeAPIDelegate : public RuntimeAPIDelegate {
|
|||
private:
|
||||
content::BrowserContext* browser_context_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRuntimeAPIDelegate);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronRuntimeAPIDelegate);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ATOM_RUNTIME_API_DELEGATE_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ELECTRON_RUNTIME_API_DELEGATE_H_
|
|
@ -1,23 +0,0 @@
|
|||
// 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 SHELL_BROWSER_EXTENSIONS_ATOM_DISPLAY_INFO_PROVIDER_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_DISPLAY_INFO_PROVIDER_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "extensions/browser/api/system_display/display_info_provider.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class AtomDisplayInfoProvider : public DisplayInfoProvider {
|
||||
public:
|
||||
AtomDisplayInfoProvider();
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomDisplayInfoProvider);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_DISPLAY_INFO_PROVIDER_H_
|
|
@ -2,11 +2,11 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_browser_context_keyed_service_factories.h"
|
||||
#include "shell/browser/extensions/electron_browser_context_keyed_service_factories.h"
|
||||
|
||||
#include "extensions/browser/updater/update_service_factory.h"
|
||||
// #include "extensions/shell/browser/api/identity/identity_api.h"
|
||||
#include "shell/browser/extensions/atom_extension_system_factory.h"
|
||||
#include "shell/browser/extensions/electron_extension_system_factory.h"
|
||||
|
||||
namespace extensions {
|
||||
namespace electron {
|
||||
|
@ -18,7 +18,7 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
|
|||
// extensions embedders (and namely chrome.)
|
||||
UpdateServiceFactory::GetInstance();
|
||||
|
||||
AtomExtensionSystemFactory::GetInstance();
|
||||
ElectronExtensionSystemFactory::GetInstance();
|
||||
}
|
||||
|
||||
} // namespace electron
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
||||
|
||||
namespace extensions {
|
||||
namespace electron {
|
||||
|
@ -15,4 +15,4 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt();
|
|||
} // namespace electron
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_BROWSER_CONTEXT_KEYED_SERVICE_FACTORIES_H_
|
|
@ -2,10 +2,10 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_display_info_provider.h"
|
||||
#include "shell/browser/extensions/electron_display_info_provider.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
AtomDisplayInfoProvider::AtomDisplayInfoProvider() = default;
|
||||
ElectronDisplayInfoProvider::ElectronDisplayInfoProvider() = default;
|
||||
|
||||
} // namespace extensions
|
23
shell/browser/extensions/electron_display_info_provider.h
Normal file
23
shell/browser/extensions/electron_display_info_provider.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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 SHELL_BROWSER_EXTENSIONS_ELECTRON_DISPLAY_INFO_PROVIDER_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_DISPLAY_INFO_PROVIDER_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "extensions/browser/api/system_display/display_info_provider.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
class ElectronDisplayInfoProvider : public DisplayInfoProvider {
|
||||
public:
|
||||
ElectronDisplayInfoProvider();
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronDisplayInfoProvider);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_DISPLAY_INFO_PROVIDER_H_
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_extension_host_delegate.h"
|
||||
#include "shell/browser/extensions/electron_extension_host_delegate.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -11,31 +11,31 @@
|
|||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "extensions/browser/media_capture_util.h"
|
||||
#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
|
||||
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
AtomExtensionHostDelegate::AtomExtensionHostDelegate() {}
|
||||
ElectronExtensionHostDelegate::ElectronExtensionHostDelegate() {}
|
||||
|
||||
AtomExtensionHostDelegate::~AtomExtensionHostDelegate() {}
|
||||
ElectronExtensionHostDelegate::~ElectronExtensionHostDelegate() {}
|
||||
|
||||
void AtomExtensionHostDelegate::OnExtensionHostCreated(
|
||||
void ElectronExtensionHostDelegate::OnExtensionHostCreated(
|
||||
content::WebContents* web_contents) {
|
||||
AtomExtensionWebContentsObserver::CreateForWebContents(web_contents);
|
||||
ElectronExtensionWebContentsObserver::CreateForWebContents(web_contents);
|
||||
}
|
||||
|
||||
void AtomExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
|
||||
void ElectronExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
|
||||
ExtensionHost* host) {}
|
||||
|
||||
content::JavaScriptDialogManager*
|
||||
AtomExtensionHostDelegate::GetJavaScriptDialogManager() {
|
||||
ElectronExtensionHostDelegate::GetJavaScriptDialogManager() {
|
||||
// TODO(jamescook): Create a JavaScriptDialogManager or reuse the one from
|
||||
// content_shell.
|
||||
NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AtomExtensionHostDelegate::CreateTab(
|
||||
void ElectronExtensionHostDelegate::CreateTab(
|
||||
std::unique_ptr<content::WebContents> web_contents,
|
||||
const std::string& extension_id,
|
||||
WindowOpenDisposition disposition,
|
||||
|
@ -45,7 +45,7 @@ void AtomExtensionHostDelegate::CreateTab(
|
|||
NOTREACHED();
|
||||
}
|
||||
|
||||
void AtomExtensionHostDelegate::ProcessMediaAccessRequest(
|
||||
void ElectronExtensionHostDelegate::ProcessMediaAccessRequest(
|
||||
content::WebContents* web_contents,
|
||||
const content::MediaStreamRequest& request,
|
||||
content::MediaResponseCallback callback,
|
||||
|
@ -55,7 +55,7 @@ void AtomExtensionHostDelegate::ProcessMediaAccessRequest(
|
|||
std::move(callback), extension);
|
||||
}
|
||||
|
||||
bool AtomExtensionHostDelegate::CheckMediaAccessPermission(
|
||||
bool ElectronExtensionHostDelegate::CheckMediaAccessPermission(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& security_origin,
|
||||
blink::mojom::MediaStreamType type,
|
||||
|
@ -65,7 +65,7 @@ bool AtomExtensionHostDelegate::CheckMediaAccessPermission(
|
|||
}
|
||||
|
||||
content::PictureInPictureResult
|
||||
AtomExtensionHostDelegate::EnterPictureInPicture(
|
||||
ElectronExtensionHostDelegate::EnterPictureInPicture(
|
||||
content::WebContents* web_contents,
|
||||
const viz::SurfaceId& surface_id,
|
||||
const gfx::Size& natural_size) {
|
||||
|
@ -73,7 +73,7 @@ AtomExtensionHostDelegate::EnterPictureInPicture(
|
|||
return content::PictureInPictureResult();
|
||||
}
|
||||
|
||||
void AtomExtensionHostDelegate::ExitPictureInPicture() {
|
||||
void ElectronExtensionHostDelegate::ExitPictureInPicture() {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_HOST_DELEGATE_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_HOST_DELEGATE_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_HOST_DELEGATE_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_HOST_DELEGATE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -14,10 +14,10 @@
|
|||
namespace extensions {
|
||||
|
||||
// A minimal ExtensionHostDelegate.
|
||||
class AtomExtensionHostDelegate : public ExtensionHostDelegate {
|
||||
class ElectronExtensionHostDelegate : public ExtensionHostDelegate {
|
||||
public:
|
||||
AtomExtensionHostDelegate();
|
||||
~AtomExtensionHostDelegate() override;
|
||||
ElectronExtensionHostDelegate();
|
||||
~ElectronExtensionHostDelegate() override;
|
||||
|
||||
// ExtensionHostDelegate implementation.
|
||||
void OnExtensionHostCreated(content::WebContents* web_contents) override;
|
||||
|
@ -43,9 +43,9 @@ class AtomExtensionHostDelegate : public ExtensionHostDelegate {
|
|||
void ExitPictureInPicture() override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomExtensionHostDelegate);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionHostDelegate);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_HOST_DELEGATE_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_HOST_DELEGATE_H_
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_extension_loader.h"
|
||||
#include "shell/browser/extensions/electron_extension_loader.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
|||
#include "base/files/file_util.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "extensions/browser/extension_file_task_runner.h"
|
||||
|
@ -25,16 +26,15 @@ using LoadErrorBehavior = ExtensionRegistrar::LoadErrorBehavior;
|
|||
|
||||
namespace {
|
||||
|
||||
scoped_refptr<const Extension> LoadUnpacked(
|
||||
std::pair<scoped_refptr<const Extension>, std::string> LoadUnpacked(
|
||||
const base::FilePath& extension_dir) {
|
||||
// app_shell only supports unpacked extensions.
|
||||
// NOTE: If you add packed extension support consider removing the flag
|
||||
// FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks.
|
||||
// TODO(nornagon): these LOG()s should surface as JS exceptions
|
||||
if (!base::DirectoryExists(extension_dir)) {
|
||||
LOG(ERROR) << "Extension directory not found: "
|
||||
<< extension_dir.AsUTF8Unsafe();
|
||||
return nullptr;
|
||||
std::string err = "Extension directory not found: " +
|
||||
base::UTF16ToUTF8(extension_dir.LossyDisplayName());
|
||||
return std::make_pair(nullptr, err);
|
||||
}
|
||||
|
||||
int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE;
|
||||
|
@ -42,43 +42,46 @@ scoped_refptr<const Extension> LoadUnpacked(
|
|||
scoped_refptr<Extension> extension = file_util::LoadExtension(
|
||||
extension_dir, Manifest::COMMAND_LINE, load_flags, &load_error);
|
||||
if (!extension.get()) {
|
||||
LOG(ERROR) << "Loading extension at " << extension_dir.value()
|
||||
<< " failed with: " << load_error;
|
||||
return nullptr;
|
||||
std::string err = "Loading extension at " +
|
||||
base::UTF16ToUTF8(extension_dir.LossyDisplayName()) +
|
||||
" failed with: " + load_error;
|
||||
return std::make_pair(nullptr, err);
|
||||
}
|
||||
|
||||
std::string warnings;
|
||||
// Log warnings.
|
||||
if (extension->install_warnings().size()) {
|
||||
LOG(WARNING) << "Warnings loading extension at " << extension_dir.value()
|
||||
<< ":";
|
||||
for (const auto& warning : extension->install_warnings())
|
||||
LOG(WARNING) << warning.message;
|
||||
warnings += "Warnings loading extension at " +
|
||||
base::UTF16ToUTF8(extension_dir.LossyDisplayName()) + ": ";
|
||||
for (const auto& warning : extension->install_warnings()) {
|
||||
warnings += warning.message + " ";
|
||||
}
|
||||
}
|
||||
|
||||
return extension;
|
||||
return std::make_pair(extension, warnings);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomExtensionLoader::AtomExtensionLoader(
|
||||
ElectronExtensionLoader::ElectronExtensionLoader(
|
||||
content::BrowserContext* browser_context)
|
||||
: browser_context_(browser_context),
|
||||
extension_registrar_(browser_context, this),
|
||||
weak_factory_(this) {}
|
||||
|
||||
AtomExtensionLoader::~AtomExtensionLoader() = default;
|
||||
ElectronExtensionLoader::~ElectronExtensionLoader() = default;
|
||||
|
||||
void AtomExtensionLoader::LoadExtension(
|
||||
void ElectronExtensionLoader::LoadExtension(
|
||||
const base::FilePath& extension_dir,
|
||||
base::OnceCallback<void(const Extension*)> loaded) {
|
||||
base::OnceCallback<void(const Extension*, const std::string&)> cb) {
|
||||
base::PostTaskAndReplyWithResult(
|
||||
GetExtensionFileTaskRunner().get(), FROM_HERE,
|
||||
base::BindOnce(&LoadUnpacked, extension_dir),
|
||||
base::BindOnce(&AtomExtensionLoader::FinishExtensionLoad,
|
||||
weak_factory_.GetWeakPtr(), std::move(loaded)));
|
||||
base::BindOnce(&ElectronExtensionLoader::FinishExtensionLoad,
|
||||
weak_factory_.GetWeakPtr(), std::move(cb)));
|
||||
}
|
||||
|
||||
void AtomExtensionLoader::ReloadExtension(const ExtensionId& extension_id) {
|
||||
void ElectronExtensionLoader::ReloadExtension(const ExtensionId& extension_id) {
|
||||
const Extension* extension = ExtensionRegistry::Get(browser_context_)
|
||||
->GetInstalledExtension(extension_id);
|
||||
// We shouldn't be trying to reload extensions that haven't been added.
|
||||
|
@ -94,31 +97,33 @@ void AtomExtensionLoader::ReloadExtension(const ExtensionId& extension_id) {
|
|||
return;
|
||||
}
|
||||
|
||||
void AtomExtensionLoader::UnloadExtension(
|
||||
void ElectronExtensionLoader::UnloadExtension(
|
||||
const ExtensionId& extension_id,
|
||||
extensions::UnloadedExtensionReason reason) {
|
||||
extension_registrar_.RemoveExtension(extension_id, reason);
|
||||
}
|
||||
|
||||
void AtomExtensionLoader::FinishExtensionLoad(
|
||||
base::OnceCallback<void(const Extension*)> done,
|
||||
scoped_refptr<const Extension> extension) {
|
||||
void ElectronExtensionLoader::FinishExtensionLoad(
|
||||
base::OnceCallback<void(const Extension*, const std::string&)> cb,
|
||||
std::pair<scoped_refptr<const Extension>, std::string> result) {
|
||||
scoped_refptr<const Extension> extension = result.first;
|
||||
if (extension) {
|
||||
extension_registrar_.AddExtension(extension);
|
||||
}
|
||||
std::move(done).Run(extension.get());
|
||||
std::move(cb).Run(extension.get(), result.second);
|
||||
}
|
||||
|
||||
void AtomExtensionLoader::FinishExtensionReload(
|
||||
void ElectronExtensionLoader::FinishExtensionReload(
|
||||
const ExtensionId& old_extension_id,
|
||||
scoped_refptr<const Extension> extension) {
|
||||
std::pair<scoped_refptr<const Extension>, std::string> result) {
|
||||
scoped_refptr<const Extension> extension = result.first;
|
||||
if (extension) {
|
||||
extension_registrar_.AddExtension(extension);
|
||||
}
|
||||
}
|
||||
|
||||
void AtomExtensionLoader::PreAddExtension(const Extension* extension,
|
||||
const Extension* old_extension) {
|
||||
void ElectronExtensionLoader::PreAddExtension(const Extension* extension,
|
||||
const Extension* old_extension) {
|
||||
if (old_extension)
|
||||
return;
|
||||
|
||||
|
@ -138,13 +143,13 @@ void AtomExtensionLoader::PreAddExtension(const Extension* extension,
|
|||
}
|
||||
}
|
||||
|
||||
void AtomExtensionLoader::PostActivateExtension(
|
||||
void ElectronExtensionLoader::PostActivateExtension(
|
||||
scoped_refptr<const Extension> extension) {}
|
||||
|
||||
void AtomExtensionLoader::PostDeactivateExtension(
|
||||
void ElectronExtensionLoader::PostDeactivateExtension(
|
||||
scoped_refptr<const Extension> extension) {}
|
||||
|
||||
void AtomExtensionLoader::LoadExtensionForReload(
|
||||
void ElectronExtensionLoader::LoadExtensionForReload(
|
||||
const ExtensionId& extension_id,
|
||||
const base::FilePath& path,
|
||||
LoadErrorBehavior load_error_behavior) {
|
||||
|
@ -153,21 +158,21 @@ void AtomExtensionLoader::LoadExtensionForReload(
|
|||
base::PostTaskAndReplyWithResult(
|
||||
GetExtensionFileTaskRunner().get(), FROM_HERE,
|
||||
base::BindOnce(&LoadUnpacked, path),
|
||||
base::BindOnce(&AtomExtensionLoader::FinishExtensionReload,
|
||||
base::BindOnce(&ElectronExtensionLoader::FinishExtensionReload,
|
||||
weak_factory_.GetWeakPtr(), extension_id));
|
||||
did_schedule_reload_ = true;
|
||||
}
|
||||
|
||||
bool AtomExtensionLoader::CanEnableExtension(const Extension* extension) {
|
||||
bool ElectronExtensionLoader::CanEnableExtension(const Extension* extension) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AtomExtensionLoader::CanDisableExtension(const Extension* extension) {
|
||||
bool ElectronExtensionLoader::CanDisableExtension(const Extension* extension) {
|
||||
// Extensions cannot be disabled by the user.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionLoader::ShouldBlockExtension(const Extension* extension) {
|
||||
bool ElectronExtensionLoader::ShouldBlockExtension(const Extension* extension) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_LOADER_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_LOADER_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_LOADER_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_LOADER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
@ -27,16 +28,16 @@ namespace extensions {
|
|||
class Extension;
|
||||
|
||||
// Handles extension loading and reloading using ExtensionRegistrar.
|
||||
class AtomExtensionLoader : public ExtensionRegistrar::Delegate {
|
||||
class ElectronExtensionLoader : public ExtensionRegistrar::Delegate {
|
||||
public:
|
||||
explicit AtomExtensionLoader(content::BrowserContext* browser_context);
|
||||
~AtomExtensionLoader() override;
|
||||
explicit ElectronExtensionLoader(content::BrowserContext* browser_context);
|
||||
~ElectronExtensionLoader() override;
|
||||
|
||||
// Loads an unpacked extension from a directory synchronously. Returns the
|
||||
// extension on success, or nullptr otherwise.
|
||||
void LoadExtension(
|
||||
const base::FilePath& extension_dir,
|
||||
base::OnceCallback<void(const Extension* extension)> loaded);
|
||||
void LoadExtension(const base::FilePath& extension_dir,
|
||||
base::OnceCallback<void(const Extension* extension,
|
||||
const std::string&)> cb);
|
||||
|
||||
// Starts reloading the extension. A keep-alive is maintained until the
|
||||
// reload succeeds/fails. If the extension is an app, it will be launched upon
|
||||
|
@ -51,11 +52,13 @@ class AtomExtensionLoader : public ExtensionRegistrar::Delegate {
|
|||
private:
|
||||
// If the extension loaded successfully, enables it. If it's an app, launches
|
||||
// it. If the load failed, updates ShellKeepAliveRequester.
|
||||
void FinishExtensionReload(const ExtensionId& old_extension_id,
|
||||
scoped_refptr<const Extension> extension);
|
||||
void FinishExtensionReload(
|
||||
const ExtensionId& old_extension_id,
|
||||
std::pair<scoped_refptr<const Extension>, std::string> result);
|
||||
|
||||
void FinishExtensionLoad(base::OnceCallback<void(const Extension*)> loaded,
|
||||
scoped_refptr<const Extension> extension);
|
||||
void FinishExtensionLoad(
|
||||
base::OnceCallback<void(const Extension*, const std::string&)> cb,
|
||||
std::pair<scoped_refptr<const Extension>, std::string> result);
|
||||
|
||||
// ExtensionRegistrar::Delegate:
|
||||
void PreAddExtension(const Extension* extension,
|
||||
|
@ -84,11 +87,11 @@ class AtomExtensionLoader : public ExtensionRegistrar::Delegate {
|
|||
// LoadExtensionForReload().
|
||||
bool did_schedule_reload_ = false;
|
||||
|
||||
base::WeakPtrFactory<AtomExtensionLoader> weak_factory_;
|
||||
base::WeakPtrFactory<ElectronExtensionLoader> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomExtensionLoader);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionLoader);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_LOADER_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_LOADER_H_
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_extension_system.h"
|
||||
#include "shell/browser/extensions/electron_extension_system.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -30,27 +30,28 @@
|
|||
#include "extensions/browser/value_store/value_store_factory_impl.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/common/file_util.h"
|
||||
#include "shell/browser/extensions/atom_extension_loader.h"
|
||||
#include "shell/browser/extensions/electron_extension_loader.h"
|
||||
|
||||
using content::BrowserContext;
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
AtomExtensionSystem::AtomExtensionSystem(BrowserContext* browser_context)
|
||||
ElectronExtensionSystem::ElectronExtensionSystem(
|
||||
BrowserContext* browser_context)
|
||||
: browser_context_(browser_context),
|
||||
store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())),
|
||||
weak_factory_(this) {}
|
||||
|
||||
AtomExtensionSystem::~AtomExtensionSystem() = default;
|
||||
ElectronExtensionSystem::~ElectronExtensionSystem() = default;
|
||||
|
||||
void AtomExtensionSystem::LoadExtension(
|
||||
void ElectronExtensionSystem::LoadExtension(
|
||||
const base::FilePath& extension_dir,
|
||||
base::OnceCallback<void(const Extension*)> loaded) {
|
||||
extension_loader_->LoadExtension(extension_dir, std::move(loaded));
|
||||
base::OnceCallback<void(const Extension*, const std::string&)> cb) {
|
||||
extension_loader_->LoadExtension(extension_dir, std::move(cb));
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::FinishInitialization() {
|
||||
void ElectronExtensionSystem::FinishInitialization() {
|
||||
// Inform the rest of the extensions system to start.
|
||||
ready_.Signal();
|
||||
content::NotificationService::current()->Notify(
|
||||
|
@ -59,20 +60,20 @@ void AtomExtensionSystem::FinishInitialization() {
|
|||
content::NotificationService::NoDetails());
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::ReloadExtension(const ExtensionId& extension_id) {
|
||||
void ElectronExtensionSystem::ReloadExtension(const ExtensionId& extension_id) {
|
||||
extension_loader_->ReloadExtension(extension_id);
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::RemoveExtension(const ExtensionId& extension_id) {
|
||||
void ElectronExtensionSystem::RemoveExtension(const ExtensionId& extension_id) {
|
||||
extension_loader_->UnloadExtension(
|
||||
extension_id, extensions::UnloadedExtensionReason::UNINSTALL);
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::Shutdown() {
|
||||
void ElectronExtensionSystem::Shutdown() {
|
||||
extension_loader_.reset();
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
||||
void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
||||
service_worker_manager_ =
|
||||
std::make_unique<ServiceWorkerManager>(browser_context_);
|
||||
runtime_data_ =
|
||||
|
@ -81,56 +82,57 @@ void AtomExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
|||
shared_user_script_master_ =
|
||||
std::make_unique<SharedUserScriptMaster>(browser_context_);
|
||||
app_sorting_ = std::make_unique<NullAppSorting>();
|
||||
extension_loader_ = std::make_unique<AtomExtensionLoader>(browser_context_);
|
||||
extension_loader_ =
|
||||
std::make_unique<ElectronExtensionLoader>(browser_context_);
|
||||
}
|
||||
|
||||
ExtensionService* AtomExtensionSystem::extension_service() {
|
||||
ExtensionService* ElectronExtensionSystem::extension_service() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RuntimeData* AtomExtensionSystem::runtime_data() {
|
||||
RuntimeData* ElectronExtensionSystem::runtime_data() {
|
||||
return runtime_data_.get();
|
||||
}
|
||||
|
||||
ManagementPolicy* AtomExtensionSystem::management_policy() {
|
||||
ManagementPolicy* ElectronExtensionSystem::management_policy() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ServiceWorkerManager* AtomExtensionSystem::service_worker_manager() {
|
||||
ServiceWorkerManager* ElectronExtensionSystem::service_worker_manager() {
|
||||
return service_worker_manager_.get();
|
||||
}
|
||||
|
||||
SharedUserScriptMaster* AtomExtensionSystem::shared_user_script_master() {
|
||||
SharedUserScriptMaster* ElectronExtensionSystem::shared_user_script_master() {
|
||||
return new SharedUserScriptMaster(browser_context_);
|
||||
}
|
||||
|
||||
StateStore* AtomExtensionSystem::state_store() {
|
||||
StateStore* ElectronExtensionSystem::state_store() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
StateStore* AtomExtensionSystem::rules_store() {
|
||||
StateStore* ElectronExtensionSystem::rules_store() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scoped_refptr<ValueStoreFactory> AtomExtensionSystem::store_factory() {
|
||||
scoped_refptr<ValueStoreFactory> ElectronExtensionSystem::store_factory() {
|
||||
return store_factory_;
|
||||
}
|
||||
|
||||
InfoMap* AtomExtensionSystem::info_map() {
|
||||
InfoMap* ElectronExtensionSystem::info_map() {
|
||||
if (!info_map_.get())
|
||||
info_map_ = new InfoMap;
|
||||
return info_map_.get();
|
||||
}
|
||||
|
||||
QuotaService* AtomExtensionSystem::quota_service() {
|
||||
QuotaService* ElectronExtensionSystem::quota_service() {
|
||||
return quota_service_.get();
|
||||
}
|
||||
|
||||
AppSorting* AtomExtensionSystem::app_sorting() {
|
||||
AppSorting* ElectronExtensionSystem::app_sorting() {
|
||||
return app_sorting_.get();
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::RegisterExtensionWithRequestContexts(
|
||||
void ElectronExtensionSystem::RegisterExtensionWithRequestContexts(
|
||||
const Extension* extension,
|
||||
base::OnceClosure callback) {
|
||||
base::PostTaskAndReply(
|
||||
|
@ -140,24 +142,24 @@ void AtomExtensionSystem::RegisterExtensionWithRequestContexts(
|
|||
std::move(callback));
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::UnregisterExtensionWithRequestContexts(
|
||||
void ElectronExtensionSystem::UnregisterExtensionWithRequestContexts(
|
||||
const std::string& extension_id,
|
||||
const UnloadedExtensionReason reason) {}
|
||||
|
||||
const base::OneShotEvent& AtomExtensionSystem::ready() const {
|
||||
const base::OneShotEvent& ElectronExtensionSystem::ready() const {
|
||||
return ready_;
|
||||
}
|
||||
|
||||
ContentVerifier* AtomExtensionSystem::content_verifier() {
|
||||
ContentVerifier* ElectronExtensionSystem::content_verifier() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<ExtensionSet> AtomExtensionSystem::GetDependentExtensions(
|
||||
std::unique_ptr<ExtensionSet> ElectronExtensionSystem::GetDependentExtensions(
|
||||
const Extension* extension) {
|
||||
return std::make_unique<ExtensionSet>();
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::InstallUpdate(
|
||||
void ElectronExtensionSystem::InstallUpdate(
|
||||
const std::string& extension_id,
|
||||
const std::string& public_key,
|
||||
const base::FilePath& temp_dir,
|
||||
|
@ -167,14 +169,14 @@ void AtomExtensionSystem::InstallUpdate(
|
|||
base::DeleteFile(temp_dir, true /* recursive */);
|
||||
}
|
||||
|
||||
bool AtomExtensionSystem::FinishDelayedInstallationIfReady(
|
||||
bool ElectronExtensionSystem::FinishDelayedInstallationIfReady(
|
||||
const std::string& extension_id,
|
||||
bool install_immediately) {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtomExtensionSystem::OnExtensionRegisteredWithRequestContexts(
|
||||
void ElectronExtensionSystem::OnExtensionRegisteredWithRequestContexts(
|
||||
scoped_refptr<Extension> extension) {
|
||||
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_);
|
||||
registry->AddReady(extension);
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -26,21 +26,22 @@ class BrowserContext;
|
|||
|
||||
namespace extensions {
|
||||
|
||||
class AtomExtensionLoader;
|
||||
class ElectronExtensionLoader;
|
||||
class ValueStoreFactory;
|
||||
|
||||
// A simplified version of ExtensionSystem for app_shell. Allows
|
||||
// app_shell to skip initialization of services it doesn't need.
|
||||
class AtomExtensionSystem : public ExtensionSystem {
|
||||
class ElectronExtensionSystem : public ExtensionSystem {
|
||||
public:
|
||||
using InstallUpdateCallback = ExtensionSystem::InstallUpdateCallback;
|
||||
explicit AtomExtensionSystem(content::BrowserContext* browser_context);
|
||||
~AtomExtensionSystem() override;
|
||||
explicit ElectronExtensionSystem(content::BrowserContext* browser_context);
|
||||
~ElectronExtensionSystem() override;
|
||||
|
||||
// Loads an unpacked extension from a directory. Returns the extension on
|
||||
// success, or nullptr otherwise.
|
||||
void LoadExtension(const base::FilePath& extension_dir,
|
||||
base::OnceCallback<void(const Extension*)> loaded);
|
||||
void LoadExtension(
|
||||
const base::FilePath& extension_dir,
|
||||
base::OnceCallback<void(const Extension*, const std::string&)> cb);
|
||||
|
||||
// Finish initialization for the shell extension system.
|
||||
void FinishInitialization();
|
||||
|
@ -98,18 +99,18 @@ class AtomExtensionSystem : public ExtensionSystem {
|
|||
std::unique_ptr<SharedUserScriptMaster> shared_user_script_master_;
|
||||
std::unique_ptr<AppSorting> app_sorting_;
|
||||
|
||||
std::unique_ptr<AtomExtensionLoader> extension_loader_;
|
||||
std::unique_ptr<ElectronExtensionLoader> extension_loader_;
|
||||
|
||||
scoped_refptr<ValueStoreFactory> store_factory_;
|
||||
|
||||
// Signaled when the extension system has completed its startup tasks.
|
||||
base::OneShotEvent ready_;
|
||||
|
||||
base::WeakPtrFactory<AtomExtensionSystem> weak_factory_;
|
||||
base::WeakPtrFactory<ElectronExtensionSystem> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomExtensionSystem);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystem);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_H_
|
|
@ -2,49 +2,50 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_extension_system_factory.h"
|
||||
#include "shell/browser/extensions/electron_extension_system_factory.h"
|
||||
|
||||
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
||||
#include "extensions/browser/extension_prefs_factory.h"
|
||||
#include "extensions/browser/extension_registry_factory.h"
|
||||
#include "shell/browser/extensions/atom_extension_system.h"
|
||||
#include "shell/browser/extensions/electron_extension_system.h"
|
||||
|
||||
using content::BrowserContext;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
ExtensionSystem* AtomExtensionSystemFactory::GetForBrowserContext(
|
||||
ExtensionSystem* ElectronExtensionSystemFactory::GetForBrowserContext(
|
||||
BrowserContext* context) {
|
||||
return static_cast<AtomExtensionSystem*>(
|
||||
return static_cast<ElectronExtensionSystem*>(
|
||||
GetInstance()->GetServiceForBrowserContext(context, true));
|
||||
}
|
||||
|
||||
// static
|
||||
AtomExtensionSystemFactory* AtomExtensionSystemFactory::GetInstance() {
|
||||
return base::Singleton<AtomExtensionSystemFactory>::get();
|
||||
ElectronExtensionSystemFactory* ElectronExtensionSystemFactory::GetInstance() {
|
||||
return base::Singleton<ElectronExtensionSystemFactory>::get();
|
||||
}
|
||||
|
||||
AtomExtensionSystemFactory::AtomExtensionSystemFactory()
|
||||
: ExtensionSystemProvider("AtomExtensionSystem",
|
||||
ElectronExtensionSystemFactory::ElectronExtensionSystemFactory()
|
||||
: ExtensionSystemProvider("ElectronExtensionSystem",
|
||||
BrowserContextDependencyManager::GetInstance()) {
|
||||
DependsOn(ExtensionPrefsFactory::GetInstance());
|
||||
DependsOn(ExtensionRegistryFactory::GetInstance());
|
||||
}
|
||||
|
||||
AtomExtensionSystemFactory::~AtomExtensionSystemFactory() {}
|
||||
ElectronExtensionSystemFactory::~ElectronExtensionSystemFactory() {}
|
||||
|
||||
KeyedService* AtomExtensionSystemFactory::BuildServiceInstanceFor(
|
||||
KeyedService* ElectronExtensionSystemFactory::BuildServiceInstanceFor(
|
||||
BrowserContext* context) const {
|
||||
return new AtomExtensionSystem(context);
|
||||
return new ElectronExtensionSystem(context);
|
||||
}
|
||||
|
||||
BrowserContext* AtomExtensionSystemFactory::GetBrowserContextToUse(
|
||||
BrowserContext* ElectronExtensionSystemFactory::GetBrowserContextToUse(
|
||||
BrowserContext* context) const {
|
||||
// Use a separate instance for incognito.
|
||||
return context;
|
||||
}
|
||||
|
||||
bool AtomExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
|
||||
bool ElectronExtensionSystemFactory::ServiceIsCreatedWithBrowserContext()
|
||||
const {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_FACTORY_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_FACTORY_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/singleton.h"
|
||||
|
@ -11,20 +11,20 @@
|
|||
|
||||
namespace extensions {
|
||||
|
||||
// A factory that provides AtomExtensionSystem.
|
||||
class AtomExtensionSystemFactory : public ExtensionSystemProvider {
|
||||
// A factory that provides ElectronExtensionSystem.
|
||||
class ElectronExtensionSystemFactory : public ExtensionSystemProvider {
|
||||
public:
|
||||
// ExtensionSystemProvider implementation:
|
||||
ExtensionSystem* GetForBrowserContext(
|
||||
content::BrowserContext* context) override;
|
||||
|
||||
static AtomExtensionSystemFactory* GetInstance();
|
||||
static ElectronExtensionSystemFactory* GetInstance();
|
||||
|
||||
private:
|
||||
friend struct base::DefaultSingletonTraits<AtomExtensionSystemFactory>;
|
||||
friend struct base::DefaultSingletonTraits<ElectronExtensionSystemFactory>;
|
||||
|
||||
AtomExtensionSystemFactory();
|
||||
~AtomExtensionSystemFactory() override;
|
||||
ElectronExtensionSystemFactory();
|
||||
~ElectronExtensionSystemFactory() override;
|
||||
|
||||
// BrowserContextKeyedServiceFactory implementation:
|
||||
KeyedService* BuildServiceInstanceFor(
|
||||
|
@ -33,9 +33,9 @@ class AtomExtensionSystemFactory : public ExtensionSystemProvider {
|
|||
content::BrowserContext* context) const override;
|
||||
bool ServiceIsCreatedWithBrowserContext() const override;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomExtensionSystemFactory);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystemFactory);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_FACTORY_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
|
@ -2,25 +2,25 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
|
||||
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
|
||||
|
||||
namespace extensions {
|
||||
|
||||
AtomExtensionWebContentsObserver::AtomExtensionWebContentsObserver(
|
||||
ElectronExtensionWebContentsObserver::ElectronExtensionWebContentsObserver(
|
||||
content::WebContents* web_contents)
|
||||
: ExtensionWebContentsObserver(web_contents) {}
|
||||
|
||||
AtomExtensionWebContentsObserver::~AtomExtensionWebContentsObserver() {}
|
||||
ElectronExtensionWebContentsObserver::~ElectronExtensionWebContentsObserver() {}
|
||||
|
||||
void AtomExtensionWebContentsObserver::CreateForWebContents(
|
||||
void ElectronExtensionWebContentsObserver::CreateForWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
content::WebContentsUserData<
|
||||
AtomExtensionWebContentsObserver>::CreateForWebContents(web_contents);
|
||||
ElectronExtensionWebContentsObserver>::CreateForWebContents(web_contents);
|
||||
|
||||
// Initialize this instance if necessary.
|
||||
FromWebContents(web_contents)->Initialize();
|
||||
}
|
||||
|
||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(AtomExtensionWebContentsObserver)
|
||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(ElectronExtensionWebContentsObserver)
|
||||
|
||||
} // namespace extensions
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
|
@ -12,26 +12,29 @@
|
|||
namespace extensions {
|
||||
|
||||
// The app_shell version of ExtensionWebContentsObserver.
|
||||
class AtomExtensionWebContentsObserver
|
||||
class ElectronExtensionWebContentsObserver
|
||||
: public ExtensionWebContentsObserver,
|
||||
public content::WebContentsUserData<AtomExtensionWebContentsObserver> {
|
||||
public content::WebContentsUserData<
|
||||
ElectronExtensionWebContentsObserver> {
|
||||
public:
|
||||
~AtomExtensionWebContentsObserver() override;
|
||||
~ElectronExtensionWebContentsObserver() override;
|
||||
|
||||
// Creates and initializes an instance of this class for the given
|
||||
// |web_contents|, if it doesn't already exist.
|
||||
static void CreateForWebContents(content::WebContents* web_contents);
|
||||
|
||||
private:
|
||||
friend class content::WebContentsUserData<AtomExtensionWebContentsObserver>;
|
||||
friend class content::WebContentsUserData<
|
||||
ElectronExtensionWebContentsObserver>;
|
||||
|
||||
explicit AtomExtensionWebContentsObserver(content::WebContents* web_contents);
|
||||
explicit ElectronExtensionWebContentsObserver(
|
||||
content::WebContents* web_contents);
|
||||
|
||||
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomExtensionWebContentsObserver);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionWebContentsObserver);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_WEB_CONTENTS_OBSERVER_H_
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
|
||||
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
|
||||
#include "shell/browser/extensions/electron_messaging_delegate.h"
|
||||
|
||||
namespace extensions {
|
||||
|
@ -22,7 +22,7 @@ MessagingDelegate* ElectronExtensionsAPIClient::GetMessagingDelegate() {
|
|||
|
||||
void ElectronExtensionsAPIClient::AttachWebContentsHelpers(
|
||||
content::WebContents* web_contents) const {
|
||||
extensions::AtomExtensionWebContentsObserver::CreateForWebContents(
|
||||
extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
|
||||
web_contents);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_extensions_browser_client.h"
|
||||
#include "shell/browser/extensions/electron_extensions_browser_client.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
@ -30,13 +30,13 @@
|
|||
#include "shell/browser/atom_browser_client.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h"
|
||||
#include "shell/browser/extensions/atom_extension_host_delegate.h"
|
||||
#include "shell/browser/extensions/atom_extension_system_factory.h"
|
||||
#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
|
||||
#include "shell/browser/extensions/atom_navigation_ui_data.h"
|
||||
#include "shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h"
|
||||
#include "shell/browser/extensions/electron_extension_host_delegate.h"
|
||||
#include "shell/browser/extensions/electron_extension_system_factory.h"
|
||||
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
|
||||
#include "shell/browser/extensions/electron_extensions_api_client.h"
|
||||
#include "shell/browser/extensions/electron_extensions_browser_api_provider.h"
|
||||
#include "shell/browser/extensions/electron_navigation_ui_data.h"
|
||||
#include "shell/browser/extensions/electron_process_manager_delegate.h"
|
||||
|
||||
using content::BrowserContext;
|
||||
|
@ -44,7 +44,7 @@ using content::BrowserThread;
|
|||
|
||||
namespace electron {
|
||||
|
||||
AtomExtensionsBrowserClient::AtomExtensionsBrowserClient()
|
||||
ElectronExtensionsBrowserClient::ElectronExtensionsBrowserClient()
|
||||
: api_client_(new extensions::ElectronExtensionsAPIClient),
|
||||
process_manager_delegate_(new extensions::ElectronProcessManagerDelegate),
|
||||
extension_cache_(new extensions::NullExtensionCache()) {
|
||||
|
@ -58,19 +58,19 @@ AtomExtensionsBrowserClient::AtomExtensionsBrowserClient()
|
|||
std::make_unique<extensions::ElectronExtensionsBrowserAPIProvider>());
|
||||
}
|
||||
|
||||
AtomExtensionsBrowserClient::~AtomExtensionsBrowserClient() {}
|
||||
ElectronExtensionsBrowserClient::~ElectronExtensionsBrowserClient() {}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsShuttingDown() {
|
||||
bool ElectronExtensionsBrowserClient::IsShuttingDown() {
|
||||
return electron::Browser::Get()->is_shutting_down();
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::AreExtensionsDisabled(
|
||||
bool ElectronExtensionsBrowserClient::AreExtensionsDisabled(
|
||||
const base::CommandLine& command_line,
|
||||
BrowserContext* context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
||||
bool ElectronExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
||||
auto context_map = AtomBrowserContext::browser_context_map();
|
||||
for (auto const& entry : context_map) {
|
||||
if (entry.second && entry.second.get() == context)
|
||||
|
@ -79,23 +79,23 @@ bool AtomExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsSameContext(BrowserContext* first,
|
||||
BrowserContext* second) {
|
||||
bool ElectronExtensionsBrowserClient::IsSameContext(BrowserContext* first,
|
||||
BrowserContext* second) {
|
||||
return first == second;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::HasOffTheRecordContext(
|
||||
bool ElectronExtensionsBrowserClient::HasOffTheRecordContext(
|
||||
BrowserContext* context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BrowserContext* AtomExtensionsBrowserClient::GetOffTheRecordContext(
|
||||
BrowserContext* ElectronExtensionsBrowserClient::GetOffTheRecordContext(
|
||||
BrowserContext* context) {
|
||||
// app_shell only supports a single context.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BrowserContext* AtomExtensionsBrowserClient::GetOriginalContext(
|
||||
BrowserContext* ElectronExtensionsBrowserClient::GetOriginalContext(
|
||||
BrowserContext* context) {
|
||||
DCHECK(context);
|
||||
if (context->IsOffTheRecord()) {
|
||||
|
@ -105,24 +105,24 @@ BrowserContext* AtomExtensionsBrowserClient::GetOriginalContext(
|
|||
}
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsGuestSession(
|
||||
bool ElectronExtensionsBrowserClient::IsGuestSession(
|
||||
BrowserContext* context) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsExtensionIncognitoEnabled(
|
||||
bool ElectronExtensionsBrowserClient::IsExtensionIncognitoEnabled(
|
||||
const std::string& extension_id,
|
||||
content::BrowserContext* context) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::CanExtensionCrossIncognito(
|
||||
bool ElectronExtensionsBrowserClient::CanExtensionCrossIncognito(
|
||||
const extensions::Extension* extension,
|
||||
content::BrowserContext* context) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
base::FilePath AtomExtensionsBrowserClient::GetBundleResourcePath(
|
||||
base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath(
|
||||
const network::ResourceRequest& request,
|
||||
const base::FilePath& extension_resources_path,
|
||||
int* resource_id) const {
|
||||
|
@ -130,7 +130,7 @@ base::FilePath AtomExtensionsBrowserClient::GetBundleResourcePath(
|
|||
return base::FilePath();
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::LoadResourceFromResourceBundle(
|
||||
void ElectronExtensionsBrowserClient::LoadResourceFromResourceBundle(
|
||||
const network::ResourceRequest& request,
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
const base::FilePath& resource_relative_path,
|
||||
|
@ -172,7 +172,7 @@ bool AllowCrossRendererResourceLoad(const GURL& url,
|
|||
}
|
||||
} // namespace
|
||||
|
||||
bool AtomExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
||||
bool ElectronExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
||||
const GURL& url,
|
||||
content::ResourceType resource_type,
|
||||
ui::PageTransition page_transition,
|
||||
|
@ -192,71 +192,73 @@ bool AtomExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
|||
return false;
|
||||
}
|
||||
|
||||
PrefService* AtomExtensionsBrowserClient::GetPrefServiceForContext(
|
||||
PrefService* ElectronExtensionsBrowserClient::GetPrefServiceForContext(
|
||||
BrowserContext* context) {
|
||||
return static_cast<AtomBrowserContext*>(context)->prefs();
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
|
||||
void ElectronExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
|
||||
content::BrowserContext* context,
|
||||
std::vector<extensions::EarlyExtensionPrefsObserver*>* observers) const {}
|
||||
|
||||
extensions::ProcessManagerDelegate*
|
||||
AtomExtensionsBrowserClient::GetProcessManagerDelegate() const {
|
||||
ElectronExtensionsBrowserClient::GetProcessManagerDelegate() const {
|
||||
return process_manager_delegate_.get();
|
||||
}
|
||||
|
||||
std::unique_ptr<extensions::ExtensionHostDelegate> AtomExtensionsBrowserClient::
|
||||
std::unique_ptr<extensions::ExtensionHostDelegate>
|
||||
ElectronExtensionsBrowserClient::
|
||||
CreateExtensionHostDelegate() { // TODO(samuelmaddock):
|
||||
return base::WrapUnique(new extensions::AtomExtensionHostDelegate);
|
||||
return base::WrapUnique(new extensions::ElectronExtensionHostDelegate);
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
|
||||
bool ElectronExtensionsBrowserClient::DidVersionUpdate(
|
||||
BrowserContext* context) {
|
||||
// TODO(jamescook): We might want to tell extensions when app_shell updates.
|
||||
return false;
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::PermitExternalProtocolHandler() {}
|
||||
void ElectronExtensionsBrowserClient::PermitExternalProtocolHandler() {}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsInDemoMode() {
|
||||
bool ElectronExtensionsBrowserClient::IsInDemoMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsScreensaverInDemoMode(
|
||||
bool ElectronExtensionsBrowserClient::IsScreensaverInDemoMode(
|
||||
const std::string& app_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsRunningInForcedAppMode() {
|
||||
bool ElectronExtensionsBrowserClient::IsRunningInForcedAppMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsAppModeForcedForApp(
|
||||
bool ElectronExtensionsBrowserClient::IsAppModeForcedForApp(
|
||||
const extensions::ExtensionId& extension_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
||||
bool ElectronExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
||||
return false;
|
||||
}
|
||||
|
||||
extensions::ExtensionSystemProvider*
|
||||
AtomExtensionsBrowserClient::GetExtensionSystemFactory() {
|
||||
return extensions::AtomExtensionSystemFactory::GetInstance();
|
||||
ElectronExtensionsBrowserClient::GetExtensionSystemFactory() {
|
||||
return extensions::ElectronExtensionSystemFactory::GetInstance();
|
||||
}
|
||||
|
||||
std::unique_ptr<extensions::RuntimeAPIDelegate>
|
||||
AtomExtensionsBrowserClient::CreateRuntimeAPIDelegate(
|
||||
ElectronExtensionsBrowserClient::CreateRuntimeAPIDelegate(
|
||||
content::BrowserContext* context) const {
|
||||
return std::make_unique<extensions::AtomRuntimeAPIDelegate>(context);
|
||||
return std::make_unique<extensions::ElectronRuntimeAPIDelegate>(context);
|
||||
}
|
||||
|
||||
const extensions::ComponentExtensionResourceManager*
|
||||
AtomExtensionsBrowserClient::GetComponentExtensionResourceManager() {
|
||||
ElectronExtensionsBrowserClient::GetComponentExtensionResourceManager() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::BroadcastEventToRenderers(
|
||||
void ElectronExtensionsBrowserClient::BroadcastEventToRenderers(
|
||||
extensions::events::HistogramValue histogram_value,
|
||||
const std::string& event_name,
|
||||
std::unique_ptr<base::ListValue> args,
|
||||
|
@ -264,9 +266,10 @@ void AtomExtensionsBrowserClient::BroadcastEventToRenderers(
|
|||
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
|
||||
base::PostTask(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&AtomExtensionsBrowserClient::BroadcastEventToRenderers,
|
||||
base::Unretained(this), histogram_value, event_name,
|
||||
std::move(args), dispatch_to_off_the_record_profiles));
|
||||
base::BindOnce(
|
||||
&ElectronExtensionsBrowserClient::BroadcastEventToRenderers,
|
||||
base::Unretained(this), histogram_value, event_name,
|
||||
std::move(args), dispatch_to_off_the_record_profiles));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -281,49 +284,50 @@ void AtomExtensionsBrowserClient::BroadcastEventToRenderers(
|
|||
}
|
||||
}
|
||||
|
||||
extensions::ExtensionCache* AtomExtensionsBrowserClient::GetExtensionCache() {
|
||||
extensions::ExtensionCache*
|
||||
ElectronExtensionsBrowserClient::GetExtensionCache() {
|
||||
return extension_cache_.get();
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
|
||||
bool ElectronExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsMinBrowserVersionSupported(
|
||||
bool ElectronExtensionsBrowserClient::IsMinBrowserVersionSupported(
|
||||
const std::string& min_version) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::SetAPIClientForTest(
|
||||
void ElectronExtensionsBrowserClient::SetAPIClientForTest(
|
||||
extensions::ExtensionsAPIClient* api_client) {
|
||||
api_client_.reset(api_client);
|
||||
}
|
||||
|
||||
extensions::ExtensionWebContentsObserver*
|
||||
AtomExtensionsBrowserClient::GetExtensionWebContentsObserver(
|
||||
ElectronExtensionsBrowserClient::GetExtensionWebContentsObserver(
|
||||
content::WebContents* web_contents) {
|
||||
return extensions::AtomExtensionWebContentsObserver::FromWebContents(
|
||||
return extensions::ElectronExtensionWebContentsObserver::FromWebContents(
|
||||
web_contents);
|
||||
}
|
||||
|
||||
extensions::KioskDelegate* AtomExtensionsBrowserClient::GetKioskDelegate() {
|
||||
extensions::KioskDelegate* ElectronExtensionsBrowserClient::GetKioskDelegate() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AtomExtensionsBrowserClient::IsLockScreenContext(
|
||||
bool ElectronExtensionsBrowserClient::IsLockScreenContext(
|
||||
content::BrowserContext* context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string AtomExtensionsBrowserClient::GetApplicationLocale() {
|
||||
std::string ElectronExtensionsBrowserClient::GetApplicationLocale() {
|
||||
return AtomBrowserClient::Get()->GetApplicationLocale();
|
||||
}
|
||||
|
||||
std::string AtomExtensionsBrowserClient::GetUserAgent() const {
|
||||
std::string ElectronExtensionsBrowserClient::GetUserAgent() const {
|
||||
return AtomBrowserClient::Get()->GetUserAgent();
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
||||
void ElectronExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
||||
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const extensions::Extension* extension) const {}
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -31,10 +31,11 @@ namespace electron {
|
|||
// with no related incognito context.
|
||||
// Must be initialized via InitWithBrowserContext() once the BrowserContext is
|
||||
// created.
|
||||
class AtomExtensionsBrowserClient : public extensions::ExtensionsBrowserClient {
|
||||
class ElectronExtensionsBrowserClient
|
||||
: public extensions::ExtensionsBrowserClient {
|
||||
public:
|
||||
AtomExtensionsBrowserClient();
|
||||
~AtomExtensionsBrowserClient() override;
|
||||
ElectronExtensionsBrowserClient();
|
||||
~ElectronExtensionsBrowserClient() override;
|
||||
|
||||
// ExtensionsBrowserClient overrides:
|
||||
bool IsShuttingDown() override;
|
||||
|
@ -137,9 +138,9 @@ class AtomExtensionsBrowserClient : public extensions::ExtensionsBrowserClient {
|
|||
// The extension cache used for download and installation.
|
||||
std::unique_ptr<extensions::ExtensionCache> extension_cache_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomExtensionsBrowserClient);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsBrowserClient);
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSIONS_BROWSER_CLIENT_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/extensions/atom_navigation_ui_data.h"
|
||||
#include "shell/browser/extensions/electron_navigation_ui_data.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
@ -11,20 +11,20 @@
|
|||
|
||||
namespace extensions {
|
||||
|
||||
AtomNavigationUIData::AtomNavigationUIData() {}
|
||||
ElectronNavigationUIData::ElectronNavigationUIData() {}
|
||||
|
||||
AtomNavigationUIData::AtomNavigationUIData(
|
||||
ElectronNavigationUIData::ElectronNavigationUIData(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
extension_data_ = std::make_unique<ExtensionNavigationUIData>(
|
||||
navigation_handle, extension_misc::kUnknownTabId,
|
||||
extension_misc::kUnknownWindowId);
|
||||
}
|
||||
|
||||
AtomNavigationUIData::~AtomNavigationUIData() {}
|
||||
ElectronNavigationUIData::~ElectronNavigationUIData() {}
|
||||
|
||||
std::unique_ptr<content::NavigationUIData> AtomNavigationUIData::Clone() {
|
||||
std::unique_ptr<AtomNavigationUIData> copy =
|
||||
std::make_unique<AtomNavigationUIData>();
|
||||
std::unique_ptr<content::NavigationUIData> ElectronNavigationUIData::Clone() {
|
||||
std::unique_ptr<ElectronNavigationUIData> copy =
|
||||
std::make_unique<ElectronNavigationUIData>();
|
||||
|
||||
if (extension_data_)
|
||||
copy->SetExtensionNavigationUIData(extension_data_->DeepCopy());
|
||||
|
@ -32,7 +32,7 @@ std::unique_ptr<content::NavigationUIData> AtomNavigationUIData::Clone() {
|
|||
return std::move(copy);
|
||||
}
|
||||
|
||||
void AtomNavigationUIData::SetExtensionNavigationUIData(
|
||||
void ElectronNavigationUIData::SetExtensionNavigationUIData(
|
||||
std::unique_ptr<ExtensionNavigationUIData> extension_data) {
|
||||
extension_data_ = std::move(extension_data);
|
||||
}
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_NAVIGATION_UI_DATA_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ATOM_NAVIGATION_UI_DATA_H_
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_ELECTRON_NAVIGATION_UI_DATA_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_ELECTRON_NAVIGATION_UI_DATA_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -18,11 +18,12 @@ namespace extensions {
|
|||
// beginning of each navigation. The class is instantiated on the UI thread,
|
||||
// then a copy created using Clone is passed to the content::ResourceRequestInfo
|
||||
// on the IO thread.
|
||||
class AtomNavigationUIData : public content::NavigationUIData {
|
||||
class ElectronNavigationUIData : public content::NavigationUIData {
|
||||
public:
|
||||
AtomNavigationUIData();
|
||||
explicit AtomNavigationUIData(content::NavigationHandle* navigation_handle);
|
||||
~AtomNavigationUIData() override;
|
||||
ElectronNavigationUIData();
|
||||
explicit ElectronNavigationUIData(
|
||||
content::NavigationHandle* navigation_handle);
|
||||
~ElectronNavigationUIData() override;
|
||||
|
||||
// Creates a new ChromeNavigationUIData that is a deep copy of the original.
|
||||
// Any changes to the original after the clone is created will not be
|
||||
|
@ -40,9 +41,9 @@ class AtomNavigationUIData : public content::NavigationUIData {
|
|||
// Manages the lifetime of optional ExtensionNavigationUIData information.
|
||||
std::unique_ptr<ExtensionNavigationUIData> extension_data_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomNavigationUIData);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronNavigationUIData);
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ATOM_NAVIGATION_UI_DATA_H_
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_ELECTRON_NAVIGATION_UI_DATA_H_
|
Loading…
Add table
Add a link
Reference in a new issue