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_
|
Loading…
Add table
Add a link
Reference in a new issue