diff --git a/build/args/all.gn b/build/args/all.gn index f322706a427b..6f6bd45aa1d6 100644 --- a/build/args/all.gn +++ b/build/args/all.gn @@ -23,3 +23,5 @@ is_cfi = false # TODO: disabled due to crashes. re-enable. enable_osr = false + +enable_electron_extensions = true diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index eb91f91caa19..bcc58adb775f 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -677,7 +677,7 @@ Returns `BrowserWindow | null` - The window that owns the given `browserView`. I Returns `BrowserWindow` - The window with the given `id`. -#### `BrowserWindow.addExtension(path)` +#### `BrowserWindow.addExtension(path)` _Deprecated_ * `path` String @@ -688,7 +688,10 @@ The method will also not return if the extension's manifest is missing or incomp **Note:** This API cannot be called before the `ready` event of the `app` module is emitted. -#### `BrowserWindow.removeExtension(name)` +**Note:** This method is deprecated. Instead, use +[`ses.loadExtension(path)`](session.md#sesloadextensionpath). + +#### `BrowserWindow.removeExtension(name)` _Deprecated_ * `name` String @@ -697,7 +700,10 @@ Remove a Chrome extension by name. **Note:** This API cannot be called before the `ready` event of the `app` module is emitted. -#### `BrowserWindow.getExtensions()` +**Note:** This method is deprecated. Instead, use +[`ses.removeExtension(extension_id)`](session.md#sesremoveextensionextensionid). + +#### `BrowserWindow.getExtensions()` _Deprecated_ Returns `Record` - The keys are the extension names and each value is an Object containing `name` and `version` properties. @@ -705,7 +711,10 @@ an Object containing `name` and `version` properties. **Note:** This API cannot be called before the `ready` event of the `app` module is emitted. -#### `BrowserWindow.addDevToolsExtension(path)` +**Note:** This method is deprecated. Instead, use +[`ses.getAllExtensions()`](session.md#sesgetallextensions). + +#### `BrowserWindow.addDevToolsExtension(path)` _Deprecated_ * `path` String @@ -721,7 +730,10 @@ The method will also not return if the extension's manifest is missing or incomp **Note:** This API cannot be called before the `ready` event of the `app` module is emitted. -#### `BrowserWindow.removeDevToolsExtension(name)` +**Note:** This method is deprecated. Instead, use +[`ses.loadExtension(path)`](session.md#sesloadextensionpath). + +#### `BrowserWindow.removeDevToolsExtension(name)` _Deprecated_ * `name` String @@ -730,7 +742,10 @@ Remove a DevTools extension by name. **Note:** This API cannot be called before the `ready` event of the `app` module is emitted. -#### `BrowserWindow.getDevToolsExtensions()` +**Note:** This method is deprecated. Instead, use +[`ses.removeExtension(extension_id)`](session.md#sesremoveextensionextensionid). + +#### `BrowserWindow.getDevToolsExtensions()` _Deprecated_ Returns `Record` - The keys are the extension names and each value is an Object containing `name` and `version` properties. @@ -747,6 +762,9 @@ console.log(installed) **Note:** This API cannot be called before the `ready` event of the `app` module is emitted. +**Note:** This method is deprecated. Instead, use +[`ses.getAllExtensions()`](session.md#sesgetallextensions). + ### Instance Properties Objects created with `new BrowserWindow` have the following properties: diff --git a/docs/api/session.md b/docs/api/session.md index d0334ccc4549..22af38488b31 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -495,6 +495,65 @@ Returns `Boolean` - Whether the word was successfully written to the custom dict **Note:** On macOS and Windows 10 this word will be written to the OS custom dictionary as well +#### `ses.loadExtension(path)` + +* `path` String - Path to a directory containing an unpacked Chrome extension + +Returns `Promise` - resolves when the extension is loaded. + +This method will raise an exception if the extension could not be loaded. If +there are warnings when installing the extension (e.g. if the extension +requests an API that Electron does not support) then they will be logged to the +console. + +Note that Electron does not support the full range of Chrome extensions APIs. + +Note that in previous versions of Electron, extensions that were loaded would +be remembered for future runs of the application. This is no longer the case: +`loadExtension` must be called on every boot of your app if you want the +extension to be loaded. + +```js +const { app, session } = require('electron') +const path = require('path') + +app.on('ready', async () => { + await session.defaultSession.loadExtension(path.join(__dirname, 'react-devtools')) + // Note that in order to use the React DevTools extension, you'll need to + // download and unzip a copy of the extension. +}) +``` + +This API does not support loading packed (.crx) extensions. + +**Note:** This API cannot be called before the `ready` event of the `app` module +is emitted. + +#### `ses.removeExtension(extensionId)` + +* `extensionId` String - ID of extension to remove + +Unloads an extension. + +**Note:** This API cannot be called before the `ready` event of the `app` module +is emitted. + +#### `ses.getExtension(extensionId)` + +* `extensionId` String - ID of extension to query + +Returns `Extension` | `null` - The loaded extension with the given ID. + +**Note:** This API cannot be called before the `ready` event of the `app` module +is emitted. + +#### `ses.getAllExtensions()` + +Returns `Extension[]` - A list of all loaded extensions. + +**Note:** This API cannot be called before the `ready` event of the `app` module +is emitted. + ### Instance Properties The following properties are available on instances of `Session`: diff --git a/docs/api/structures/extension.md b/docs/api/structures/extension.md new file mode 100644 index 000000000000..f575d352634c --- /dev/null +++ b/docs/api/structures/extension.md @@ -0,0 +1,5 @@ +# Extension Object + +* `id` String +* `name` String +* `version` String diff --git a/filenames.auto.gni b/filenames.auto.gni index e39410e9bd65..1befe12cf20f 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -77,6 +77,7 @@ auto_filenames = { "docs/api/structures/display.md", "docs/api/structures/event.md", "docs/api/structures/extension-info.md", + "docs/api/structures/extension.md", "docs/api/structures/file-filter.md", "docs/api/structures/file-path-with-headers.md", "docs/api/structures/gpu-feature-status.md", diff --git a/filenames.gni b/filenames.gni index 2ca34e9b060d..b7a54b23f689 100644 --- a/filenames.gni +++ b/filenames.gni @@ -465,8 +465,6 @@ filenames = { "shell/common/crash_reporter/linux/crash_dump_handler.h", "shell/common/crash_reporter/win/crash_service_main.cc", "shell/common/crash_reporter/win/crash_service_main.h", - "shell/common/deprecate_util.cc", - "shell/common/deprecate_util.h", "shell/common/gin_converters/accelerator_converter.cc", "shell/common/gin_converters/accelerator_converter.h", "shell/common/gin_converters/blink_converter.cc", @@ -547,6 +545,8 @@ filenames = { "shell/common/platform_util_linux.cc", "shell/common/platform_util_mac.mm", "shell/common/platform_util_win.cc", + "shell/common/process_util.cc", + "shell/common/process_util.h", "shell/common/skia_util.cc", "shell/common/skia_util.h", "shell/common/v8_value_converter.cc", @@ -591,28 +591,28 @@ filenames = { ] lib_sources_extensions = [ - "shell/browser/extensions/api/runtime/atom_runtime_api_delegate.cc", - "shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h", + "shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc", + "shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h", "shell/browser/extensions/api/tabs/tabs_api.cc", "shell/browser/extensions/api/tabs/tabs_api.h", - "shell/browser/extensions/atom_extensions_browser_client.cc", - "shell/browser/extensions/atom_extensions_browser_client.h", - "shell/browser/extensions/atom_browser_context_keyed_service_factories.cc", - "shell/browser/extensions/atom_browser_context_keyed_service_factories.h", - "shell/browser/extensions/atom_display_info_provider.cc", - "shell/browser/extensions/atom_display_info_provider.h", - "shell/browser/extensions/atom_extension_host_delegate.cc", - "shell/browser/extensions/atom_extension_host_delegate.h", - "shell/browser/extensions/atom_extension_loader.cc", - "shell/browser/extensions/atom_extension_loader.h", - "shell/browser/extensions/atom_extension_system.cc", - "shell/browser/extensions/atom_extension_system.h", - "shell/browser/extensions/atom_extension_system_factory.cc", - "shell/browser/extensions/atom_extension_system_factory.h", - "shell/browser/extensions/atom_extension_web_contents_observer.cc", - "shell/browser/extensions/atom_extension_web_contents_observer.h", - "shell/browser/extensions/atom_navigation_ui_data.cc", - "shell/browser/extensions/atom_navigation_ui_data.h", + "shell/browser/extensions/electron_extensions_browser_client.cc", + "shell/browser/extensions/electron_extensions_browser_client.h", + "shell/browser/extensions/electron_browser_context_keyed_service_factories.cc", + "shell/browser/extensions/electron_browser_context_keyed_service_factories.h", + "shell/browser/extensions/electron_display_info_provider.cc", + "shell/browser/extensions/electron_display_info_provider.h", + "shell/browser/extensions/electron_extension_host_delegate.cc", + "shell/browser/extensions/electron_extension_host_delegate.h", + "shell/browser/extensions/electron_extension_loader.cc", + "shell/browser/extensions/electron_extension_loader.h", + "shell/browser/extensions/electron_extension_system.cc", + "shell/browser/extensions/electron_extension_system.h", + "shell/browser/extensions/electron_extension_system_factory.cc", + "shell/browser/extensions/electron_extension_system_factory.h", + "shell/browser/extensions/electron_extension_web_contents_observer.cc", + "shell/browser/extensions/electron_extension_web_contents_observer.h", + "shell/browser/extensions/electron_navigation_ui_data.cc", + "shell/browser/extensions/electron_navigation_ui_data.h", "shell/browser/extensions/electron_process_manager_delegate.cc", "shell/browser/extensions/electron_process_manager_delegate.h", "shell/browser/extensions/electron_extensions_api_client.cc", @@ -621,12 +621,12 @@ filenames = { "shell/browser/extensions/electron_extensions_browser_api_provider.h", "shell/browser/extensions/electron_messaging_delegate.cc", "shell/browser/extensions/electron_messaging_delegate.h", - "shell/common/extensions/atom_extensions_api_provider.cc", - "shell/common/extensions/atom_extensions_api_provider.h", - "shell/common/extensions/atom_extensions_client.cc", - "shell/common/extensions/atom_extensions_client.h", - "shell/renderer/extensions/atom_extensions_renderer_client.cc", - "shell/renderer/extensions/atom_extensions_renderer_client.h", + "shell/common/extensions/electron_extensions_api_provider.cc", + "shell/common/extensions/electron_extensions_api_provider.h", + "shell/common/extensions/electron_extensions_client.cc", + "shell/common/extensions/electron_extensions_client.h", + "shell/renderer/extensions/electron_extensions_renderer_client.cc", + "shell/renderer/extensions/electron_extensions_renderer_client.h", "shell/renderer/extensions/electron_extensions_dispatcher_delegate.cc", "shell/renderer/extensions/electron_extensions_dispatcher_delegate.h", ] diff --git a/shell/browser/api/atom_api_protocol.cc b/shell/browser/api/atom_api_protocol.cc index 83e807919cea..173422251924 100644 --- a/shell/browser/api/atom_api_protocol.cc +++ b/shell/browser/api/atom_api_protocol.cc @@ -12,13 +12,13 @@ #include "content/public/browser/child_process_security_policy.h" #include "shell/browser/atom_browser_context.h" #include "shell/browser/browser.h" -#include "shell/common/deprecate_util.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/gin_converters/net_converter.h" #include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/gin_helper/promise.h" #include "shell/common/options_switches.h" +#include "shell/common/process_util.h" #include "url/url_util.h" namespace { @@ -217,12 +217,11 @@ bool Protocol::IsProtocolIntercepted(const std::string& scheme) { v8::Local Protocol::IsProtocolHandled(const std::string& scheme, gin::Arguments* args) { node::Environment* env = node::Environment::GetCurrent(args->isolate()); - EmitDeprecationWarning( - env, - "The protocol.isProtocolHandled API is deprecated, use " - "protocol.isProtocolRegistered or protocol.isProtocolIntercepted " - "instead.", - "ProtocolDeprecateIsProtocolHandled"); + EmitWarning(env, + "The protocol.isProtocolHandled API is deprecated, use " + "protocol.isProtocolRegistered or protocol.isProtocolIntercepted " + "instead.", + "ProtocolDeprecateIsProtocolHandled"); return gin_helper::Promise::ResolvedPromise( isolate(), IsProtocolRegistered(scheme) || IsProtocolIntercepted(scheme) || @@ -241,7 +240,7 @@ void Protocol::HandleOptionalCallback(gin::Arguments* args, CompletionCallback callback; if (args->GetNext(&callback)) { node::Environment* env = node::Environment::GetCurrent(args->isolate()); - EmitDeprecationWarning( + EmitWarning( env, "The callback argument of protocol module APIs is no longer needed.", "ProtocolDeprecateCallback"); diff --git a/shell/browser/api/atom_api_session.cc b/shell/browser/api/atom_api_session.cc index b1a1bc3e22b9..877e5e6dbd86 100644 --- a/shell/browser/api/atom_api_session.cc +++ b/shell/browser/api/atom_api_session.cc @@ -63,11 +63,12 @@ #include "shell/common/gin_helper/object_template_builder.h" #include "shell/common/node_includes.h" #include "shell/common/options_switches.h" +#include "shell/common/process_util.h" #include "ui/base/l10n/l10n_util.h" #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) #include "extensions/browser/extension_registry.h" -#include "shell/browser/extensions/atom_extension_system.h" +#include "shell/browser/extensions/electron_extension_system.h" #include "shell/common/gin_converters/extension_converter.h" #endif @@ -613,19 +614,23 @@ v8::Local Session::LoadExtension( gin_helper::Promise promise(isolate()); v8::Local handle = promise.GetHandle(); - auto* extension_system = static_cast( + auto* extension_system = static_cast( extensions::ExtensionSystem::Get(browser_context())); extension_system->LoadExtension( extension_path, base::BindOnce( [](gin_helper::Promise promise, - const extensions::Extension* extension) { + const extensions::Extension* extension, + const std::string& error_msg) { if (extension) { + if (!error_msg.empty()) { + node::Environment* env = + node::Environment::GetCurrent(v8::Isolate::GetCurrent()); + EmitWarning(env, error_msg, "ExtensionLoadWarning"); + } promise.Resolve(extension); } else { - // TODO(nornagon): plumb through error message from extension - // loader. - promise.RejectWithErrorMessage("Failed to load extension"); + promise.RejectWithErrorMessage(error_msg); } }, std::move(promise))); @@ -634,7 +639,7 @@ v8::Local Session::LoadExtension( } void Session::RemoveExtension(const std::string& extension_id) { - auto* extension_system = static_cast( + auto* extension_system = static_cast( extensions::ExtensionSystem::Get(browser_context())); extension_system->RemoveExtension(extension_id); } diff --git a/shell/browser/api/atom_api_system_preferences_mac.mm b/shell/browser/api/atom_api_system_preferences_mac.mm index dc50f820bf32..d4be5ce3ded3 100644 --- a/shell/browser/api/atom_api_system_preferences_mac.mm +++ b/shell/browser/api/atom_api_system_preferences_mac.mm @@ -26,9 +26,9 @@ #include "shell/browser/mac/atom_application.h" #include "shell/browser/mac/dict_util.h" #include "shell/browser/ui/cocoa/NSColor+Hex.h" -#include "shell/common/deprecate_util.h" #include "shell/common/gin_converters/gurl_converter.h" #include "shell/common/gin_converters/value_converter.h" +#include "shell/common/process_util.h" #include "ui/native_theme/native_theme.h" namespace gin { @@ -504,7 +504,7 @@ std::string SystemPreferences::GetColor(gin_helper::ErrorThrower thrower, NSColor* sysColor = nil; if (color == "alternate-selected-control-text") { sysColor = [NSColor alternateSelectedControlTextColor]; - EmitDeprecationWarning( + EmitWarning( node::Environment::GetCurrent(thrower.isolate()), "'alternate-selected-control-text' is deprecated as an input to " "getColor. Use 'selected-content-background' instead.", diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index c41a39148b98..6d54c36e7d85 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -114,7 +114,7 @@ #endif #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) -#include "shell/browser/extensions/atom_extension_web_contents_observer.h" +#include "shell/browser/extensions/electron_extension_web_contents_observer.h" #endif namespace gin { @@ -385,7 +385,7 @@ WebContents::WebContents(v8::Isolate* isolate, AttachAsUserData(web_contents); InitZoomController(web_contents, gin::Dictionary::CreateEmpty(isolate)); #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - extensions::AtomExtensionWebContentsObserver::CreateForWebContents( + extensions::ElectronExtensionWebContentsObserver::CreateForWebContents( web_contents); script_executor_.reset(new extensions::ScriptExecutor(web_contents)); #endif @@ -546,7 +546,7 @@ void WebContents::InitWithSessionAndOptions( SecurityStateTabHelper::CreateForWebContents(web_contents()); InitZoomController(web_contents(), options); #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - extensions::AtomExtensionWebContentsObserver::CreateForWebContents( + extensions::ElectronExtensionWebContentsObserver::CreateForWebContents( web_contents()); script_executor_.reset(new extensions::ScriptExecutor(web_contents())); #endif diff --git a/shell/browser/atom_browser_client.cc b/shell/browser/atom_browser_client.cc index f9617a03cf5e..e7f1cc3a5fb8 100644 --- a/shell/browser/atom_browser_client.cc +++ b/shell/browser/atom_browser_client.cc @@ -134,7 +134,7 @@ #include "extensions/browser/info_map.h" #include "extensions/browser/process_map.h" #include "extensions/common/extension.h" -#include "shell/browser/extensions/atom_extension_system.h" +#include "shell/browser/extensions/electron_extension_system.h" #endif #if defined(OS_MACOSX) diff --git a/shell/browser/atom_browser_context.cc b/shell/browser/atom_browser_context.cc index 83feba88b400..f411bebb416c 100644 --- a/shell/browser/atom_browser_context.cc +++ b/shell/browser/atom_browser_context.cc @@ -56,11 +56,11 @@ #include "extensions/browser/extension_prefs.h" #include "extensions/browser/pref_names.h" #include "extensions/common/extension_api.h" -#include "shell/browser/extensions/atom_browser_context_keyed_service_factories.h" -#include "shell/browser/extensions/atom_extension_system.h" -#include "shell/browser/extensions/atom_extension_system_factory.h" -#include "shell/browser/extensions/atom_extensions_browser_client.h" -#include "shell/common/extensions/atom_extensions_client.h" +#include "shell/browser/extensions/electron_browser_context_keyed_service_factories.h" +#include "shell/browser/extensions/electron_extension_system.h" +#include "shell/browser/extensions/electron_extension_system_factory.h" +#include "shell/browser/extensions/electron_extensions_browser_client.h" +#include "shell/common/extensions/electron_extensions_client.h" #endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) || \ @@ -136,7 +136,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( this); - extension_system_ = static_cast( + extension_system_ = static_cast( extensions::ExtensionSystem::Get(this)); extension_system_->InitForRegularProfile(true /* extensions_enabled */); extension_system_->FinishInitialization(); diff --git a/shell/browser/atom_browser_context.h b/shell/browser/atom_browser_context.h index dc1012ce6a75..00fcc8ca3d9f 100644 --- a/shell/browser/atom_browser_context.h +++ b/shell/browser/atom_browser_context.h @@ -35,7 +35,7 @@ class SpecialStoragePolicy; #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) namespace extensions { -class AtomExtensionSystem; +class ElectronExtensionSystem; } #endif @@ -142,7 +142,7 @@ class AtomBrowserContext } #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - extensions::AtomExtensionSystem* extension_system() { + extensions::ElectronExtensionSystem* extension_system() { return extension_system_; } #endif @@ -192,7 +192,7 @@ class AtomBrowserContext #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) // Owned by the KeyedService system. - extensions::AtomExtensionSystem* extension_system_; + extensions::ElectronExtensionSystem* extension_system_; #endif // Shared URLLoaderFactory. diff --git a/shell/browser/atom_browser_main_parts.cc b/shell/browser/atom_browser_main_parts.cc index 7193bb2cbe3f..de974faaafc0 100644 --- a/shell/browser/atom_browser_main_parts.cc +++ b/shell/browser/atom_browser_main_parts.cc @@ -97,9 +97,9 @@ #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "extensions/browser/browser_context_keyed_service_factories.h" #include "extensions/common/extension_api.h" -#include "shell/browser/extensions/atom_browser_context_keyed_service_factories.h" -#include "shell/browser/extensions/atom_extensions_browser_client.h" -#include "shell/common/extensions/atom_extensions_client.h" +#include "shell/browser/extensions/electron_browser_context_keyed_service_factories.h" +#include "shell/browser/extensions/electron_extensions_browser_client.h" +#include "shell/common/extensions/electron_extensions_client.h" #endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) #if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER) @@ -437,11 +437,12 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { node_bindings_->RunMessageLoop(); #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - extensions_client_ = std::make_unique(); + extensions_client_ = std::make_unique(); extensions::ExtensionsClient::Set(extensions_client_.get()); // BrowserContextKeyedAPIServiceFactories require an ExtensionsBrowserClient. - extensions_browser_client_ = std::make_unique(); + extensions_browser_client_ = + std::make_unique(); extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); diff --git a/shell/browser/atom_browser_main_parts.h b/shell/browser/atom_browser_main_parts.h index 0e3aea7fd5c7..0a6c7254b8aa 100644 --- a/shell/browser/atom_browser_main_parts.h +++ b/shell/browser/atom_browser_main_parts.h @@ -41,8 +41,8 @@ class NodeEnvironment; class BridgeTaskRunner; #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) -class AtomExtensionsClient; -class AtomExtensionsBrowserClient; +class ElectronExtensionsClient; +class ElectronExtensionsBrowserClient; #endif #if defined(TOOLKIT_VIEWS) @@ -139,8 +139,8 @@ class AtomBrowserMainParts : public content::BrowserMainParts { std::unique_ptr field_trial_list_; #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - std::unique_ptr extensions_client_; - std::unique_ptr extensions_browser_client_; + std::unique_ptr extensions_client_; + std::unique_ptr extensions_browser_client_; #endif base::RepeatingTimer gc_timer_; diff --git a/shell/browser/extensions/api/runtime/atom_runtime_api_delegate.cc b/shell/browser/extensions/api/runtime/atom_runtime_api_delegate.cc deleted file mode 100644 index 37216dbbe04f..000000000000 --- a/shell/browser/extensions/api/runtime/atom_runtime_api_delegate.cc +++ /dev/null @@ -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 - -#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(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 diff --git a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc new file mode 100644 index 000000000000..b375ac69b1be --- /dev/null +++ b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc @@ -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 + +#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(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 diff --git a/shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h similarity index 67% rename from shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h rename to shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h index d49c468577c7..0491c0ebf3ae 100644 --- a/shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h +++ b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h @@ -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 @@ -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_ diff --git a/shell/browser/extensions/atom_display_info_provider.h b/shell/browser/extensions/atom_display_info_provider.h deleted file mode 100644 index 22458339bd79..000000000000 --- a/shell/browser/extensions/atom_display_info_provider.h +++ /dev/null @@ -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_ diff --git a/shell/browser/extensions/atom_browser_context_keyed_service_factories.cc b/shell/browser/extensions/electron_browser_context_keyed_service_factories.cc similarity index 75% rename from shell/browser/extensions/atom_browser_context_keyed_service_factories.cc rename to shell/browser/extensions/electron_browser_context_keyed_service_factories.cc index 8101a63cf5b5..eb0a91fc9150 100644 --- a/shell/browser/extensions/atom_browser_context_keyed_service_factories.cc +++ b/shell/browser/extensions/electron_browser_context_keyed_service_factories.cc @@ -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 diff --git a/shell/browser/extensions/atom_browser_context_keyed_service_factories.h b/shell/browser/extensions/electron_browser_context_keyed_service_factories.h similarity index 62% rename from shell/browser/extensions/atom_browser_context_keyed_service_factories.h rename to shell/browser/extensions/electron_browser_context_keyed_service_factories.h index 536b75c86f0b..3ac39a587aa2 100644 --- a/shell/browser/extensions/atom_browser_context_keyed_service_factories.h +++ b/shell/browser/extensions/electron_browser_context_keyed_service_factories.h @@ -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_ diff --git a/shell/browser/extensions/atom_display_info_provider.cc b/shell/browser/extensions/electron_display_info_provider.cc similarity index 61% rename from shell/browser/extensions/atom_display_info_provider.cc rename to shell/browser/extensions/electron_display_info_provider.cc index 92567b568017..4e93c281ab0c 100644 --- a/shell/browser/extensions/atom_display_info_provider.cc +++ b/shell/browser/extensions/electron_display_info_provider.cc @@ -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 diff --git a/shell/browser/extensions/electron_display_info_provider.h b/shell/browser/extensions/electron_display_info_provider.h new file mode 100644 index 000000000000..931dab17a29f --- /dev/null +++ b/shell/browser/extensions/electron_display_info_provider.h @@ -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_ diff --git a/shell/browser/extensions/atom_extension_host_delegate.cc b/shell/browser/extensions/electron_extension_host_delegate.cc similarity index 67% rename from shell/browser/extensions/atom_extension_host_delegate.cc rename to shell/browser/extensions/electron_extension_host_delegate.cc index bb03bf7b3f9b..91e27343c0fb 100644 --- a/shell/browser/extensions/atom_extension_host_delegate.cc +++ b/shell/browser/extensions/electron_extension_host_delegate.cc @@ -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 #include @@ -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 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(); } diff --git a/shell/browser/extensions/atom_extension_host_delegate.h b/shell/browser/extensions/electron_extension_host_delegate.h similarity index 80% rename from shell/browser/extensions/atom_extension_host_delegate.h rename to shell/browser/extensions/electron_extension_host_delegate.h index d7fb68160ae2..7334603c39b2 100644 --- a/shell/browser/extensions/atom_extension_host_delegate.h +++ b/shell/browser/extensions/electron_extension_host_delegate.h @@ -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 #include @@ -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_ diff --git a/shell/browser/extensions/atom_extension_loader.cc b/shell/browser/extensions/electron_extension_loader.cc similarity index 62% rename from shell/browser/extensions/atom_extension_loader.cc rename to shell/browser/extensions/electron_extension_loader.cc index a195bca50a24..b9b8294abc30 100644 --- a/shell/browser/extensions/atom_extension_loader.cc +++ b/shell/browser/extensions/electron_extension_loader.cc @@ -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 @@ -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 LoadUnpacked( +std::pair, 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 LoadUnpacked( scoped_refptr 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 loaded) { + base::OnceCallback 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 done, - scoped_refptr extension) { +void ElectronExtensionLoader::FinishExtensionLoad( + base::OnceCallback cb, + std::pair, std::string> result) { + scoped_refptr 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 extension) { + std::pair, std::string> result) { + scoped_refptr 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 extension) {} -void AtomExtensionLoader::PostDeactivateExtension( +void ElectronExtensionLoader::PostDeactivateExtension( scoped_refptr 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; } diff --git a/shell/browser/extensions/atom_extension_loader.h b/shell/browser/extensions/electron_extension_loader.h similarity index 71% rename from shell/browser/extensions/atom_extension_loader.h rename to shell/browser/extensions/electron_extension_loader.h index 2cca8e109492..0dda5a6d009e 100644 --- a/shell/browser/extensions/atom_extension_loader.h +++ b/shell/browser/extensions/electron_extension_loader.h @@ -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 #include +#include #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 loaded); + void LoadExtension(const base::FilePath& extension_dir, + base::OnceCallback 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 extension); + void FinishExtensionReload( + const ExtensionId& old_extension_id, + std::pair, std::string> result); - void FinishExtensionLoad(base::OnceCallback loaded, - scoped_refptr extension); + void FinishExtensionLoad( + base::OnceCallback cb, + std::pair, 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 weak_factory_; + base::WeakPtrFactory 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_ diff --git a/shell/browser/extensions/atom_extension_system.cc b/shell/browser/extensions/electron_extension_system.cc similarity index 65% rename from shell/browser/extensions/atom_extension_system.cc rename to shell/browser/extensions/electron_extension_system.cc index a0fb5f1ad2d0..2e54a838284f 100644 --- a/shell/browser/extensions/atom_extension_system.cc +++ b/shell/browser/extensions/electron_extension_system.cc @@ -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 #include @@ -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 loaded) { - extension_loader_->LoadExtension(extension_dir, std::move(loaded)); + base::OnceCallback 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(browser_context_); runtime_data_ = @@ -81,56 +82,57 @@ void AtomExtensionSystem::InitForRegularProfile(bool extensions_enabled) { shared_user_script_master_ = std::make_unique(browser_context_); app_sorting_ = std::make_unique(); - extension_loader_ = std::make_unique(browser_context_); + extension_loader_ = + std::make_unique(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 AtomExtensionSystem::store_factory() { +scoped_refptr 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 AtomExtensionSystem::GetDependentExtensions( +std::unique_ptr ElectronExtensionSystem::GetDependentExtensions( const Extension* extension) { return std::make_unique(); } -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) { ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_); registry->AddReady(extension); diff --git a/shell/browser/extensions/atom_extension_system.h b/shell/browser/extensions/electron_extension_system.h similarity index 82% rename from shell/browser/extensions/atom_extension_system.h rename to shell/browser/extensions/electron_extension_system.h index 59859fc2e749..728eab19d27f 100644 --- a/shell/browser/extensions/atom_extension_system.h +++ b/shell/browser/extensions/electron_extension_system.h @@ -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 #include @@ -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 loaded); + void LoadExtension( + const base::FilePath& extension_dir, + base::OnceCallback cb); // Finish initialization for the shell extension system. void FinishInitialization(); @@ -98,18 +99,18 @@ class AtomExtensionSystem : public ExtensionSystem { std::unique_ptr shared_user_script_master_; std::unique_ptr app_sorting_; - std::unique_ptr extension_loader_; + std::unique_ptr extension_loader_; scoped_refptr store_factory_; // Signaled when the extension system has completed its startup tasks. base::OneShotEvent ready_; - base::WeakPtrFactory weak_factory_; + base::WeakPtrFactory 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_ diff --git a/shell/browser/extensions/atom_extension_system_factory.cc b/shell/browser/extensions/electron_extension_system_factory.cc similarity index 51% rename from shell/browser/extensions/atom_extension_system_factory.cc rename to shell/browser/extensions/electron_extension_system_factory.cc index cdc7d1ec8d65..b284f8f21b44 100644 --- a/shell/browser/extensions/atom_extension_system_factory.cc +++ b/shell/browser/extensions/electron_extension_system_factory.cc @@ -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( + return static_cast( GetInstance()->GetServiceForBrowserContext(context, true)); } // static -AtomExtensionSystemFactory* AtomExtensionSystemFactory::GetInstance() { - return base::Singleton::get(); +ElectronExtensionSystemFactory* ElectronExtensionSystemFactory::GetInstance() { + return base::Singleton::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; } diff --git a/shell/browser/extensions/atom_extension_system_factory.h b/shell/browser/extensions/electron_extension_system_factory.h similarity index 57% rename from shell/browser/extensions/atom_extension_system_factory.h rename to shell/browser/extensions/electron_extension_system_factory.h index 6ec20f45c301..e6e761c14423 100644 --- a/shell/browser/extensions/atom_extension_system_factory.h +++ b/shell/browser/extensions/electron_extension_system_factory.h @@ -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; + friend struct base::DefaultSingletonTraits; - 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_ diff --git a/shell/browser/extensions/atom_extension_web_contents_observer.cc b/shell/browser/extensions/electron_extension_web_contents_observer.cc similarity index 51% rename from shell/browser/extensions/atom_extension_web_contents_observer.cc rename to shell/browser/extensions/electron_extension_web_contents_observer.cc index 4beb9030375e..4d7a2cebd5c7 100644 --- a/shell/browser/extensions/atom_extension_web_contents_observer.cc +++ b/shell/browser/extensions/electron_extension_web_contents_observer.cc @@ -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 diff --git a/shell/browser/extensions/atom_extension_web_contents_observer.h b/shell/browser/extensions/electron_extension_web_contents_observer.h similarity index 51% rename from shell/browser/extensions/atom_extension_web_contents_observer.h rename to shell/browser/extensions/electron_extension_web_contents_observer.h index 75c4fc72853b..577c3c3b1929 100644 --- a/shell/browser/extensions/atom_extension_web_contents_observer.h +++ b/shell/browser/extensions/electron_extension_web_contents_observer.h @@ -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 { + 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; + 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_ diff --git a/shell/browser/extensions/electron_extensions_api_client.cc b/shell/browser/extensions/electron_extensions_api_client.cc index 09e7a03126e8..0001a7b18ed7 100644 --- a/shell/browser/extensions/electron_extensions_api_client.cc +++ b/shell/browser/extensions/electron_extensions_api_client.cc @@ -6,7 +6,7 @@ #include -#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); } diff --git a/shell/browser/extensions/atom_extensions_browser_client.cc b/shell/browser/extensions/electron_extensions_browser_client.cc similarity index 67% rename from shell/browser/extensions/atom_extensions_browser_client.cc rename to shell/browser/extensions/electron_extensions_browser_client.cc index a8f2f4fa148c..8bc975cb3ae4 100644 --- a/shell/browser/extensions/atom_extensions_browser_client.cc +++ b/shell/browser/extensions/electron_extensions_browser_client.cc @@ -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 @@ -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()); } -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 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(context)->prefs(); } -void AtomExtensionsBrowserClient::GetEarlyExtensionPrefsObservers( +void ElectronExtensionsBrowserClient::GetEarlyExtensionPrefsObservers( content::BrowserContext* context, std::vector* observers) const {} extensions::ProcessManagerDelegate* -AtomExtensionsBrowserClient::GetProcessManagerDelegate() const { +ElectronExtensionsBrowserClient::GetProcessManagerDelegate() const { return process_manager_delegate_.get(); } -std::unique_ptr AtomExtensionsBrowserClient:: +std::unique_ptr +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 -AtomExtensionsBrowserClient::CreateRuntimeAPIDelegate( +ElectronExtensionsBrowserClient::CreateRuntimeAPIDelegate( content::BrowserContext* context) const { - return std::make_unique(context); + return std::make_unique(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 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* map, content::RenderFrameHost* render_frame_host, const extensions::Extension* extension) const {} diff --git a/shell/browser/extensions/atom_extensions_browser_client.h b/shell/browser/extensions/electron_extensions_browser_client.h similarity index 92% rename from shell/browser/extensions/atom_extensions_browser_client.h rename to shell/browser/extensions/electron_extensions_browser_client.h index 08c965d411a3..9cab4ffe33ea 100644 --- a/shell/browser/extensions/atom_extensions_browser_client.h +++ b/shell/browser/extensions/electron_extensions_browser_client.h @@ -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 #include @@ -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 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_ diff --git a/shell/browser/extensions/atom_navigation_ui_data.cc b/shell/browser/extensions/electron_navigation_ui_data.cc similarity index 62% rename from shell/browser/extensions/atom_navigation_ui_data.cc rename to shell/browser/extensions/electron_navigation_ui_data.cc index ab1b8afd2220..eac7e275c67b 100644 --- a/shell/browser/extensions/atom_navigation_ui_data.cc +++ b/shell/browser/extensions/electron_navigation_ui_data.cc @@ -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 @@ -11,20 +11,20 @@ namespace extensions { -AtomNavigationUIData::AtomNavigationUIData() {} +ElectronNavigationUIData::ElectronNavigationUIData() {} -AtomNavigationUIData::AtomNavigationUIData( +ElectronNavigationUIData::ElectronNavigationUIData( content::NavigationHandle* navigation_handle) { extension_data_ = std::make_unique( navigation_handle, extension_misc::kUnknownTabId, extension_misc::kUnknownWindowId); } -AtomNavigationUIData::~AtomNavigationUIData() {} +ElectronNavigationUIData::~ElectronNavigationUIData() {} -std::unique_ptr AtomNavigationUIData::Clone() { - std::unique_ptr copy = - std::make_unique(); +std::unique_ptr ElectronNavigationUIData::Clone() { + std::unique_ptr copy = + std::make_unique(); if (extension_data_) copy->SetExtensionNavigationUIData(extension_data_->DeepCopy()); @@ -32,7 +32,7 @@ std::unique_ptr AtomNavigationUIData::Clone() { return std::move(copy); } -void AtomNavigationUIData::SetExtensionNavigationUIData( +void ElectronNavigationUIData::SetExtensionNavigationUIData( std::unique_ptr extension_data) { extension_data_ = std::move(extension_data); } diff --git a/shell/browser/extensions/atom_navigation_ui_data.h b/shell/browser/extensions/electron_navigation_ui_data.h similarity index 73% rename from shell/browser/extensions/atom_navigation_ui_data.h rename to shell/browser/extensions/electron_navigation_ui_data.h index f757ee5e8d50..e3680eb4315b 100644 --- a/shell/browser/extensions/atom_navigation_ui_data.h +++ b/shell/browser/extensions/electron_navigation_ui_data.h @@ -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 @@ -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 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_ diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index a02b86139de5..54763b7f1a3d 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -29,10 +29,10 @@ #include "shell/browser/ui/inspectable_web_contents.h" #include "shell/browser/ui/inspectable_web_contents_view.h" #include "shell/browser/window_list.h" -#include "shell/common/deprecate_util.h" #include "shell/common/gin_converters/gfx_converter.h" #include "shell/common/gin_helper/dictionary.h" #include "shell/common/options_switches.h" +#include "shell/common/process_util.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/webrtc/modules/desktop_capture/mac/window_list_utils.h" #include "ui/gfx/skia_util.h" @@ -1463,16 +1463,14 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { NSVisualEffectMaterial vibrancyType; if (type == "appearance-based") { - EmitDeprecationWarning( - env, "NSVisualEffectMaterialAppearanceBased" + dep_warn, "electron"); + EmitWarning(env, "NSVisualEffectMaterialAppearanceBased" + dep_warn, + "electron"); vibrancyType = NSVisualEffectMaterialAppearanceBased; } else if (type == "light") { - EmitDeprecationWarning(env, "NSVisualEffectMaterialLight" + dep_warn, - "electron"); + EmitWarning(env, "NSVisualEffectMaterialLight" + dep_warn, "electron"); vibrancyType = NSVisualEffectMaterialLight; } else if (type == "dark") { - EmitDeprecationWarning(env, "NSVisualEffectMaterialDark" + dep_warn, - "electron"); + EmitWarning(env, "NSVisualEffectMaterialDark" + dep_warn, "electron"); vibrancyType = NSVisualEffectMaterialDark; } else if (type == "titlebar") { vibrancyType = NSVisualEffectMaterialTitlebar; @@ -1495,13 +1493,13 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { vibrancyType = static_cast(7); } else if (type == "medium-light") { // NSVisualEffectMaterialMediumLight - EmitDeprecationWarning( - env, "NSVisualEffectMaterialMediumLight" + dep_warn, "electron"); + EmitWarning(env, "NSVisualEffectMaterialMediumLight" + dep_warn, + "electron"); vibrancyType = static_cast(8); } else if (type == "ultra-dark") { // NSVisualEffectMaterialUltraDark - EmitDeprecationWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn, - "electron"); + EmitWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn, + "electron"); vibrancyType = static_cast(9); } } diff --git a/shell/common/deprecate_util.h b/shell/common/deprecate_util.h deleted file mode 100644 index 27a933495a59..000000000000 --- a/shell/common/deprecate_util.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef SHELL_COMMON_DEPRECATE_UTIL_H_ -#define SHELL_COMMON_DEPRECATE_UTIL_H_ - -#include - -#include "shell/common/node_includes.h" - -namespace electron { - -void EmitDeprecationWarning(node::Environment* env, - const std::string& warning_msg, - const std::string& warning_type); - -} // namespace electron - -#endif // SHELL_COMMON_DEPRECATE_UTIL_H_ diff --git a/shell/common/extensions/atom_extensions_api_provider.cc b/shell/common/extensions/electron_extensions_api_provider.cc similarity index 82% rename from shell/common/extensions/atom_extensions_api_provider.cc rename to shell/common/extensions/electron_extensions_api_provider.cc index 042b5bf04b41..276bb1de419e 100644 --- a/shell/common/extensions/atom_extensions_api_provider.cc +++ b/shell/common/extensions/electron_extensions_api_provider.cc @@ -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/common/extensions/atom_extensions_api_provider.h" +#include "shell/common/extensions/electron_extensions_api_provider.h" #include #include @@ -74,50 +74,51 @@ base::span GetPermissionAliases() { namespace electron { -AtomExtensionsAPIProvider::AtomExtensionsAPIProvider() = default; -AtomExtensionsAPIProvider::~AtomExtensionsAPIProvider() = default; +ElectronExtensionsAPIProvider::ElectronExtensionsAPIProvider() = default; +ElectronExtensionsAPIProvider::~ElectronExtensionsAPIProvider() = default; -void AtomExtensionsAPIProvider::AddAPIFeatures( +void ElectronExtensionsAPIProvider::AddAPIFeatures( extensions::FeatureProvider* provider) { extensions::AddElectronAPIFeatures(provider); } -void AtomExtensionsAPIProvider::AddManifestFeatures( +void ElectronExtensionsAPIProvider::AddManifestFeatures( extensions::FeatureProvider* provider) { extensions::AddElectronManifestFeatures(provider); } -void AtomExtensionsAPIProvider::AddPermissionFeatures( +void ElectronExtensionsAPIProvider::AddPermissionFeatures( extensions::FeatureProvider* provider) { // No shell-specific permission features. } -void AtomExtensionsAPIProvider::AddBehaviorFeatures( +void ElectronExtensionsAPIProvider::AddBehaviorFeatures( extensions::FeatureProvider* provider) { // No shell-specific behavior features. } -void AtomExtensionsAPIProvider::AddAPIJSONSources( +void ElectronExtensionsAPIProvider::AddAPIJSONSources( extensions::JSONFeatureProviderSource* json_source) { // json_source->LoadJSON(IDR_SHELL_EXTENSION_API_FEATURES); } -bool AtomExtensionsAPIProvider::IsAPISchemaGenerated(const std::string& name) { +bool ElectronExtensionsAPIProvider::IsAPISchemaGenerated( + const std::string& name) { return extensions::api::ElectronGeneratedSchemas::IsGenerated(name); } -base::StringPiece AtomExtensionsAPIProvider::GetAPISchema( +base::StringPiece ElectronExtensionsAPIProvider::GetAPISchema( const std::string& name) { return extensions::api::ElectronGeneratedSchemas::Get(name); } -void AtomExtensionsAPIProvider::RegisterPermissions( +void ElectronExtensionsAPIProvider::RegisterPermissions( extensions::PermissionsInfo* permissions_info) { permissions_info->RegisterPermissions(extensions::GetPermissionInfos(), extensions::GetPermissionAliases()); } -void AtomExtensionsAPIProvider::RegisterManifestHandlers() { +void ElectronExtensionsAPIProvider::RegisterManifestHandlers() { extensions::ManifestHandlerRegistry* registry = extensions::ManifestHandlerRegistry::Get(); registry->RegisterHandler( diff --git a/shell/common/extensions/atom_extensions_api_provider.h b/shell/common/extensions/electron_extensions_api_provider.h similarity index 70% rename from shell/common/extensions/atom_extensions_api_provider.h rename to shell/common/extensions/electron_extensions_api_provider.h index 80a6303c6108..5fe9aebd129b 100644 --- a/shell/common/extensions/atom_extensions_api_provider.h +++ b/shell/common/extensions/electron_extensions_api_provider.h @@ -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_COMMON_EXTENSIONS_ATOM_EXTENSIONS_API_PROVIDER_H_ -#define SHELL_COMMON_EXTENSIONS_ATOM_EXTENSIONS_API_PROVIDER_H_ +#ifndef SHELL_COMMON_EXTENSIONS_ELECTRON_EXTENSIONS_API_PROVIDER_H_ +#define SHELL_COMMON_EXTENSIONS_ELECTRON_EXTENSIONS_API_PROVIDER_H_ #include @@ -12,10 +12,10 @@ namespace electron { -class AtomExtensionsAPIProvider : public extensions::ExtensionsAPIProvider { +class ElectronExtensionsAPIProvider : public extensions::ExtensionsAPIProvider { public: - AtomExtensionsAPIProvider(); - ~AtomExtensionsAPIProvider() override; + ElectronExtensionsAPIProvider(); + ~ElectronExtensionsAPIProvider() override; // ExtensionsAPIProvider: void AddAPIFeatures(extensions::FeatureProvider* provider) override; @@ -31,9 +31,9 @@ class AtomExtensionsAPIProvider : public extensions::ExtensionsAPIProvider { void RegisterManifestHandlers() override; private: - DISALLOW_COPY_AND_ASSIGN(AtomExtensionsAPIProvider); + DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsAPIProvider); }; } // namespace electron -#endif // SHELL_COMMON_EXTENSIONS_ATOM_EXTENSIONS_API_PROVIDER_H_ +#endif // SHELL_COMMON_EXTENSIONS_ELECTRON_EXTENSIONS_API_PROVIDER_H_ diff --git a/shell/common/extensions/atom_extensions_client.cc b/shell/common/extensions/electron_extensions_client.cc similarity index 70% rename from shell/common/extensions/atom_extensions_client.cc rename to shell/common/extensions/electron_extensions_client.cc index d1d2d0dfc5c9..fc300ad20d0d 100644 --- a/shell/common/extensions/atom_extensions_client.cc +++ b/shell/common/extensions/electron_extensions_client.cc @@ -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/common/extensions/atom_extensions_client.h" +#include "shell/common/extensions/electron_extensions_client.h" #include #include @@ -17,7 +17,7 @@ #include "extensions/common/features/simple_feature.h" #include "extensions/common/permissions/permission_message_provider.h" #include "extensions/common/url_pattern_set.h" -#include "shell/common/extensions/atom_extensions_api_provider.h" +#include "shell/common/extensions/electron_extensions_api_provider.h" using extensions::ExtensionsClient; @@ -27,11 +27,11 @@ namespace { // TODO(jamescook): Refactor ChromePermissionsMessageProvider so we can share // code. For now, this implementation does nothing. -class AtomPermissionMessageProvider +class ElectronPermissionMessageProvider : public extensions::PermissionMessageProvider { public: - AtomPermissionMessageProvider() {} - ~AtomPermissionMessageProvider() override {} + ElectronPermissionMessageProvider() {} + ~ElectronPermissionMessageProvider() override {} // PermissionMessageProvider implementation. extensions::PermissionMessages GetPermissionMessages( @@ -60,81 +60,82 @@ class AtomPermissionMessageProvider } private: - DISALLOW_COPY_AND_ASSIGN(AtomPermissionMessageProvider); + DISALLOW_COPY_AND_ASSIGN(ElectronPermissionMessageProvider); }; -base::LazyInstance::DestructorAtExit +base::LazyInstance::DestructorAtExit g_permission_message_provider = LAZY_INSTANCE_INITIALIZER; } // namespace -AtomExtensionsClient::AtomExtensionsClient() +ElectronExtensionsClient::ElectronExtensionsClient() : webstore_base_url_(extension_urls::kChromeWebstoreBaseURL), webstore_update_url_(extension_urls::kChromeWebstoreUpdateURL) { AddAPIProvider(std::make_unique()); - AddAPIProvider(std::make_unique()); + AddAPIProvider(std::make_unique()); } -AtomExtensionsClient::~AtomExtensionsClient() {} +ElectronExtensionsClient::~ElectronExtensionsClient() {} -void AtomExtensionsClient::Initialize() { +void ElectronExtensionsClient::Initialize() { // TODO(jamescook): Do we need to whitelist any extensions? } -void AtomExtensionsClient::InitializeWebStoreUrls( +void ElectronExtensionsClient::InitializeWebStoreUrls( base::CommandLine* command_line) {} const extensions::PermissionMessageProvider& -AtomExtensionsClient::GetPermissionMessageProvider() const { +ElectronExtensionsClient::GetPermissionMessageProvider() const { NOTIMPLEMENTED(); return g_permission_message_provider.Get(); } -const std::string AtomExtensionsClient::GetProductName() { +const std::string ElectronExtensionsClient::GetProductName() { // TODO(samuelmaddock): return "app_shell"; } -void AtomExtensionsClient::FilterHostPermissions( +void ElectronExtensionsClient::FilterHostPermissions( const extensions::URLPatternSet& hosts, extensions::URLPatternSet* new_hosts, extensions::PermissionIDSet* permissions) const { NOTIMPLEMENTED(); } -void AtomExtensionsClient::SetScriptingWhitelist( +void ElectronExtensionsClient::SetScriptingWhitelist( const ExtensionsClient::ScriptingWhitelist& whitelist) { scripting_whitelist_ = whitelist; } const ExtensionsClient::ScriptingWhitelist& -AtomExtensionsClient::GetScriptingWhitelist() const { +ElectronExtensionsClient::GetScriptingWhitelist() const { // TODO(jamescook): Real whitelist. return scripting_whitelist_; } -extensions::URLPatternSet AtomExtensionsClient::GetPermittedChromeSchemeHosts( +extensions::URLPatternSet +ElectronExtensionsClient::GetPermittedChromeSchemeHosts( const extensions::Extension* extension, const extensions::APIPermissionSet& api_permissions) const { NOTIMPLEMENTED(); return extensions::URLPatternSet(); } -bool AtomExtensionsClient::IsScriptableURL(const GURL& url, - std::string* error) const { +bool ElectronExtensionsClient::IsScriptableURL(const GURL& url, + std::string* error) const { // No restrictions on URLs. return true; } -const GURL& AtomExtensionsClient::GetWebstoreBaseURL() const { +const GURL& ElectronExtensionsClient::GetWebstoreBaseURL() const { return webstore_base_url_; } -const GURL& AtomExtensionsClient::GetWebstoreUpdateURL() const { +const GURL& ElectronExtensionsClient::GetWebstoreUpdateURL() const { return webstore_update_url_; } -bool AtomExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { +bool ElectronExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { // TODO(rockot): Maybe we want to do something else here. For now we accept // any URL as a blacklist URL because we don't really care. return true; diff --git a/shell/common/extensions/atom_extensions_client.h b/shell/common/extensions/electron_extensions_client.h similarity index 82% rename from shell/common/extensions/atom_extensions_client.h rename to shell/common/extensions/electron_extensions_client.h index 6601b323faf7..7ed155e55bbe 100644 --- a/shell/common/extensions/atom_extensions_client.h +++ b/shell/common/extensions/electron_extensions_client.h @@ -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_COMMON_EXTENSIONS_ATOM_EXTENSIONS_CLIENT_H_ -#define SHELL_COMMON_EXTENSIONS_ATOM_EXTENSIONS_CLIENT_H_ +#ifndef SHELL_COMMON_EXTENSIONS_ELECTRON_EXTENSIONS_CLIENT_H_ +#define SHELL_COMMON_EXTENSIONS_ELECTRON_EXTENSIONS_CLIENT_H_ #include @@ -24,12 +24,12 @@ class URLPatternSet; namespace electron { // The app_shell implementation of ExtensionsClient. -class AtomExtensionsClient : public extensions::ExtensionsClient { +class ElectronExtensionsClient : public extensions::ExtensionsClient { public: typedef extensions::ExtensionsClient::ScriptingWhitelist ScriptingWhitelist; - AtomExtensionsClient(); - ~AtomExtensionsClient() override; + ElectronExtensionsClient(); + ~ElectronExtensionsClient() override; // ExtensionsClient overrides: void Initialize() override; @@ -57,9 +57,9 @@ class AtomExtensionsClient : public extensions::ExtensionsClient { const GURL webstore_base_url_; const GURL webstore_update_url_; - DISALLOW_COPY_AND_ASSIGN(AtomExtensionsClient); + DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsClient); }; } // namespace electron -#endif // SHELL_COMMON_EXTENSIONS_ATOM_EXTENSIONS_CLIENT_H_ +#endif // SHELL_COMMON_EXTENSIONS_ELECTRON_EXTENSIONS_CLIENT_H_ diff --git a/shell/common/gin_converters/blink_converter.cc b/shell/common/gin_converters/blink_converter.cc index 79d38c87160e..299a2c80c82c 100644 --- a/shell/common/gin_converters/blink_converter.cc +++ b/shell/common/gin_converters/blink_converter.cc @@ -12,7 +12,6 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "gin/converter.h" -#include "shell/common/deprecate_util.h" #include "shell/common/gin_converters/gfx_converter.h" #include "shell/common/gin_converters/value_converter.h" #include "shell/common/gin_helper/dictionary.h" diff --git a/shell/common/deprecate_util.cc b/shell/common/process_util.cc similarity index 72% rename from shell/common/deprecate_util.cc rename to shell/common/process_util.cc index 6d20cf39057b..0db8b33927a5 100644 --- a/shell/common/deprecate_util.cc +++ b/shell/common/process_util.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include "shell/common/deprecate_util.h" +#include "shell/common/process_util.h" #include "gin/dictionary.h" #include "shell/common/gin_converters/callback_converter.h" namespace electron { -void EmitDeprecationWarning(node::Environment* env, - const std::string& warning_msg, - const std::string& warning_type) { +void EmitWarning(node::Environment* env, + const std::string& warning_msg, + const std::string& warning_type) { gin::Dictionary process(env->isolate(), env->process_object()); base::RepeatingCallback + +#include "shell/common/node_includes.h" + +namespace electron { + +void EmitWarning(node::Environment* env, + const std::string& warning_msg, + const std::string& warning_type); + +} // namespace electron + +#endif // SHELL_COMMON_PROCESS_UTIL_H_ diff --git a/shell/renderer/extensions/atom_extensions_renderer_client.cc b/shell/renderer/extensions/electron_extensions_renderer_client.cc similarity index 60% rename from shell/renderer/extensions/atom_extensions_renderer_client.cc rename to shell/renderer/extensions/electron_extensions_renderer_client.cc index 0fc87bdce487..85ec1cff3fa8 100644 --- a/shell/renderer/extensions/atom_extensions_renderer_client.cc +++ b/shell/renderer/extensions/electron_extensions_renderer_client.cc @@ -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/renderer/extensions/atom_extensions_renderer_client.h" +#include "shell/renderer/extensions/electron_extensions_renderer_client.h" #include "content/public/renderer/render_thread.h" #include "extensions/renderer/dispatcher.h" @@ -10,20 +10,20 @@ namespace electron { -AtomExtensionsRendererClient::AtomExtensionsRendererClient() +ElectronExtensionsRendererClient::ElectronExtensionsRendererClient() : dispatcher_(std::make_unique( std::make_unique())) { dispatcher_->OnRenderThreadStarted(content::RenderThread::Get()); } -AtomExtensionsRendererClient::~AtomExtensionsRendererClient() {} +ElectronExtensionsRendererClient::~ElectronExtensionsRendererClient() {} -bool AtomExtensionsRendererClient::IsIncognitoProcess() const { +bool ElectronExtensionsRendererClient::IsIncognitoProcess() const { // app_shell doesn't support off-the-record contexts. return false; } -int AtomExtensionsRendererClient::GetLowestIsolatedWorldId() const { +int ElectronExtensionsRendererClient::GetLowestIsolatedWorldId() const { // app_shell doesn't need to reserve world IDs for anything other than // extensions, so we always return 1. Note that 0 is reserved for the global // world. @@ -31,33 +31,33 @@ int AtomExtensionsRendererClient::GetLowestIsolatedWorldId() const { return 10; } -extensions::Dispatcher* AtomExtensionsRendererClient::GetDispatcher() { +extensions::Dispatcher* ElectronExtensionsRendererClient::GetDispatcher() { return dispatcher_.get(); } -bool AtomExtensionsRendererClient::ExtensionAPIEnabledForServiceWorkerScript( - const GURL& scope, - const GURL& script_url) const { +bool ElectronExtensionsRendererClient:: + ExtensionAPIEnabledForServiceWorkerScript(const GURL& scope, + const GURL& script_url) const { // TODO(nornagon): adapt logic from chrome's version return true; } -bool AtomExtensionsRendererClient::AllowPopup() { +bool ElectronExtensionsRendererClient::AllowPopup() { // TODO(samuelmaddock): return false; } -void AtomExtensionsRendererClient::RunScriptsAtDocumentStart( +void ElectronExtensionsRendererClient::RunScriptsAtDocumentStart( content::RenderFrame* render_frame) { dispatcher_->RunScriptsAtDocumentStart(render_frame); } -void AtomExtensionsRendererClient::RunScriptsAtDocumentEnd( +void ElectronExtensionsRendererClient::RunScriptsAtDocumentEnd( content::RenderFrame* render_frame) { dispatcher_->RunScriptsAtDocumentEnd(render_frame); } -void AtomExtensionsRendererClient::RunScriptsAtDocumentIdle( +void ElectronExtensionsRendererClient::RunScriptsAtDocumentIdle( content::RenderFrame* render_frame) { dispatcher_->RunScriptsAtDocumentIdle(render_frame); } diff --git a/shell/renderer/extensions/atom_extensions_renderer_client.h b/shell/renderer/extensions/electron_extensions_renderer_client.h similarity index 71% rename from shell/renderer/extensions/atom_extensions_renderer_client.h rename to shell/renderer/extensions/electron_extensions_renderer_client.h index e38db538fba9..a24c5154b301 100644 --- a/shell/renderer/extensions/atom_extensions_renderer_client.h +++ b/shell/renderer/extensions/electron_extensions_renderer_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef SHELL_RENDERER_EXTENSIONS_ATOM_EXTENSIONS_RENDERER_CLIENT_H_ -#define SHELL_RENDERER_EXTENSIONS_ATOM_EXTENSIONS_RENDERER_CLIENT_H_ +#ifndef SHELL_RENDERER_EXTENSIONS_ELECTRON_EXTENSIONS_RENDERER_CLIENT_H_ +#define SHELL_RENDERER_EXTENSIONS_ELECTRON_EXTENSIONS_RENDERER_CLIENT_H_ #include @@ -20,11 +20,11 @@ class Dispatcher; namespace electron { -class AtomExtensionsRendererClient +class ElectronExtensionsRendererClient : public extensions::ExtensionsRendererClient { public: - AtomExtensionsRendererClient(); - ~AtomExtensionsRendererClient() override; + ElectronExtensionsRendererClient(); + ~ElectronExtensionsRendererClient() override; // ExtensionsRendererClient implementation. bool IsIncognitoProcess() const override; @@ -43,9 +43,9 @@ class AtomExtensionsRendererClient private: std::unique_ptr dispatcher_; - DISALLOW_COPY_AND_ASSIGN(AtomExtensionsRendererClient); + DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsRendererClient); }; } // namespace electron -#endif // SHELL_RENDERER_EXTENSIONS_ATOM_EXTENSIONS_RENDERER_CLIENT_H_ +#endif // SHELL_RENDERER_EXTENSIONS_ELECTRON_EXTENSIONS_RENDERER_CLIENT_H_ diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index 2bd4ca4cefc1..907f8d0067ad 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -73,8 +73,8 @@ #include "extensions/renderer/guest_view/extensions_guest_view_container.h" #include "extensions/renderer/guest_view/extensions_guest_view_container_dispatcher.h" #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h" -#include "shell/common/extensions/atom_extensions_client.h" -#include "shell/renderer/extensions/atom_extensions_renderer_client.h" +#include "shell/common/extensions/electron_extensions_client.h" +#include "shell/renderer/extensions/electron_extensions_renderer_client.h" #endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) namespace electron { @@ -149,7 +149,7 @@ void RendererClientBase::RenderThreadStarted() { extensions_client_.reset(CreateExtensionsClient()); extensions::ExtensionsClient::Set(extensions_client_.get()); - extensions_renderer_client_.reset(new AtomExtensionsRendererClient); + extensions_renderer_client_.reset(new ElectronExtensionsRendererClient); extensions::ExtensionsRendererClient::Set(extensions_renderer_client_.get()); thread->AddObserver(extensions_renderer_client_->GetDispatcher()); @@ -386,7 +386,7 @@ v8::Local RendererClientBase::RunScript( #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) extensions::ExtensionsClient* RendererClientBase::CreateExtensionsClient() { - return new AtomExtensionsClient; + return new ElectronExtensionsClient; } #endif diff --git a/shell/renderer/renderer_client_base.h b/shell/renderer/renderer_client_base.h index ef5c3103936b..70c673d0bffe 100644 --- a/shell/renderer/renderer_client_base.h +++ b/shell/renderer/renderer_client_base.h @@ -35,7 +35,7 @@ class ExtensionsClient; namespace electron { #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) -class AtomExtensionsRendererClient; +class ElectronExtensionsRendererClient; #endif class RendererClientBase : public content::ContentRendererClient @@ -115,7 +115,7 @@ class RendererClientBase : public content::ContentRendererClient private: #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) std::unique_ptr extensions_client_; - std::unique_ptr extensions_renderer_client_; + std::unique_ptr extensions_renderer_client_; #endif #if defined(WIDEVINE_CDM_AVAILABLE) diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index 3b2b5407c354..1ef86442779f 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -3578,201 +3578,6 @@ describe('BrowserWindow module', () => { }) }) - describe('extensions and dev tools extensions', () => { - let showPanelTimeoutId: NodeJS.Timeout | null = null - - const showLastDevToolsPanel = (w: BrowserWindow) => { - w.webContents.once('devtools-opened', () => { - const show = () => { - if (w == null || w.isDestroyed()) return - const { devToolsWebContents } = w as unknown as { devToolsWebContents: WebContents | undefined } - if (devToolsWebContents == null || devToolsWebContents.isDestroyed()) { - return - } - - const showLastPanel = () => { - // this is executed in the devtools context, where UI is a global - const { UI } = (window as any) - const lastPanelId = UI.inspectorView._tabbedPane._tabs.peekLast().id - UI.inspectorView.showPanel(lastPanelId) - } - devToolsWebContents.executeJavaScript(`(${showLastPanel})()`, false).then(() => { - showPanelTimeoutId = setTimeout(show, 100) - }) - } - showPanelTimeoutId = setTimeout(show, 100) - }) - } - - afterEach(() => { - if (showPanelTimeoutId != null) { - clearTimeout(showPanelTimeoutId) - showPanelTimeoutId = null - } - }) - - describe('BrowserWindow.addDevToolsExtension', () => { - describe('for invalid extensions', () => { - it('throws errors for missing manifest.json files', () => { - const nonexistentExtensionPath = path.join(__dirname, 'does-not-exist') - expect(() => { - BrowserWindow.addDevToolsExtension(nonexistentExtensionPath) - }).to.throw(/ENOENT: no such file or directory/) - }) - - it('throws errors for invalid manifest.json files', () => { - const badManifestExtensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest') - expect(() => { - BrowserWindow.addDevToolsExtension(badManifestExtensionPath) - }).to.throw(/Unexpected token }/) - }) - }) - - describe('for a valid extension', () => { - const extensionName = 'foo' - - before(() => { - const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo') - BrowserWindow.addDevToolsExtension(extensionPath) - expect(BrowserWindow.getDevToolsExtensions()).to.have.property(extensionName) - }) - - after(() => { - BrowserWindow.removeDevToolsExtension('foo') - expect(BrowserWindow.getDevToolsExtensions()).to.not.have.property(extensionName) - }) - - describe('when the devtools is docked', () => { - let message: any - let w: BrowserWindow - before(async () => { - w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }) - const p = new Promise(resolve => ipcMain.once('answer', (event, message) => { - resolve(message) - })) - showLastDevToolsPanel(w) - w.loadURL('about:blank') - w.webContents.openDevTools({ mode: 'bottom' }) - message = await p - }) - after(closeAllWindows) - - describe('created extension info', function () { - it('has proper "runtimeId"', async function () { - expect(message).to.have.ownProperty('runtimeId') - expect(message.runtimeId).to.equal(extensionName) - }) - it('has "tabId" matching webContents id', function () { - expect(message).to.have.ownProperty('tabId') - expect(message.tabId).to.equal(w.webContents.id) - }) - it('has "i18nString" with proper contents', function () { - expect(message).to.have.ownProperty('i18nString') - expect(message.i18nString).to.equal('foo - bar (baz)') - }) - it('has "storageItems" with proper contents', function () { - expect(message).to.have.ownProperty('storageItems') - expect(message.storageItems).to.deep.equal({ - local: { - set: { hello: 'world', world: 'hello' }, - remove: { world: 'hello' }, - clear: {} - }, - sync: { - set: { foo: 'bar', bar: 'foo' }, - remove: { foo: 'bar' }, - clear: {} - } - }) - }) - }) - }) - - describe('when the devtools is undocked', () => { - let message: any - let w: BrowserWindow - before(async () => { - w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }) - showLastDevToolsPanel(w) - w.loadURL('about:blank') - w.webContents.openDevTools({ mode: 'undocked' }) - message = await new Promise(resolve => ipcMain.once('answer', (event, message) => { - resolve(message) - })) - }) - after(closeAllWindows) - - describe('created extension info', function () { - it('has proper "runtimeId"', function () { - expect(message).to.have.ownProperty('runtimeId') - expect(message.runtimeId).to.equal(extensionName) - }) - it('has "tabId" matching webContents id', function () { - expect(message).to.have.ownProperty('tabId') - expect(message.tabId).to.equal(w.webContents.id) - }) - }) - }) - }) - }) - - it('works when used with partitions', async () => { - const w = new BrowserWindow({ - show: false, - webPreferences: { - nodeIntegration: true, - partition: 'temp' - } - }) - - const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo') - BrowserWindow.addDevToolsExtension(extensionPath) - try { - showLastDevToolsPanel(w) - - const p: Promise = new Promise(resolve => ipcMain.once('answer', function (event, message) { - resolve(message) - })) - - w.loadURL('about:blank') - w.webContents.openDevTools({ mode: 'bottom' }) - const message = await p - expect(message.runtimeId).to.equal('foo') - } finally { - BrowserWindow.removeDevToolsExtension('foo') - await closeAllWindows() - } - }) - - it('serializes the registered extensions on quit', () => { - const extensionName = 'foo' - const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName) - const serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions') - - BrowserWindow.addDevToolsExtension(extensionPath) - app.emit('will-quit') - expect(JSON.parse(fs.readFileSync(serializedPath, 'utf8'))).to.deep.equal([extensionPath]) - - BrowserWindow.removeDevToolsExtension(extensionName) - app.emit('will-quit') - expect(fs.existsSync(serializedPath)).to.be.false('file exists') - }) - - describe('BrowserWindow.addExtension', () => { - it('throws errors for missing manifest.json files', () => { - expect(() => { - BrowserWindow.addExtension(path.join(__dirname, 'does-not-exist')) - }).to.throw('ENOENT: no such file or directory') - }) - - it('throws errors for invalid manifest.json files', () => { - expect(() => { - BrowserWindow.addExtension(path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest')) - }).to.throw('Unexpected token }') - }) - }) - }) - ifdescribe(process.platform === 'darwin')('previewFile', () => { afterEach(closeAllWindows) it('opens the path in Quick Look on macOS', () => { diff --git a/spec-main/content-script-spec.ts b/spec-main/content-script-spec.ts deleted file mode 100644 index 8e4c2051f97b..000000000000 --- a/spec-main/content-script-spec.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { expect } from 'chai' -import * as path from 'path' - -import { closeWindow } from './window-helpers' -import { emittedNTimes } from './events-helpers' - -import { BrowserWindow, ipcMain, WebContents } from 'electron' - -describe('chrome extension content scripts', () => { - const fixtures = path.resolve(__dirname, 'fixtures') - const extensionPath = path.resolve(fixtures, 'extensions') - - const addExtension = (name: string) => BrowserWindow.addExtension(path.resolve(extensionPath, name)) - const removeAllExtensions = () => { - Object.keys(BrowserWindow.getExtensions()).map(extName => { - BrowserWindow.removeExtension(extName) - }) - } - - let responseIdCounter = 0 - const executeJavaScriptInFrame = (webContents: WebContents, frameRoutingId: number, code: string) => { - return new Promise(resolve => { - const responseId = responseIdCounter++ - ipcMain.once(`executeJavaScriptInFrame_${responseId}`, (event, result) => { - resolve(result) - }) - webContents.send('executeJavaScriptInFrame', frameRoutingId, code, responseId) - }) - } - - const generateTests = (sandboxEnabled: boolean, contextIsolationEnabled: boolean) => { - describe(`with sandbox ${sandboxEnabled ? 'enabled' : 'disabled'} and context isolation ${contextIsolationEnabled ? 'enabled' : 'disabled'}`, () => { - let w: BrowserWindow - - describe('supports "run_at" option', () => { - beforeEach(async () => { - await closeWindow(w) - w = new BrowserWindow({ - show: false, - width: 400, - height: 400, - webPreferences: { - contextIsolation: contextIsolationEnabled, - sandbox: sandboxEnabled - } - }) - }) - - afterEach(() => { - removeAllExtensions() - return closeWindow(w).then(() => { w = null as unknown as BrowserWindow }) - }) - - it('should run content script at document_start', () => { - addExtension('content-script-document-start') - w.webContents.once('dom-ready', async () => { - const result = await w.webContents.executeJavaScript('document.documentElement.style.backgroundColor') - expect(result).to.equal('red') - }) - w.loadURL('about:blank') - }) - - it('should run content script at document_idle', async () => { - addExtension('content-script-document-idle') - w.loadURL('about:blank') - const result = await w.webContents.executeJavaScript('document.body.style.backgroundColor') - expect(result).to.equal('red') - }) - - it('should run content script at document_end', () => { - addExtension('content-script-document-end') - w.webContents.once('did-finish-load', async () => { - const result = await w.webContents.executeJavaScript('document.documentElement.style.backgroundColor') - expect(result).to.equal('red') - }) - w.loadURL('about:blank') - }) - }) - - describe('supports "all_frames" option', () => { - const contentScript = path.resolve(fixtures, 'extensions/content-script') - - // Computed style values - const COLOR_RED = `rgb(255, 0, 0)` - const COLOR_BLUE = `rgb(0, 0, 255)` - const COLOR_TRANSPARENT = `rgba(0, 0, 0, 0)` - - before(() => { - BrowserWindow.addExtension(contentScript) - }) - - after(() => { - BrowserWindow.removeExtension('content-script-test') - }) - - beforeEach(() => { - w = new BrowserWindow({ - show: false, - webPreferences: { - // enable content script injection in subframes - nodeIntegrationInSubFrames: true, - preload: path.join(contentScript, 'all_frames-preload.js') - } - }) - }) - - afterEach(() => - closeWindow(w).then(() => { - w = null as unknown as BrowserWindow - }) - ) - - it('applies matching rules in subframes', async () => { - const detailsPromise = emittedNTimes(w.webContents, 'did-frame-finish-load', 2) - w.loadFile(path.join(contentScript, 'frame-with-frame.html')) - const frameEvents = await detailsPromise - await Promise.all( - frameEvents.map(async frameEvent => { - const [, isMainFrame, , frameRoutingId] = frameEvent - const result: any = await executeJavaScriptInFrame( - w.webContents, - frameRoutingId, - `(() => { - const a = document.getElementById('all_frames_enabled') - const b = document.getElementById('all_frames_disabled') - return { - enabledColor: getComputedStyle(a).backgroundColor, - disabledColor: getComputedStyle(b).backgroundColor - } - })()` - ) - expect(result.enabledColor).to.equal(COLOR_RED) - if (isMainFrame) { - expect(result.disabledColor).to.equal(COLOR_BLUE) - } else { - expect(result.disabledColor).to.equal(COLOR_TRANSPARENT) // null color - } - }) - ) - }) - }) - }) - } - - generateTests(false, false) - generateTests(false, true) - generateTests(true, false) - generateTests(true, true) -}) diff --git a/spec-main/extensions-spec.ts b/spec-main/extensions-spec.ts index 638df0c26e6f..0ebf9ffa8ed4 100644 --- a/spec-main/extensions-spec.ts +++ b/spec-main/extensions-spec.ts @@ -1,12 +1,12 @@ import { expect } from 'chai' -import { session, BrowserWindow, ipcMain, WebContents } from 'electron' +import { app, session, BrowserWindow, ipcMain, WebContents } from 'electron' import { closeAllWindows, closeWindow } from './window-helpers' import * as http from 'http' import { AddressInfo } from 'net' import * as path from 'path' import * as fs from 'fs' import { ifdescribe } from './spec-helpers' -import { emittedOnce } from './events-helpers' +import { emittedOnce, emittedNTimes } from './events-helpers' const fixtures = path.join(__dirname, 'fixtures') @@ -243,6 +243,150 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex expect(bg).to.equal('') }) }) + + describe('chrome extension content scripts', () => { + const fixtures = path.resolve(__dirname, 'fixtures') + const extensionPath = path.resolve(fixtures, 'extensions') + + const addExtension = (name: string) => session.defaultSession.loadExtension(path.resolve(extensionPath, name)) + const removeAllExtensions = () => { + Object.keys(session.defaultSession.getAllExtensions()).map(extName => { + session.defaultSession.removeExtension(extName) + }) + } + + let responseIdCounter = 0 + const executeJavaScriptInFrame = (webContents: WebContents, frameRoutingId: number, code: string) => { + return new Promise(resolve => { + const responseId = responseIdCounter++ + ipcMain.once(`executeJavaScriptInFrame_${responseId}`, (event, result) => { + resolve(result) + }) + webContents.send('executeJavaScriptInFrame', frameRoutingId, code, responseId) + }) + } + + const generateTests = (sandboxEnabled: boolean, contextIsolationEnabled: boolean) => { + describe(`with sandbox ${sandboxEnabled ? 'enabled' : 'disabled'} and context isolation ${contextIsolationEnabled ? 'enabled' : 'disabled'}`, () => { + let w: BrowserWindow + + describe('supports "run_at" option', () => { + beforeEach(async () => { + await closeWindow(w) + w = new BrowserWindow({ + show: false, + width: 400, + height: 400, + webPreferences: { + contextIsolation: contextIsolationEnabled, + sandbox: sandboxEnabled + } + }) + }) + + afterEach(() => { + removeAllExtensions() + return closeWindow(w).then(() => { w = null as unknown as BrowserWindow }) + }) + + it('should run content script at document_start', async () => { + await addExtension('content-script-document-start') + w.webContents.once('dom-ready', async () => { + const result = await w.webContents.executeJavaScript('document.documentElement.style.backgroundColor') + expect(result).to.equal('red') + }) + w.loadURL(url) + }) + + it('should run content script at document_idle', async () => { + await addExtension('content-script-document-idle') + w.loadURL(url) + const result = await w.webContents.executeJavaScript('document.body.style.backgroundColor') + expect(result).to.equal('red') + }) + + it('should run content script at document_end', async () => { + await addExtension('content-script-document-end') + w.webContents.once('did-finish-load', async () => { + const result = await w.webContents.executeJavaScript('document.documentElement.style.backgroundColor') + expect(result).to.equal('red') + }) + w.loadURL(url) + }) + }) + + // TODO(nornagon): real extensions don't load on file: urls, so this + // test needs to be updated to serve its content over http. + describe.skip('supports "all_frames" option', () => { + const contentScript = path.resolve(fixtures, 'extensions/content-script') + + // Computed style values + const COLOR_RED = `rgb(255, 0, 0)` + const COLOR_BLUE = `rgb(0, 0, 255)` + const COLOR_TRANSPARENT = `rgba(0, 0, 0, 0)` + + before(() => { + BrowserWindow.addExtension(contentScript) + }) + + after(() => { + BrowserWindow.removeExtension('content-script-test') + }) + + beforeEach(() => { + w = new BrowserWindow({ + show: false, + webPreferences: { + // enable content script injection in subframes + nodeIntegrationInSubFrames: true, + preload: path.join(contentScript, 'all_frames-preload.js') + } + }) + }) + + afterEach(() => + closeWindow(w).then(() => { + w = null as unknown as BrowserWindow + }) + ) + + it('applies matching rules in subframes', async () => { + const detailsPromise = emittedNTimes(w.webContents, 'did-frame-finish-load', 2) + w.loadFile(path.join(contentScript, 'frame-with-frame.html')) + const frameEvents = await detailsPromise + await Promise.all( + frameEvents.map(async frameEvent => { + const [, isMainFrame, , frameRoutingId] = frameEvent + const result: any = await executeJavaScriptInFrame( + w.webContents, + frameRoutingId, + `(() => { + const a = document.getElementById('all_frames_enabled') + const b = document.getElementById('all_frames_disabled') + return { + enabledColor: getComputedStyle(a).backgroundColor, + disabledColor: getComputedStyle(b).backgroundColor + } + })()` + ) + expect(result.enabledColor).to.equal(COLOR_RED) + if (isMainFrame) { + expect(result.disabledColor).to.equal(COLOR_BLUE) + } else { + expect(result.disabledColor).to.equal(COLOR_TRANSPARENT) // null color + } + }) + ) + }) + }) + }) + } + + generateTests(false, false) + generateTests(false, true) + generateTests(true, false) + generateTests(true, true) + }) }) ifdescribe(!process.electronBinding('features').isExtensionsEnabled())('chrome extensions', () => { @@ -325,4 +469,199 @@ ifdescribe(!process.electronBinding('features').isExtensionsEnabled())('chrome e expect(response).to.equal(3) }) + + describe('extensions and dev tools extensions', () => { + let showPanelTimeoutId: NodeJS.Timeout | null = null + + const showLastDevToolsPanel = (w: BrowserWindow) => { + w.webContents.once('devtools-opened', () => { + const show = () => { + if (w == null || w.isDestroyed()) return + const { devToolsWebContents } = w as unknown as { devToolsWebContents: WebContents | undefined } + if (devToolsWebContents == null || devToolsWebContents.isDestroyed()) { + return + } + + const showLastPanel = () => { + // this is executed in the devtools context, where UI is a global + const { UI } = (window as any) + const lastPanelId = UI.inspectorView._tabbedPane._tabs.peekLast().id + UI.inspectorView.showPanel(lastPanelId) + } + devToolsWebContents.executeJavaScript(`(${showLastPanel})()`, false).then(() => { + showPanelTimeoutId = setTimeout(show, 100) + }) + } + showPanelTimeoutId = setTimeout(show, 100) + }) + } + + afterEach(() => { + if (showPanelTimeoutId != null) { + clearTimeout(showPanelTimeoutId) + showPanelTimeoutId = null + } + }) + + describe('BrowserWindow.addDevToolsExtension', () => { + describe('for invalid extensions', () => { + it('throws errors for missing manifest.json files', () => { + const nonexistentExtensionPath = path.join(__dirname, 'does-not-exist') + expect(() => { + BrowserWindow.addDevToolsExtension(nonexistentExtensionPath) + }).to.throw(/ENOENT: no such file or directory/) + }) + + it('throws errors for invalid manifest.json files', () => { + const badManifestExtensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest') + expect(() => { + BrowserWindow.addDevToolsExtension(badManifestExtensionPath) + }).to.throw(/Unexpected token }/) + }) + }) + + describe('for a valid extension', () => { + const extensionName = 'foo' + + before(() => { + const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo') + BrowserWindow.addDevToolsExtension(extensionPath) + expect(BrowserWindow.getDevToolsExtensions()).to.have.property(extensionName) + }) + + after(() => { + BrowserWindow.removeDevToolsExtension('foo') + expect(BrowserWindow.getDevToolsExtensions()).to.not.have.property(extensionName) + }) + + describe('when the devtools is docked', () => { + let message: any + let w: BrowserWindow + before(async () => { + w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }) + const p = new Promise(resolve => ipcMain.once('answer', (event, message) => { + resolve(message) + })) + showLastDevToolsPanel(w) + w.loadURL('about:blank') + w.webContents.openDevTools({ mode: 'bottom' }) + message = await p + }) + after(closeAllWindows) + + describe('created extension info', function () { + it('has proper "runtimeId"', async function () { + expect(message).to.have.ownProperty('runtimeId') + expect(message.runtimeId).to.equal(extensionName) + }) + it('has "tabId" matching webContents id', function () { + expect(message).to.have.ownProperty('tabId') + expect(message.tabId).to.equal(w.webContents.id) + }) + it('has "i18nString" with proper contents', function () { + expect(message).to.have.ownProperty('i18nString') + expect(message.i18nString).to.equal('foo - bar (baz)') + }) + it('has "storageItems" with proper contents', function () { + expect(message).to.have.ownProperty('storageItems') + expect(message.storageItems).to.deep.equal({ + local: { + set: { hello: 'world', world: 'hello' }, + remove: { world: 'hello' }, + clear: {} + }, + sync: { + set: { foo: 'bar', bar: 'foo' }, + remove: { foo: 'bar' }, + clear: {} + } + }) + }) + }) + }) + + describe('when the devtools is undocked', () => { + let message: any + let w: BrowserWindow + before(async () => { + w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }) + showLastDevToolsPanel(w) + w.loadURL('about:blank') + w.webContents.openDevTools({ mode: 'undocked' }) + message = await new Promise(resolve => ipcMain.once('answer', (event, message) => { + resolve(message) + })) + }) + after(closeAllWindows) + + describe('created extension info', function () { + it('has proper "runtimeId"', function () { + expect(message).to.have.ownProperty('runtimeId') + expect(message.runtimeId).to.equal(extensionName) + }) + it('has "tabId" matching webContents id', function () { + expect(message).to.have.ownProperty('tabId') + expect(message.tabId).to.equal(w.webContents.id) + }) + }) + }) + }) + }) + + it('works when used with partitions', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { + nodeIntegration: true, + partition: 'temp' + } + }) + + const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo') + BrowserWindow.addDevToolsExtension(extensionPath) + try { + showLastDevToolsPanel(w) + + const p: Promise = new Promise(resolve => ipcMain.once('answer', function (event, message) { + resolve(message) + })) + + w.loadURL('about:blank') + w.webContents.openDevTools({ mode: 'bottom' }) + const message = await p + expect(message.runtimeId).to.equal('foo') + } finally { + BrowserWindow.removeDevToolsExtension('foo') + await closeAllWindows() + } + }) + + it('serializes the registered extensions on quit', () => { + const extensionName = 'foo' + const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName) + const serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions') + + BrowserWindow.addDevToolsExtension(extensionPath) + app.emit('will-quit') + expect(JSON.parse(fs.readFileSync(serializedPath, 'utf8'))).to.deep.equal([extensionPath]) + + BrowserWindow.removeDevToolsExtension(extensionName) + app.emit('will-quit') + expect(fs.existsSync(serializedPath)).to.be.false('file exists') + }) + + describe('BrowserWindow.addExtension', () => { + it('throws errors for missing manifest.json files', () => { + expect(() => { + BrowserWindow.addExtension(path.join(__dirname, 'does-not-exist')) + }).to.throw('ENOENT: no such file or directory') + }) + + it('throws errors for invalid manifest.json files', () => { + expect(() => { + BrowserWindow.addExtension(path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest')) + }).to.throw('Unexpected token }') + }) + }) + }) }) diff --git a/spec-main/fixtures/devtools-extensions/foo/devtools.js b/spec-main/fixtures/devtools-extensions/foo/devtools.js new file mode 100644 index 000000000000..efe264240afa --- /dev/null +++ b/spec-main/fixtures/devtools-extensions/foo/devtools.js @@ -0,0 +1,2 @@ +/* global chrome */ +chrome.devtools.panels.create('Foo', 'foo.png', 'index.html') diff --git a/spec-main/fixtures/devtools-extensions/foo/foo.html b/spec-main/fixtures/devtools-extensions/foo/foo.html index a326639c38de..9a00a78cfe0f 100644 --- a/spec-main/fixtures/devtools-extensions/foo/foo.html +++ b/spec-main/fixtures/devtools-extensions/foo/foo.html @@ -3,8 +3,6 @@ foo - + diff --git a/spec-main/fixtures/devtools-extensions/foo/index.html b/spec-main/fixtures/devtools-extensions/foo/index.html index 6642121c2410..df7c456474a4 100644 --- a/spec-main/fixtures/devtools-extensions/foo/index.html +++ b/spec-main/fixtures/devtools-extensions/foo/index.html @@ -3,84 +3,7 @@ - + a custom devtools extension diff --git a/spec-main/fixtures/devtools-extensions/foo/manifest.json b/spec-main/fixtures/devtools-extensions/foo/manifest.json index b88ab65a1ea8..65e16e074b2c 100644 --- a/spec-main/fixtures/devtools-extensions/foo/manifest.json +++ b/spec-main/fixtures/devtools-extensions/foo/manifest.json @@ -1,5 +1,9 @@ { + "manifest_version": 2, "name": "foo", + "permissions": [ + "storage" + ], "version": "1.0", "devtools_page": "foo.html", "default_locale": "en" diff --git a/spec-main/fixtures/devtools-extensions/foo/panel.js b/spec-main/fixtures/devtools-extensions/foo/panel.js new file mode 100644 index 000000000000..ff8f3f5196c4 --- /dev/null +++ b/spec-main/fixtures/devtools-extensions/foo/panel.js @@ -0,0 +1,77 @@ +/* global chrome */ +function testStorageClear (callback) { + chrome.storage.sync.clear(function () { + chrome.storage.sync.get(null, function (syncItems) { + chrome.storage.local.clear(function () { + chrome.storage.local.get(null, function (localItems) { + callback(syncItems, localItems) + }) + }) + }) + }) +} + +function testStorageRemove (callback) { + chrome.storage.sync.remove('bar', function () { + chrome.storage.sync.get({ foo: 'baz' }, function (syncItems) { + chrome.storage.local.remove(['hello'], function () { + chrome.storage.local.get(null, function (localItems) { + callback(syncItems, localItems) + }) + }) + }) + }) +} + +function testStorageSet (callback) { + chrome.storage.sync.set({ foo: 'bar', bar: 'foo' }, function () { + chrome.storage.sync.get({ foo: 'baz', bar: 'fooo' }, function (syncItems) { + chrome.storage.local.set({ hello: 'world', world: 'hello' }, function () { + chrome.storage.local.get(null, function (localItems) { + callback(syncItems, localItems) + }) + }) + }) + }) +} + +function testStorage (callback) { + testStorageSet(function (syncForSet, localForSet) { + testStorageRemove(function (syncForRemove, localForRemove) { + testStorageClear(function (syncForClear, localForClear) { + callback( + syncForSet, localForSet, + syncForRemove, localForRemove, + syncForClear, localForClear + ) + }) + }) + }) +} + +testStorage(function ( + syncForSet, localForSet, + syncForRemove, localForRemove, + syncForClear, localForClear +) { + const message = JSON.stringify({ + runtimeId: chrome.runtime.id, + tabId: chrome.devtools.inspectedWindow.tabId, + i18nString: null, // chrome.i18n.getMessage('foo', ['bar', 'baz']), + storageItems: { + local: { + set: localForSet, + remove: localForRemove, + clear: localForClear + }, + sync: { + set: syncForSet, + remove: syncForRemove, + clear: syncForClear + } + } + }) + + const sendMessage = `require('electron').ipcRenderer.send('answer', ${message})` + window.chrome.devtools.inspectedWindow.eval(sendMessage, function () {}) +}) diff --git a/spec-main/fixtures/pages/webview-devtools.html b/spec-main/fixtures/pages/webview-devtools.html index ebbf952c300c..47cd8719d495 100644 --- a/spec-main/fixtures/pages/webview-devtools.html +++ b/spec-main/fixtures/pages/webview-devtools.html @@ -4,7 +4,7 @@ - +