feat: enable native extensions support (#21814)

This commit is contained in:
Jeremy Apthorp 2020-02-03 14:01:10 -08:00 committed by GitHub
parent bdf65a75d0
commit a061c87e56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 1054 additions and 941 deletions

View file

@ -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

View file

@ -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

View file

@ -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_