Browse Source

feat: enable native extensions support (#21814)

Jeremy Apthorp 5 years ago
parent
commit
a061c87e56
61 changed files with 1054 additions and 941 deletions
  1. 2 0
      build/args/all.gn
  2. 24 6
      docs/api/browser-window.md
  3. 59 0
      docs/api/session.md
  4. 5 0
      docs/api/structures/extension.md
  5. 1 0
      filenames.auto.gni
  6. 28 28
      filenames.gni
  7. 7 8
      shell/browser/api/atom_api_protocol.cc
  8. 12 7
      shell/browser/api/atom_api_session.cc
  9. 2 2
      shell/browser/api/atom_api_system_preferences_mac.mm
  10. 3 3
      shell/browser/api/atom_api_web_contents.cc
  11. 1 1
      shell/browser/atom_browser_client.cc
  12. 6 6
      shell/browser/atom_browser_context.cc
  13. 3 3
      shell/browser/atom_browser_context.h
  14. 6 5
      shell/browser/atom_browser_main_parts.cc
  15. 4 4
      shell/browser/atom_browser_main_parts.h
  16. 0 55
      shell/browser/extensions/api/runtime/atom_runtime_api_delegate.cc
  17. 57 0
      shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc
  18. 7 7
      shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h
  19. 0 23
      shell/browser/extensions/atom_display_info_provider.h
  20. 3 3
      shell/browser/extensions/electron_browser_context_keyed_service_factories.cc
  21. 3 3
      shell/browser/extensions/electron_browser_context_keyed_service_factories.h
  22. 2 2
      shell/browser/extensions/electron_display_info_provider.cc
  23. 23 0
      shell/browser/extensions/electron_display_info_provider.h
  24. 13 13
      shell/browser/extensions/electron_extension_host_delegate.cc
  25. 7 7
      shell/browser/extensions/electron_extension_host_delegate.h
  26. 42 37
      shell/browser/extensions/electron_extension_loader.cc
  27. 18 15
      shell/browser/extensions/electron_extension_loader.h
  28. 34 32
      shell/browser/extensions/electron_extension_system.cc
  29. 13 12
      shell/browser/extensions/electron_extension_system.h
  30. 14 13
      shell/browser/extensions/electron_extension_system_factory.cc
  31. 10 10
      shell/browser/extensions/electron_extension_system_factory.h
  32. 6 6
      shell/browser/extensions/electron_extension_web_contents_observer.cc
  33. 12 9
      shell/browser/extensions/electron_extension_web_contents_observer.h
  34. 2 2
      shell/browser/extensions/electron_extensions_api_client.cc
  35. 58 54
      shell/browser/extensions/electron_extensions_browser_client.cc
  36. 8 7
      shell/browser/extensions/electron_extensions_browser_client.h
  37. 8 8
      shell/browser/extensions/electron_navigation_ui_data.cc
  38. 9 8
      shell/browser/extensions/electron_navigation_ui_data.h
  39. 9 11
      shell/browser/native_window_mac.mm
  40. 0 20
      shell/common/deprecate_util.h
  41. 13 12
      shell/common/extensions/electron_extensions_api_provider.cc
  42. 7 7
      shell/common/extensions/electron_extensions_api_provider.h
  43. 24 23
      shell/common/extensions/electron_extensions_client.cc
  44. 7 7
      shell/common/extensions/electron_extensions_client.h
  45. 0 1
      shell/common/gin_converters/blink_converter.cc
  46. 4 4
      shell/common/process_util.cc
  47. 20 0
      shell/common/process_util.h
  48. 13 13
      shell/renderer/extensions/electron_extensions_renderer_client.cc
  49. 7 7
      shell/renderer/extensions/electron_extensions_renderer_client.h
  50. 4 4
      shell/renderer/renderer_client_base.cc
  51. 2 2
      shell/renderer/renderer_client_base.h
  52. 0 195
      spec-main/api-browser-window-spec.ts
  53. 0 149
      spec-main/content-script-spec.ts
  54. 341 2
      spec-main/extensions-spec.ts
  55. 2 0
      spec-main/fixtures/devtools-extensions/foo/devtools.js
  56. 1 3
      spec-main/fixtures/devtools-extensions/foo/foo.html
  57. 1 78
      spec-main/fixtures/devtools-extensions/foo/index.html
  58. 4 0
      spec-main/fixtures/devtools-extensions/foo/manifest.json
  59. 77 0
      spec-main/fixtures/devtools-extensions/foo/panel.js
  60. 1 1
      spec-main/fixtures/pages/webview-devtools.html
  61. 5 3
      spec-main/webview-spec.ts

+ 2 - 0
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

+ 24 - 6
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<String, ExtensionInfo>` - 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<string, ExtensionInfo>` - 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:

+ 59 - 0
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<Extension>` - 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`:

+ 5 - 0
docs/api/structures/extension.md

@@ -0,0 +1,5 @@
+# Extension Object
+
+* `id` String
+* `name` String
+* `version` String

+ 1 - 0
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",

+ 28 - 28
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",
   ]

+ 7 - 8
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<v8::Promise> 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<bool>::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");

+ 12 - 7
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<v8::Promise> Session::LoadExtension(
   gin_helper::Promise<const extensions::Extension*> promise(isolate());
   v8::Local<v8::Promise> handle = promise.GetHandle();
 
-  auto* extension_system = static_cast<extensions::AtomExtensionSystem*>(
+  auto* extension_system = static_cast<extensions::ElectronExtensionSystem*>(
       extensions::ExtensionSystem::Get(browser_context()));
   extension_system->LoadExtension(
       extension_path,
       base::BindOnce(
           [](gin_helper::Promise<const extensions::Extension*> 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<v8::Promise> Session::LoadExtension(
 }
 
 void Session::RemoveExtension(const std::string& extension_id) {
-  auto* extension_system = static_cast<extensions::AtomExtensionSystem*>(
+  auto* extension_system = static_cast<extensions::ElectronExtensionSystem*>(
       extensions::ExtensionSystem::Get(browser_context()));
   extension_system->RemoveExtension(extension_id);
 }

+ 2 - 2
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.",

+ 3 - 3
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

+ 1 - 1
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)

+ 6 - 6
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<extensions::AtomExtensionSystem*>(
+  extension_system_ = static_cast<extensions::ElectronExtensionSystem*>(
       extensions::ExtensionSystem::Get(this));
   extension_system_->InitForRegularProfile(true /* extensions_enabled */);
   extension_system_->FinishInitialization();

+ 3 - 3
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.

+ 6 - 5
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<AtomExtensionsClient>();
+  extensions_client_ = std::make_unique<ElectronExtensionsClient>();
   extensions::ExtensionsClient::Set(extensions_client_.get());
 
   // BrowserContextKeyedAPIServiceFactories require an ExtensionsBrowserClient.
-  extensions_browser_client_ = std::make_unique<AtomExtensionsBrowserClient>();
+  extensions_browser_client_ =
+      std::make_unique<ElectronExtensionsBrowserClient>();
   extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
 
   extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();

+ 4 - 4
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<base::FieldTrialList> field_trial_list_;
 
 #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
-  std::unique_ptr<AtomExtensionsClient> extensions_client_;
-  std::unique_ptr<AtomExtensionsBrowserClient> extensions_browser_client_;
+  std::unique_ptr<ElectronExtensionsClient> extensions_client_;
+  std::unique_ptr<ElectronExtensionsBrowserClient> extensions_browser_client_;
 #endif
 
   base::RepeatingTimer gc_timer_;

+ 0 - 55
shell/browser/extensions/api/runtime/atom_runtime_api_delegate.cc

@@ -1,55 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h"
-
-#include <string>
-
-#include "build/build_config.h"
-#include "extensions/common/api/runtime.h"
-#include "shell/browser/extensions/atom_extension_system.h"
-
-using extensions::api::runtime::PlatformInfo;
-
-namespace extensions {
-
-AtomRuntimeAPIDelegate::AtomRuntimeAPIDelegate(
-    content::BrowserContext* browser_context)
-    : browser_context_(browser_context) {
-  DCHECK(browser_context_);
-}
-
-AtomRuntimeAPIDelegate::~AtomRuntimeAPIDelegate() = default;
-
-void AtomRuntimeAPIDelegate::AddUpdateObserver(UpdateObserver* observer) {}
-
-void AtomRuntimeAPIDelegate::RemoveUpdateObserver(UpdateObserver* observer) {}
-
-void AtomRuntimeAPIDelegate::ReloadExtension(const std::string& extension_id) {
-  static_cast<AtomExtensionSystem*>(ExtensionSystem::Get(browser_context_))
-      ->ReloadExtension(extension_id);
-}
-
-bool AtomRuntimeAPIDelegate::CheckForUpdates(
-    const std::string& extension_id,
-    const UpdateCheckCallback& callback) {
-  return false;
-}
-
-void AtomRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {}
-
-bool AtomRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
-  // TODO(nornagon): put useful information here.
-#if defined(OS_LINUX)
-  info->os = api::runtime::PLATFORM_OS_LINUX;
-#endif
-  return true;
-}  // namespace extensions
-
-bool AtomRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
-  *error_message = "Restart is not supported in Electron";
-  return false;
-}
-
-}  // namespace extensions

+ 57 - 0
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 <string>
+
+#include "build/build_config.h"
+#include "extensions/common/api/runtime.h"
+#include "shell/browser/extensions/electron_extension_system.h"
+
+using extensions::api::runtime::PlatformInfo;
+
+namespace extensions {
+
+ElectronRuntimeAPIDelegate::ElectronRuntimeAPIDelegate(
+    content::BrowserContext* browser_context)
+    : browser_context_(browser_context) {
+  DCHECK(browser_context_);
+}
+
+ElectronRuntimeAPIDelegate::~ElectronRuntimeAPIDelegate() = default;
+
+void ElectronRuntimeAPIDelegate::AddUpdateObserver(UpdateObserver* observer) {}
+
+void ElectronRuntimeAPIDelegate::RemoveUpdateObserver(
+    UpdateObserver* observer) {}
+
+void ElectronRuntimeAPIDelegate::ReloadExtension(
+    const std::string& extension_id) {
+  static_cast<ElectronExtensionSystem*>(ExtensionSystem::Get(browser_context_))
+      ->ReloadExtension(extension_id);
+}
+
+bool ElectronRuntimeAPIDelegate::CheckForUpdates(
+    const std::string& extension_id,
+    const UpdateCheckCallback& callback) {
+  return false;
+}
+
+void ElectronRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {}
+
+bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
+  // TODO(nornagon): put useful information here.
+#if defined(OS_LINUX)
+  info->os = api::runtime::PLATFORM_OS_LINUX;
+#endif
+  return true;
+}  // namespace extensions
+
+bool ElectronRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
+  *error_message = "Restart is not supported in Electron";
+  return false;
+}
+
+}  // namespace extensions

+ 7 - 7
shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h → 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 <string>
 
@@ -16,10 +16,10 @@ class BrowserContext;
 
 namespace extensions {
 
-class AtomRuntimeAPIDelegate : public RuntimeAPIDelegate {
+class ElectronRuntimeAPIDelegate : public RuntimeAPIDelegate {
  public:
-  explicit AtomRuntimeAPIDelegate(content::BrowserContext* browser_context);
-  ~AtomRuntimeAPIDelegate() override;
+  explicit ElectronRuntimeAPIDelegate(content::BrowserContext* browser_context);
+  ~ElectronRuntimeAPIDelegate() override;
 
   // RuntimeAPIDelegate implementation.
   void AddUpdateObserver(UpdateObserver* observer) override;
@@ -34,9 +34,9 @@ class AtomRuntimeAPIDelegate : public RuntimeAPIDelegate {
  private:
   content::BrowserContext* browser_context_;
 
-  DISALLOW_COPY_AND_ASSIGN(AtomRuntimeAPIDelegate);
+  DISALLOW_COPY_AND_ASSIGN(ElectronRuntimeAPIDelegate);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ATOM_RUNTIME_API_DELEGATE_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_API_RUNTIME_ELECTRON_RUNTIME_API_DELEGATE_H_

+ 0 - 23
shell/browser/extensions/atom_display_info_provider.h

@@ -1,23 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SHELL_BROWSER_EXTENSIONS_ATOM_DISPLAY_INFO_PROVIDER_H_
-#define SHELL_BROWSER_EXTENSIONS_ATOM_DISPLAY_INFO_PROVIDER_H_
-
-#include "base/macros.h"
-#include "extensions/browser/api/system_display/display_info_provider.h"
-
-namespace extensions {
-
-class AtomDisplayInfoProvider : public DisplayInfoProvider {
- public:
-  AtomDisplayInfoProvider();
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(AtomDisplayInfoProvider);
-};
-
-}  // namespace extensions
-
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_DISPLAY_INFO_PROVIDER_H_

+ 3 - 3
shell/browser/extensions/atom_browser_context_keyed_service_factories.cc → 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

+ 3 - 3
shell/browser/extensions/atom_browser_context_keyed_service_factories.h → 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_

+ 2 - 2
shell/browser/extensions/atom_display_info_provider.cc → 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

+ 23 - 0
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_

+ 13 - 13
shell/browser/extensions/atom_extension_host_delegate.cc → 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 <memory>
 #include <string>
@@ -11,31 +11,31 @@
 #include "base/lazy_instance.h"
 #include "base/logging.h"
 #include "extensions/browser/media_capture_util.h"
-#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
+#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
 
 namespace extensions {
 
-AtomExtensionHostDelegate::AtomExtensionHostDelegate() {}
+ElectronExtensionHostDelegate::ElectronExtensionHostDelegate() {}
 
-AtomExtensionHostDelegate::~AtomExtensionHostDelegate() {}
+ElectronExtensionHostDelegate::~ElectronExtensionHostDelegate() {}
 
-void AtomExtensionHostDelegate::OnExtensionHostCreated(
+void ElectronExtensionHostDelegate::OnExtensionHostCreated(
     content::WebContents* web_contents) {
-  AtomExtensionWebContentsObserver::CreateForWebContents(web_contents);
+  ElectronExtensionWebContentsObserver::CreateForWebContents(web_contents);
 }
 
-void AtomExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
+void ElectronExtensionHostDelegate::OnRenderViewCreatedForBackgroundPage(
     ExtensionHost* host) {}
 
 content::JavaScriptDialogManager*
-AtomExtensionHostDelegate::GetJavaScriptDialogManager() {
+ElectronExtensionHostDelegate::GetJavaScriptDialogManager() {
   // TODO(jamescook): Create a JavaScriptDialogManager or reuse the one from
   // content_shell.
   NOTREACHED();
   return nullptr;
 }
 
-void AtomExtensionHostDelegate::CreateTab(
+void ElectronExtensionHostDelegate::CreateTab(
     std::unique_ptr<content::WebContents> web_contents,
     const std::string& extension_id,
     WindowOpenDisposition disposition,
@@ -45,7 +45,7 @@ void AtomExtensionHostDelegate::CreateTab(
   NOTREACHED();
 }
 
-void AtomExtensionHostDelegate::ProcessMediaAccessRequest(
+void ElectronExtensionHostDelegate::ProcessMediaAccessRequest(
     content::WebContents* web_contents,
     const content::MediaStreamRequest& request,
     content::MediaResponseCallback callback,
@@ -55,7 +55,7 @@ void AtomExtensionHostDelegate::ProcessMediaAccessRequest(
                                               std::move(callback), extension);
 }
 
-bool AtomExtensionHostDelegate::CheckMediaAccessPermission(
+bool ElectronExtensionHostDelegate::CheckMediaAccessPermission(
     content::RenderFrameHost* render_frame_host,
     const GURL& security_origin,
     blink::mojom::MediaStreamType type,
@@ -65,7 +65,7 @@ bool AtomExtensionHostDelegate::CheckMediaAccessPermission(
 }
 
 content::PictureInPictureResult
-AtomExtensionHostDelegate::EnterPictureInPicture(
+ElectronExtensionHostDelegate::EnterPictureInPicture(
     content::WebContents* web_contents,
     const viz::SurfaceId& surface_id,
     const gfx::Size& natural_size) {
@@ -73,7 +73,7 @@ AtomExtensionHostDelegate::EnterPictureInPicture(
   return content::PictureInPictureResult();
 }
 
-void AtomExtensionHostDelegate::ExitPictureInPicture() {
+void ElectronExtensionHostDelegate::ExitPictureInPicture() {
   NOTREACHED();
 }
 

+ 7 - 7
shell/browser/extensions/atom_extension_host_delegate.h → 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 <memory>
 #include <string>
@@ -14,10 +14,10 @@
 namespace extensions {
 
 // A minimal ExtensionHostDelegate.
-class AtomExtensionHostDelegate : public ExtensionHostDelegate {
+class ElectronExtensionHostDelegate : public ExtensionHostDelegate {
  public:
-  AtomExtensionHostDelegate();
-  ~AtomExtensionHostDelegate() override;
+  ElectronExtensionHostDelegate();
+  ~ElectronExtensionHostDelegate() override;
 
   // ExtensionHostDelegate implementation.
   void OnExtensionHostCreated(content::WebContents* web_contents) override;
@@ -43,9 +43,9 @@ class AtomExtensionHostDelegate : public ExtensionHostDelegate {
   void ExitPictureInPicture() override;
 
  private:
-  DISALLOW_COPY_AND_ASSIGN(AtomExtensionHostDelegate);
+  DISALLOW_COPY_AND_ASSIGN(ElectronExtensionHostDelegate);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_HOST_DELEGATE_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_HOST_DELEGATE_H_

+ 42 - 37
shell/browser/extensions/atom_extension_loader.cc → 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 <utility>
 
@@ -12,6 +12,7 @@
 #include "base/files/file_util.h"
 #include "base/logging.h"
 #include "base/sequenced_task_runner.h"
+#include "base/strings/utf_string_conversions.h"
 #include "base/task_runner_util.h"
 #include "base/threading/thread_restrictions.h"
 #include "extensions/browser/extension_file_task_runner.h"
@@ -25,16 +26,15 @@ using LoadErrorBehavior = ExtensionRegistrar::LoadErrorBehavior;
 
 namespace {
 
-scoped_refptr<const Extension> LoadUnpacked(
+std::pair<scoped_refptr<const Extension>, std::string> LoadUnpacked(
     const base::FilePath& extension_dir) {
   // app_shell only supports unpacked extensions.
   // NOTE: If you add packed extension support consider removing the flag
   // FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks.
-  // TODO(nornagon): these LOG()s should surface as JS exceptions
   if (!base::DirectoryExists(extension_dir)) {
-    LOG(ERROR) << "Extension directory not found: "
-               << extension_dir.AsUTF8Unsafe();
-    return nullptr;
+    std::string err = "Extension directory not found: " +
+                      base::UTF16ToUTF8(extension_dir.LossyDisplayName());
+    return std::make_pair(nullptr, err);
   }
 
   int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE;
@@ -42,43 +42,46 @@ scoped_refptr<const Extension> LoadUnpacked(
   scoped_refptr<Extension> extension = file_util::LoadExtension(
       extension_dir, Manifest::COMMAND_LINE, load_flags, &load_error);
   if (!extension.get()) {
-    LOG(ERROR) << "Loading extension at " << extension_dir.value()
-               << " failed with: " << load_error;
-    return nullptr;
+    std::string err = "Loading extension at " +
+                      base::UTF16ToUTF8(extension_dir.LossyDisplayName()) +
+                      " failed with: " + load_error;
+    return std::make_pair(nullptr, err);
   }
 
+  std::string warnings;
   // Log warnings.
   if (extension->install_warnings().size()) {
-    LOG(WARNING) << "Warnings loading extension at " << extension_dir.value()
-                 << ":";
-    for (const auto& warning : extension->install_warnings())
-      LOG(WARNING) << warning.message;
+    warnings += "Warnings loading extension at " +
+                base::UTF16ToUTF8(extension_dir.LossyDisplayName()) + ": ";
+    for (const auto& warning : extension->install_warnings()) {
+      warnings += warning.message + " ";
+    }
   }
 
-  return extension;
+  return std::make_pair(extension, warnings);
 }
 
 }  // namespace
 
-AtomExtensionLoader::AtomExtensionLoader(
+ElectronExtensionLoader::ElectronExtensionLoader(
     content::BrowserContext* browser_context)
     : browser_context_(browser_context),
       extension_registrar_(browser_context, this),
       weak_factory_(this) {}
 
-AtomExtensionLoader::~AtomExtensionLoader() = default;
+ElectronExtensionLoader::~ElectronExtensionLoader() = default;
 
-void AtomExtensionLoader::LoadExtension(
+void ElectronExtensionLoader::LoadExtension(
     const base::FilePath& extension_dir,
-    base::OnceCallback<void(const Extension*)> loaded) {
+    base::OnceCallback<void(const Extension*, const std::string&)> cb) {
   base::PostTaskAndReplyWithResult(
       GetExtensionFileTaskRunner().get(), FROM_HERE,
       base::BindOnce(&LoadUnpacked, extension_dir),
-      base::BindOnce(&AtomExtensionLoader::FinishExtensionLoad,
-                     weak_factory_.GetWeakPtr(), std::move(loaded)));
+      base::BindOnce(&ElectronExtensionLoader::FinishExtensionLoad,
+                     weak_factory_.GetWeakPtr(), std::move(cb)));
 }
 
-void AtomExtensionLoader::ReloadExtension(const ExtensionId& extension_id) {
+void ElectronExtensionLoader::ReloadExtension(const ExtensionId& extension_id) {
   const Extension* extension = ExtensionRegistry::Get(browser_context_)
                                    ->GetInstalledExtension(extension_id);
   // We shouldn't be trying to reload extensions that haven't been added.
@@ -94,31 +97,33 @@ void AtomExtensionLoader::ReloadExtension(const ExtensionId& extension_id) {
     return;
 }
 
-void AtomExtensionLoader::UnloadExtension(
+void ElectronExtensionLoader::UnloadExtension(
     const ExtensionId& extension_id,
     extensions::UnloadedExtensionReason reason) {
   extension_registrar_.RemoveExtension(extension_id, reason);
 }
 
-void AtomExtensionLoader::FinishExtensionLoad(
-    base::OnceCallback<void(const Extension*)> done,
-    scoped_refptr<const Extension> extension) {
+void ElectronExtensionLoader::FinishExtensionLoad(
+    base::OnceCallback<void(const Extension*, const std::string&)> cb,
+    std::pair<scoped_refptr<const Extension>, std::string> result) {
+  scoped_refptr<const Extension> extension = result.first;
   if (extension) {
     extension_registrar_.AddExtension(extension);
   }
-  std::move(done).Run(extension.get());
+  std::move(cb).Run(extension.get(), result.second);
 }
 
-void AtomExtensionLoader::FinishExtensionReload(
+void ElectronExtensionLoader::FinishExtensionReload(
     const ExtensionId& old_extension_id,
-    scoped_refptr<const Extension> extension) {
+    std::pair<scoped_refptr<const Extension>, std::string> result) {
+  scoped_refptr<const Extension> extension = result.first;
   if (extension) {
     extension_registrar_.AddExtension(extension);
   }
 }
 
-void AtomExtensionLoader::PreAddExtension(const Extension* extension,
-                                          const Extension* old_extension) {
+void ElectronExtensionLoader::PreAddExtension(const Extension* extension,
+                                              const Extension* old_extension) {
   if (old_extension)
     return;
 
@@ -138,13 +143,13 @@ void AtomExtensionLoader::PreAddExtension(const Extension* extension,
   }
 }
 
-void AtomExtensionLoader::PostActivateExtension(
+void ElectronExtensionLoader::PostActivateExtension(
     scoped_refptr<const Extension> extension) {}
 
-void AtomExtensionLoader::PostDeactivateExtension(
+void ElectronExtensionLoader::PostDeactivateExtension(
     scoped_refptr<const Extension> extension) {}
 
-void AtomExtensionLoader::LoadExtensionForReload(
+void ElectronExtensionLoader::LoadExtensionForReload(
     const ExtensionId& extension_id,
     const base::FilePath& path,
     LoadErrorBehavior load_error_behavior) {
@@ -153,21 +158,21 @@ void AtomExtensionLoader::LoadExtensionForReload(
   base::PostTaskAndReplyWithResult(
       GetExtensionFileTaskRunner().get(), FROM_HERE,
       base::BindOnce(&LoadUnpacked, path),
-      base::BindOnce(&AtomExtensionLoader::FinishExtensionReload,
+      base::BindOnce(&ElectronExtensionLoader::FinishExtensionReload,
                      weak_factory_.GetWeakPtr(), extension_id));
   did_schedule_reload_ = true;
 }
 
-bool AtomExtensionLoader::CanEnableExtension(const Extension* extension) {
+bool ElectronExtensionLoader::CanEnableExtension(const Extension* extension) {
   return true;
 }
 
-bool AtomExtensionLoader::CanDisableExtension(const Extension* extension) {
+bool ElectronExtensionLoader::CanDisableExtension(const Extension* extension) {
   // Extensions cannot be disabled by the user.
   return false;
 }
 
-bool AtomExtensionLoader::ShouldBlockExtension(const Extension* extension) {
+bool ElectronExtensionLoader::ShouldBlockExtension(const Extension* extension) {
   return false;
 }
 

+ 18 - 15
shell/browser/extensions/atom_extension_loader.h → 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 <memory>
 #include <string>
+#include <utility>
 
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
@@ -27,16 +28,16 @@ namespace extensions {
 class Extension;
 
 // Handles extension loading and reloading using ExtensionRegistrar.
-class AtomExtensionLoader : public ExtensionRegistrar::Delegate {
+class ElectronExtensionLoader : public ExtensionRegistrar::Delegate {
  public:
-  explicit AtomExtensionLoader(content::BrowserContext* browser_context);
-  ~AtomExtensionLoader() override;
+  explicit ElectronExtensionLoader(content::BrowserContext* browser_context);
+  ~ElectronExtensionLoader() override;
 
   // Loads an unpacked extension from a directory synchronously. Returns the
   // extension on success, or nullptr otherwise.
-  void LoadExtension(
-      const base::FilePath& extension_dir,
-      base::OnceCallback<void(const Extension* extension)> loaded);
+  void LoadExtension(const base::FilePath& extension_dir,
+                     base::OnceCallback<void(const Extension* extension,
+                                             const std::string&)> cb);
 
   // Starts reloading the extension. A keep-alive is maintained until the
   // reload succeeds/fails. If the extension is an app, it will be launched upon
@@ -51,11 +52,13 @@ class AtomExtensionLoader : public ExtensionRegistrar::Delegate {
  private:
   // If the extension loaded successfully, enables it. If it's an app, launches
   // it. If the load failed, updates ShellKeepAliveRequester.
-  void FinishExtensionReload(const ExtensionId& old_extension_id,
-                             scoped_refptr<const Extension> extension);
+  void FinishExtensionReload(
+      const ExtensionId& old_extension_id,
+      std::pair<scoped_refptr<const Extension>, std::string> result);
 
-  void FinishExtensionLoad(base::OnceCallback<void(const Extension*)> loaded,
-                           scoped_refptr<const Extension> extension);
+  void FinishExtensionLoad(
+      base::OnceCallback<void(const Extension*, const std::string&)> cb,
+      std::pair<scoped_refptr<const Extension>, std::string> result);
 
   // ExtensionRegistrar::Delegate:
   void PreAddExtension(const Extension* extension,
@@ -84,11 +87,11 @@ class AtomExtensionLoader : public ExtensionRegistrar::Delegate {
   // LoadExtensionForReload().
   bool did_schedule_reload_ = false;
 
-  base::WeakPtrFactory<AtomExtensionLoader> weak_factory_;
+  base::WeakPtrFactory<ElectronExtensionLoader> weak_factory_;
 
-  DISALLOW_COPY_AND_ASSIGN(AtomExtensionLoader);
+  DISALLOW_COPY_AND_ASSIGN(ElectronExtensionLoader);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_LOADER_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_LOADER_H_

+ 34 - 32
shell/browser/extensions/atom_extension_system.cc → 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 <memory>
 #include <string>
@@ -30,27 +30,28 @@
 #include "extensions/browser/value_store/value_store_factory_impl.h"
 #include "extensions/common/constants.h"
 #include "extensions/common/file_util.h"
-#include "shell/browser/extensions/atom_extension_loader.h"
+#include "shell/browser/extensions/electron_extension_loader.h"
 
 using content::BrowserContext;
 using content::BrowserThread;
 
 namespace extensions {
 
-AtomExtensionSystem::AtomExtensionSystem(BrowserContext* browser_context)
+ElectronExtensionSystem::ElectronExtensionSystem(
+    BrowserContext* browser_context)
     : browser_context_(browser_context),
       store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())),
       weak_factory_(this) {}
 
-AtomExtensionSystem::~AtomExtensionSystem() = default;
+ElectronExtensionSystem::~ElectronExtensionSystem() = default;
 
-void AtomExtensionSystem::LoadExtension(
+void ElectronExtensionSystem::LoadExtension(
     const base::FilePath& extension_dir,
-    base::OnceCallback<void(const Extension*)> loaded) {
-  extension_loader_->LoadExtension(extension_dir, std::move(loaded));
+    base::OnceCallback<void(const Extension*, const std::string&)> cb) {
+  extension_loader_->LoadExtension(extension_dir, std::move(cb));
 }
 
-void AtomExtensionSystem::FinishInitialization() {
+void ElectronExtensionSystem::FinishInitialization() {
   // Inform the rest of the extensions system to start.
   ready_.Signal();
   content::NotificationService::current()->Notify(
@@ -59,20 +60,20 @@ void AtomExtensionSystem::FinishInitialization() {
       content::NotificationService::NoDetails());
 }
 
-void AtomExtensionSystem::ReloadExtension(const ExtensionId& extension_id) {
+void ElectronExtensionSystem::ReloadExtension(const ExtensionId& extension_id) {
   extension_loader_->ReloadExtension(extension_id);
 }
 
-void AtomExtensionSystem::RemoveExtension(const ExtensionId& extension_id) {
+void ElectronExtensionSystem::RemoveExtension(const ExtensionId& extension_id) {
   extension_loader_->UnloadExtension(
       extension_id, extensions::UnloadedExtensionReason::UNINSTALL);
 }
 
-void AtomExtensionSystem::Shutdown() {
+void ElectronExtensionSystem::Shutdown() {
   extension_loader_.reset();
 }
 
-void AtomExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
+void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
   service_worker_manager_ =
       std::make_unique<ServiceWorkerManager>(browser_context_);
   runtime_data_ =
@@ -81,56 +82,57 @@ void AtomExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
   shared_user_script_master_ =
       std::make_unique<SharedUserScriptMaster>(browser_context_);
   app_sorting_ = std::make_unique<NullAppSorting>();
-  extension_loader_ = std::make_unique<AtomExtensionLoader>(browser_context_);
+  extension_loader_ =
+      std::make_unique<ElectronExtensionLoader>(browser_context_);
 }
 
-ExtensionService* AtomExtensionSystem::extension_service() {
+ExtensionService* ElectronExtensionSystem::extension_service() {
   return nullptr;
 }
 
-RuntimeData* AtomExtensionSystem::runtime_data() {
+RuntimeData* ElectronExtensionSystem::runtime_data() {
   return runtime_data_.get();
 }
 
-ManagementPolicy* AtomExtensionSystem::management_policy() {
+ManagementPolicy* ElectronExtensionSystem::management_policy() {
   return nullptr;
 }
 
-ServiceWorkerManager* AtomExtensionSystem::service_worker_manager() {
+ServiceWorkerManager* ElectronExtensionSystem::service_worker_manager() {
   return service_worker_manager_.get();
 }
 
-SharedUserScriptMaster* AtomExtensionSystem::shared_user_script_master() {
+SharedUserScriptMaster* ElectronExtensionSystem::shared_user_script_master() {
   return new SharedUserScriptMaster(browser_context_);
 }
 
-StateStore* AtomExtensionSystem::state_store() {
+StateStore* ElectronExtensionSystem::state_store() {
   return nullptr;
 }
 
-StateStore* AtomExtensionSystem::rules_store() {
+StateStore* ElectronExtensionSystem::rules_store() {
   return nullptr;
 }
 
-scoped_refptr<ValueStoreFactory> AtomExtensionSystem::store_factory() {
+scoped_refptr<ValueStoreFactory> ElectronExtensionSystem::store_factory() {
   return store_factory_;
 }
 
-InfoMap* AtomExtensionSystem::info_map() {
+InfoMap* ElectronExtensionSystem::info_map() {
   if (!info_map_.get())
     info_map_ = new InfoMap;
   return info_map_.get();
 }
 
-QuotaService* AtomExtensionSystem::quota_service() {
+QuotaService* ElectronExtensionSystem::quota_service() {
   return quota_service_.get();
 }
 
-AppSorting* AtomExtensionSystem::app_sorting() {
+AppSorting* ElectronExtensionSystem::app_sorting() {
   return app_sorting_.get();
 }
 
-void AtomExtensionSystem::RegisterExtensionWithRequestContexts(
+void ElectronExtensionSystem::RegisterExtensionWithRequestContexts(
     const Extension* extension,
     base::OnceClosure callback) {
   base::PostTaskAndReply(
@@ -140,24 +142,24 @@ void AtomExtensionSystem::RegisterExtensionWithRequestContexts(
       std::move(callback));
 }
 
-void AtomExtensionSystem::UnregisterExtensionWithRequestContexts(
+void ElectronExtensionSystem::UnregisterExtensionWithRequestContexts(
     const std::string& extension_id,
     const UnloadedExtensionReason reason) {}
 
-const base::OneShotEvent& AtomExtensionSystem::ready() const {
+const base::OneShotEvent& ElectronExtensionSystem::ready() const {
   return ready_;
 }
 
-ContentVerifier* AtomExtensionSystem::content_verifier() {
+ContentVerifier* ElectronExtensionSystem::content_verifier() {
   return nullptr;
 }
 
-std::unique_ptr<ExtensionSet> AtomExtensionSystem::GetDependentExtensions(
+std::unique_ptr<ExtensionSet> ElectronExtensionSystem::GetDependentExtensions(
     const Extension* extension) {
   return std::make_unique<ExtensionSet>();
 }
 
-void AtomExtensionSystem::InstallUpdate(
+void ElectronExtensionSystem::InstallUpdate(
     const std::string& extension_id,
     const std::string& public_key,
     const base::FilePath& temp_dir,
@@ -167,14 +169,14 @@ void AtomExtensionSystem::InstallUpdate(
   base::DeleteFile(temp_dir, true /* recursive */);
 }
 
-bool AtomExtensionSystem::FinishDelayedInstallationIfReady(
+bool ElectronExtensionSystem::FinishDelayedInstallationIfReady(
     const std::string& extension_id,
     bool install_immediately) {
   NOTREACHED();
   return false;
 }
 
-void AtomExtensionSystem::OnExtensionRegisteredWithRequestContexts(
+void ElectronExtensionSystem::OnExtensionRegisteredWithRequestContexts(
     scoped_refptr<Extension> extension) {
   ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_);
   registry->AddReady(extension);

+ 13 - 12
shell/browser/extensions/atom_extension_system.h → 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 <memory>
 #include <string>
@@ -26,21 +26,22 @@ class BrowserContext;
 
 namespace extensions {
 
-class AtomExtensionLoader;
+class ElectronExtensionLoader;
 class ValueStoreFactory;
 
 // A simplified version of ExtensionSystem for app_shell. Allows
 // app_shell to skip initialization of services it doesn't need.
-class AtomExtensionSystem : public ExtensionSystem {
+class ElectronExtensionSystem : public ExtensionSystem {
  public:
   using InstallUpdateCallback = ExtensionSystem::InstallUpdateCallback;
-  explicit AtomExtensionSystem(content::BrowserContext* browser_context);
-  ~AtomExtensionSystem() override;
+  explicit ElectronExtensionSystem(content::BrowserContext* browser_context);
+  ~ElectronExtensionSystem() override;
 
   // Loads an unpacked extension from a directory. Returns the extension on
   // success, or nullptr otherwise.
-  void LoadExtension(const base::FilePath& extension_dir,
-                     base::OnceCallback<void(const Extension*)> loaded);
+  void LoadExtension(
+      const base::FilePath& extension_dir,
+      base::OnceCallback<void(const Extension*, const std::string&)> cb);
 
   // Finish initialization for the shell extension system.
   void FinishInitialization();
@@ -98,18 +99,18 @@ class AtomExtensionSystem : public ExtensionSystem {
   std::unique_ptr<SharedUserScriptMaster> shared_user_script_master_;
   std::unique_ptr<AppSorting> app_sorting_;
 
-  std::unique_ptr<AtomExtensionLoader> extension_loader_;
+  std::unique_ptr<ElectronExtensionLoader> extension_loader_;
 
   scoped_refptr<ValueStoreFactory> store_factory_;
 
   // Signaled when the extension system has completed its startup tasks.
   base::OneShotEvent ready_;
 
-  base::WeakPtrFactory<AtomExtensionSystem> weak_factory_;
+  base::WeakPtrFactory<ElectronExtensionSystem> weak_factory_;
 
-  DISALLOW_COPY_AND_ASSIGN(AtomExtensionSystem);
+  DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystem);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_H_

+ 14 - 13
shell/browser/extensions/atom_extension_system_factory.cc → 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<AtomExtensionSystem*>(
+  return static_cast<ElectronExtensionSystem*>(
       GetInstance()->GetServiceForBrowserContext(context, true));
 }
 
 // static
-AtomExtensionSystemFactory* AtomExtensionSystemFactory::GetInstance() {
-  return base::Singleton<AtomExtensionSystemFactory>::get();
+ElectronExtensionSystemFactory* ElectronExtensionSystemFactory::GetInstance() {
+  return base::Singleton<ElectronExtensionSystemFactory>::get();
 }
 
-AtomExtensionSystemFactory::AtomExtensionSystemFactory()
-    : ExtensionSystemProvider("AtomExtensionSystem",
+ElectronExtensionSystemFactory::ElectronExtensionSystemFactory()
+    : ExtensionSystemProvider("ElectronExtensionSystem",
                               BrowserContextDependencyManager::GetInstance()) {
   DependsOn(ExtensionPrefsFactory::GetInstance());
   DependsOn(ExtensionRegistryFactory::GetInstance());
 }
 
-AtomExtensionSystemFactory::~AtomExtensionSystemFactory() {}
+ElectronExtensionSystemFactory::~ElectronExtensionSystemFactory() {}
 
-KeyedService* AtomExtensionSystemFactory::BuildServiceInstanceFor(
+KeyedService* ElectronExtensionSystemFactory::BuildServiceInstanceFor(
     BrowserContext* context) const {
-  return new AtomExtensionSystem(context);
+  return new ElectronExtensionSystem(context);
 }
 
-BrowserContext* AtomExtensionSystemFactory::GetBrowserContextToUse(
+BrowserContext* ElectronExtensionSystemFactory::GetBrowserContextToUse(
     BrowserContext* context) const {
   // Use a separate instance for incognito.
   return context;
 }
 
-bool AtomExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
+bool ElectronExtensionSystemFactory::ServiceIsCreatedWithBrowserContext()
+    const {
   return true;
 }
 

+ 10 - 10
shell/browser/extensions/atom_extension_system_factory.h → 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<AtomExtensionSystemFactory>;
+  friend struct base::DefaultSingletonTraits<ElectronExtensionSystemFactory>;
 
-  AtomExtensionSystemFactory();
-  ~AtomExtensionSystemFactory() override;
+  ElectronExtensionSystemFactory();
+  ~ElectronExtensionSystemFactory() override;
 
   // BrowserContextKeyedServiceFactory implementation:
   KeyedService* BuildServiceInstanceFor(
@@ -33,9 +33,9 @@ class AtomExtensionSystemFactory : public ExtensionSystemProvider {
       content::BrowserContext* context) const override;
   bool ServiceIsCreatedWithBrowserContext() const override;
 
-  DISALLOW_COPY_AND_ASSIGN(AtomExtensionSystemFactory);
+  DISALLOW_COPY_AND_ASSIGN(ElectronExtensionSystemFactory);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_SYSTEM_FACTORY_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_

+ 6 - 6
shell/browser/extensions/atom_extension_web_contents_observer.cc → 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

+ 12 - 9
shell/browser/extensions/atom_extension_web_contents_observer.h → 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<AtomExtensionWebContentsObserver> {
+      public content::WebContentsUserData<
+          ElectronExtensionWebContentsObserver> {
  public:
-  ~AtomExtensionWebContentsObserver() override;
+  ~ElectronExtensionWebContentsObserver() override;
 
   // Creates and initializes an instance of this class for the given
   // |web_contents|, if it doesn't already exist.
   static void CreateForWebContents(content::WebContents* web_contents);
 
  private:
-  friend class content::WebContentsUserData<AtomExtensionWebContentsObserver>;
+  friend class content::WebContentsUserData<
+      ElectronExtensionWebContentsObserver>;
 
-  explicit AtomExtensionWebContentsObserver(content::WebContents* web_contents);
+  explicit ElectronExtensionWebContentsObserver(
+      content::WebContents* web_contents);
 
   WEB_CONTENTS_USER_DATA_KEY_DECL();
 
-  DISALLOW_COPY_AND_ASSIGN(AtomExtensionWebContentsObserver);
+  DISALLOW_COPY_AND_ASSIGN(ElectronExtensionWebContentsObserver);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSION_WEB_CONTENTS_OBSERVER_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_WEB_CONTENTS_OBSERVER_H_

+ 2 - 2
shell/browser/extensions/electron_extensions_api_client.cc

@@ -6,7 +6,7 @@
 
 #include <memory>
 
-#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
+#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
 #include "shell/browser/extensions/electron_messaging_delegate.h"
 
 namespace extensions {
@@ -22,7 +22,7 @@ MessagingDelegate* ElectronExtensionsAPIClient::GetMessagingDelegate() {
 
 void ElectronExtensionsAPIClient::AttachWebContentsHelpers(
     content::WebContents* web_contents) const {
-  extensions::AtomExtensionWebContentsObserver::CreateForWebContents(
+  extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
       web_contents);
 }
 

+ 58 - 54
shell/browser/extensions/atom_extensions_browser_client.cc → 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 <utility>
 
@@ -30,13 +30,13 @@
 #include "shell/browser/atom_browser_client.h"
 #include "shell/browser/atom_browser_context.h"
 #include "shell/browser/browser.h"
-#include "shell/browser/extensions/api/runtime/atom_runtime_api_delegate.h"
-#include "shell/browser/extensions/atom_extension_host_delegate.h"
-#include "shell/browser/extensions/atom_extension_system_factory.h"
-#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
-#include "shell/browser/extensions/atom_navigation_ui_data.h"
+#include "shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h"
+#include "shell/browser/extensions/electron_extension_host_delegate.h"
+#include "shell/browser/extensions/electron_extension_system_factory.h"
+#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
 #include "shell/browser/extensions/electron_extensions_api_client.h"
 #include "shell/browser/extensions/electron_extensions_browser_api_provider.h"
+#include "shell/browser/extensions/electron_navigation_ui_data.h"
 #include "shell/browser/extensions/electron_process_manager_delegate.h"
 
 using content::BrowserContext;
@@ -44,7 +44,7 @@ using content::BrowserThread;
 
 namespace electron {
 
-AtomExtensionsBrowserClient::AtomExtensionsBrowserClient()
+ElectronExtensionsBrowserClient::ElectronExtensionsBrowserClient()
     : api_client_(new extensions::ElectronExtensionsAPIClient),
       process_manager_delegate_(new extensions::ElectronProcessManagerDelegate),
       extension_cache_(new extensions::NullExtensionCache()) {
@@ -58,19 +58,19 @@ AtomExtensionsBrowserClient::AtomExtensionsBrowserClient()
       std::make_unique<extensions::ElectronExtensionsBrowserAPIProvider>());
 }
 
-AtomExtensionsBrowserClient::~AtomExtensionsBrowserClient() {}
+ElectronExtensionsBrowserClient::~ElectronExtensionsBrowserClient() {}
 
-bool AtomExtensionsBrowserClient::IsShuttingDown() {
+bool ElectronExtensionsBrowserClient::IsShuttingDown() {
   return electron::Browser::Get()->is_shutting_down();
 }
 
-bool AtomExtensionsBrowserClient::AreExtensionsDisabled(
+bool ElectronExtensionsBrowserClient::AreExtensionsDisabled(
     const base::CommandLine& command_line,
     BrowserContext* context) {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
+bool ElectronExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
   auto context_map = AtomBrowserContext::browser_context_map();
   for (auto const& entry : context_map) {
     if (entry.second && entry.second.get() == context)
@@ -79,23 +79,23 @@ bool AtomExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsSameContext(BrowserContext* first,
-                                                BrowserContext* second) {
+bool ElectronExtensionsBrowserClient::IsSameContext(BrowserContext* first,
+                                                    BrowserContext* second) {
   return first == second;
 }
 
-bool AtomExtensionsBrowserClient::HasOffTheRecordContext(
+bool ElectronExtensionsBrowserClient::HasOffTheRecordContext(
     BrowserContext* context) {
   return false;
 }
 
-BrowserContext* AtomExtensionsBrowserClient::GetOffTheRecordContext(
+BrowserContext* ElectronExtensionsBrowserClient::GetOffTheRecordContext(
     BrowserContext* context) {
   // app_shell only supports a single context.
   return nullptr;
 }
 
-BrowserContext* AtomExtensionsBrowserClient::GetOriginalContext(
+BrowserContext* ElectronExtensionsBrowserClient::GetOriginalContext(
     BrowserContext* context) {
   DCHECK(context);
   if (context->IsOffTheRecord()) {
@@ -105,24 +105,24 @@ BrowserContext* AtomExtensionsBrowserClient::GetOriginalContext(
   }
 }
 
-bool AtomExtensionsBrowserClient::IsGuestSession(
+bool ElectronExtensionsBrowserClient::IsGuestSession(
     BrowserContext* context) const {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsExtensionIncognitoEnabled(
+bool ElectronExtensionsBrowserClient::IsExtensionIncognitoEnabled(
     const std::string& extension_id,
     content::BrowserContext* context) const {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::CanExtensionCrossIncognito(
+bool ElectronExtensionsBrowserClient::CanExtensionCrossIncognito(
     const extensions::Extension* extension,
     content::BrowserContext* context) const {
   return false;
 }
 
-base::FilePath AtomExtensionsBrowserClient::GetBundleResourcePath(
+base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath(
     const network::ResourceRequest& request,
     const base::FilePath& extension_resources_path,
     int* resource_id) const {
@@ -130,7 +130,7 @@ base::FilePath AtomExtensionsBrowserClient::GetBundleResourcePath(
   return base::FilePath();
 }
 
-void AtomExtensionsBrowserClient::LoadResourceFromResourceBundle(
+void ElectronExtensionsBrowserClient::LoadResourceFromResourceBundle(
     const network::ResourceRequest& request,
     mojo::PendingReceiver<network::mojom::URLLoader> loader,
     const base::FilePath& resource_relative_path,
@@ -172,7 +172,7 @@ bool AllowCrossRendererResourceLoad(const GURL& url,
 }
 }  // namespace
 
-bool AtomExtensionsBrowserClient::AllowCrossRendererResourceLoad(
+bool ElectronExtensionsBrowserClient::AllowCrossRendererResourceLoad(
     const GURL& url,
     content::ResourceType resource_type,
     ui::PageTransition page_transition,
@@ -192,71 +192,73 @@ bool AtomExtensionsBrowserClient::AllowCrossRendererResourceLoad(
   return false;
 }
 
-PrefService* AtomExtensionsBrowserClient::GetPrefServiceForContext(
+PrefService* ElectronExtensionsBrowserClient::GetPrefServiceForContext(
     BrowserContext* context) {
   return static_cast<AtomBrowserContext*>(context)->prefs();
 }
 
-void AtomExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
+void ElectronExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
     content::BrowserContext* context,
     std::vector<extensions::EarlyExtensionPrefsObserver*>* observers) const {}
 
 extensions::ProcessManagerDelegate*
-AtomExtensionsBrowserClient::GetProcessManagerDelegate() const {
+ElectronExtensionsBrowserClient::GetProcessManagerDelegate() const {
   return process_manager_delegate_.get();
 }
 
-std::unique_ptr<extensions::ExtensionHostDelegate> AtomExtensionsBrowserClient::
+std::unique_ptr<extensions::ExtensionHostDelegate>
+ElectronExtensionsBrowserClient::
     CreateExtensionHostDelegate() {  // TODO(samuelmaddock):
-  return base::WrapUnique(new extensions::AtomExtensionHostDelegate);
+  return base::WrapUnique(new extensions::ElectronExtensionHostDelegate);
 }
 
-bool AtomExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
+bool ElectronExtensionsBrowserClient::DidVersionUpdate(
+    BrowserContext* context) {
   // TODO(jamescook): We might want to tell extensions when app_shell updates.
   return false;
 }
 
-void AtomExtensionsBrowserClient::PermitExternalProtocolHandler() {}
+void ElectronExtensionsBrowserClient::PermitExternalProtocolHandler() {}
 
-bool AtomExtensionsBrowserClient::IsInDemoMode() {
+bool ElectronExtensionsBrowserClient::IsInDemoMode() {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsScreensaverInDemoMode(
+bool ElectronExtensionsBrowserClient::IsScreensaverInDemoMode(
     const std::string& app_id) {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsRunningInForcedAppMode() {
+bool ElectronExtensionsBrowserClient::IsRunningInForcedAppMode() {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsAppModeForcedForApp(
+bool ElectronExtensionsBrowserClient::IsAppModeForcedForApp(
     const extensions::ExtensionId& extension_id) {
   return false;
 }
 
-bool AtomExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
+bool ElectronExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
   return false;
 }
 
 extensions::ExtensionSystemProvider*
-AtomExtensionsBrowserClient::GetExtensionSystemFactory() {
-  return extensions::AtomExtensionSystemFactory::GetInstance();
+ElectronExtensionsBrowserClient::GetExtensionSystemFactory() {
+  return extensions::ElectronExtensionSystemFactory::GetInstance();
 }
 
 std::unique_ptr<extensions::RuntimeAPIDelegate>
-AtomExtensionsBrowserClient::CreateRuntimeAPIDelegate(
+ElectronExtensionsBrowserClient::CreateRuntimeAPIDelegate(
     content::BrowserContext* context) const {
-  return std::make_unique<extensions::AtomRuntimeAPIDelegate>(context);
+  return std::make_unique<extensions::ElectronRuntimeAPIDelegate>(context);
 }
 
 const extensions::ComponentExtensionResourceManager*
-AtomExtensionsBrowserClient::GetComponentExtensionResourceManager() {
+ElectronExtensionsBrowserClient::GetComponentExtensionResourceManager() {
   return NULL;
 }
 
-void AtomExtensionsBrowserClient::BroadcastEventToRenderers(
+void ElectronExtensionsBrowserClient::BroadcastEventToRenderers(
     extensions::events::HistogramValue histogram_value,
     const std::string& event_name,
     std::unique_ptr<base::ListValue> args,
@@ -264,9 +266,10 @@ void AtomExtensionsBrowserClient::BroadcastEventToRenderers(
   if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
     base::PostTask(
         FROM_HERE, {BrowserThread::UI},
-        base::BindOnce(&AtomExtensionsBrowserClient::BroadcastEventToRenderers,
-                       base::Unretained(this), histogram_value, event_name,
-                       std::move(args), dispatch_to_off_the_record_profiles));
+        base::BindOnce(
+            &ElectronExtensionsBrowserClient::BroadcastEventToRenderers,
+            base::Unretained(this), histogram_value, event_name,
+            std::move(args), dispatch_to_off_the_record_profiles));
     return;
   }
 
@@ -281,49 +284,50 @@ void AtomExtensionsBrowserClient::BroadcastEventToRenderers(
   }
 }
 
-extensions::ExtensionCache* AtomExtensionsBrowserClient::GetExtensionCache() {
+extensions::ExtensionCache*
+ElectronExtensionsBrowserClient::GetExtensionCache() {
   return extension_cache_.get();
 }
 
-bool AtomExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
+bool ElectronExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
   return true;
 }
 
-bool AtomExtensionsBrowserClient::IsMinBrowserVersionSupported(
+bool ElectronExtensionsBrowserClient::IsMinBrowserVersionSupported(
     const std::string& min_version) {
   return true;
 }
 
-void AtomExtensionsBrowserClient::SetAPIClientForTest(
+void ElectronExtensionsBrowserClient::SetAPIClientForTest(
     extensions::ExtensionsAPIClient* api_client) {
   api_client_.reset(api_client);
 }
 
 extensions::ExtensionWebContentsObserver*
-AtomExtensionsBrowserClient::GetExtensionWebContentsObserver(
+ElectronExtensionsBrowserClient::GetExtensionWebContentsObserver(
     content::WebContents* web_contents) {
-  return extensions::AtomExtensionWebContentsObserver::FromWebContents(
+  return extensions::ElectronExtensionWebContentsObserver::FromWebContents(
       web_contents);
 }
 
-extensions::KioskDelegate* AtomExtensionsBrowserClient::GetKioskDelegate() {
+extensions::KioskDelegate* ElectronExtensionsBrowserClient::GetKioskDelegate() {
   return nullptr;
 }
 
-bool AtomExtensionsBrowserClient::IsLockScreenContext(
+bool ElectronExtensionsBrowserClient::IsLockScreenContext(
     content::BrowserContext* context) {
   return false;
 }
 
-std::string AtomExtensionsBrowserClient::GetApplicationLocale() {
+std::string ElectronExtensionsBrowserClient::GetApplicationLocale() {
   return AtomBrowserClient::Get()->GetApplicationLocale();
 }
 
-std::string AtomExtensionsBrowserClient::GetUserAgent() const {
+std::string ElectronExtensionsBrowserClient::GetUserAgent() const {
   return AtomBrowserClient::Get()->GetUserAgent();
 }
 
-void AtomExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
+void ElectronExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
     service_manager::BinderMapWithContext<content::RenderFrameHost*>* map,
     content::RenderFrameHost* render_frame_host,
     const extensions::Extension* extension) const {}

+ 8 - 7
shell/browser/extensions/atom_extensions_browser_client.h → 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 <memory>
 #include <string>
@@ -31,10 +31,11 @@ namespace electron {
 // with no related incognito context.
 // Must be initialized via InitWithBrowserContext() once the BrowserContext is
 // created.
-class AtomExtensionsBrowserClient : public extensions::ExtensionsBrowserClient {
+class ElectronExtensionsBrowserClient
+    : public extensions::ExtensionsBrowserClient {
  public:
-  AtomExtensionsBrowserClient();
-  ~AtomExtensionsBrowserClient() override;
+  ElectronExtensionsBrowserClient();
+  ~ElectronExtensionsBrowserClient() override;
 
   // ExtensionsBrowserClient overrides:
   bool IsShuttingDown() override;
@@ -137,9 +138,9 @@ class AtomExtensionsBrowserClient : public extensions::ExtensionsBrowserClient {
   // The extension cache used for download and installation.
   std::unique_ptr<extensions::ExtensionCache> extension_cache_;
 
-  DISALLOW_COPY_AND_ASSIGN(AtomExtensionsBrowserClient);
+  DISALLOW_COPY_AND_ASSIGN(ElectronExtensionsBrowserClient);
 };
 
 }  // namespace electron
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_EXTENSIONS_BROWSER_CLIENT_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSIONS_BROWSER_CLIENT_H_

+ 8 - 8
shell/browser/extensions/atom_navigation_ui_data.cc → 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 <utility>
 
@@ -11,20 +11,20 @@
 
 namespace extensions {
 
-AtomNavigationUIData::AtomNavigationUIData() {}
+ElectronNavigationUIData::ElectronNavigationUIData() {}
 
-AtomNavigationUIData::AtomNavigationUIData(
+ElectronNavigationUIData::ElectronNavigationUIData(
     content::NavigationHandle* navigation_handle) {
   extension_data_ = std::make_unique<ExtensionNavigationUIData>(
       navigation_handle, extension_misc::kUnknownTabId,
       extension_misc::kUnknownWindowId);
 }
 
-AtomNavigationUIData::~AtomNavigationUIData() {}
+ElectronNavigationUIData::~ElectronNavigationUIData() {}
 
-std::unique_ptr<content::NavigationUIData> AtomNavigationUIData::Clone() {
-  std::unique_ptr<AtomNavigationUIData> copy =
-      std::make_unique<AtomNavigationUIData>();
+std::unique_ptr<content::NavigationUIData> ElectronNavigationUIData::Clone() {
+  std::unique_ptr<ElectronNavigationUIData> copy =
+      std::make_unique<ElectronNavigationUIData>();
 
   if (extension_data_)
     copy->SetExtensionNavigationUIData(extension_data_->DeepCopy());
@@ -32,7 +32,7 @@ std::unique_ptr<content::NavigationUIData> AtomNavigationUIData::Clone() {
   return std::move(copy);
 }
 
-void AtomNavigationUIData::SetExtensionNavigationUIData(
+void ElectronNavigationUIData::SetExtensionNavigationUIData(
     std::unique_ptr<ExtensionNavigationUIData> extension_data) {
   extension_data_ = std::move(extension_data);
 }

+ 9 - 8
shell/browser/extensions/atom_navigation_ui_data.h → 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 <memory>
 
@@ -18,11 +18,12 @@ namespace extensions {
 // beginning of each navigation. The class is instantiated on the UI thread,
 // then a copy created using Clone is passed to the content::ResourceRequestInfo
 // on the IO thread.
-class AtomNavigationUIData : public content::NavigationUIData {
+class ElectronNavigationUIData : public content::NavigationUIData {
  public:
-  AtomNavigationUIData();
-  explicit AtomNavigationUIData(content::NavigationHandle* navigation_handle);
-  ~AtomNavigationUIData() override;
+  ElectronNavigationUIData();
+  explicit ElectronNavigationUIData(
+      content::NavigationHandle* navigation_handle);
+  ~ElectronNavigationUIData() override;
 
   // Creates a new ChromeNavigationUIData that is a deep copy of the original.
   // Any changes to the original after the clone is created will not be
@@ -40,9 +41,9 @@ class AtomNavigationUIData : public content::NavigationUIData {
   // Manages the lifetime of optional ExtensionNavigationUIData information.
   std::unique_ptr<ExtensionNavigationUIData> extension_data_;
 
-  DISALLOW_COPY_AND_ASSIGN(AtomNavigationUIData);
+  DISALLOW_COPY_AND_ASSIGN(ElectronNavigationUIData);
 };
 
 }  // namespace extensions
 
-#endif  // SHELL_BROWSER_EXTENSIONS_ATOM_NAVIGATION_UI_DATA_H_
+#endif  // SHELL_BROWSER_EXTENSIONS_ELECTRON_NAVIGATION_UI_DATA_H_

+ 9 - 11
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<NSVisualEffectMaterial>(7);
     } else if (type == "medium-light") {
       // NSVisualEffectMaterialMediumLight
-      EmitDeprecationWarning(
-          env, "NSVisualEffectMaterialMediumLight" + dep_warn, "electron");
+      EmitWarning(env, "NSVisualEffectMaterialMediumLight" + dep_warn,
+                  "electron");
       vibrancyType = static_cast<NSVisualEffectMaterial>(8);
     } else if (type == "ultra-dark") {
       // NSVisualEffectMaterialUltraDark
-      EmitDeprecationWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn,
-                             "electron");
+      EmitWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn,
+                  "electron");
       vibrancyType = static_cast<NSVisualEffectMaterial>(9);
     }
   }

+ 0 - 20
shell/common/deprecate_util.h

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

+ 13 - 12
shell/common/extensions/atom_extensions_api_provider.cc → 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 <memory>
 #include <string>
@@ -74,50 +74,51 @@ base::span<const Alias> 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(

+ 7 - 7
shell/common/extensions/atom_extensions_api_provider.h → 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 <string>
 
@@ -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_

+ 24 - 23
shell/common/extensions/atom_extensions_client.cc → 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 <memory>
 #include <string>
@@ -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<AtomPermissionMessageProvider>::DestructorAtExit
+base::LazyInstance<ElectronPermissionMessageProvider>::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<extensions::CoreExtensionsAPIProvider>());
-  AddAPIProvider(std::make_unique<AtomExtensionsAPIProvider>());
+  AddAPIProvider(std::make_unique<ElectronExtensionsAPIProvider>());
 }
 
-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;

+ 7 - 7
shell/common/extensions/atom_extensions_client.h → 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 <string>
 
@@ -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_

+ 0 - 1
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"

+ 4 - 4
shell/common/deprecate_util.cc → 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<void(base::StringPiece, base::StringPiece,

+ 20 - 0
shell/common/process_util.h

@@ -0,0 +1,20 @@
+// 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_PROCESS_UTIL_H_
+#define SHELL_COMMON_PROCESS_UTIL_H_
+
+#include <string>
+
+#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_

+ 13 - 13
shell/renderer/extensions/atom_extensions_renderer_client.cc → 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<extensions::Dispatcher>(
           std::make_unique<ElectronExtensionsDispatcherDelegate>())) {
   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);
 }

+ 7 - 7
shell/renderer/extensions/atom_extensions_renderer_client.h → 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 <memory>
 
@@ -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<extensions::Dispatcher> 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_

+ 4 - 4
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<v8::Value> RendererClientBase::RunScript(
 
 #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
 extensions::ExtensionsClient* RendererClientBase::CreateExtensionsClient() {
-  return new AtomExtensionsClient;
+  return new ElectronExtensionsClient;
 }
 #endif
 

+ 2 - 2
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::ExtensionsClient> extensions_client_;
-  std::unique_ptr<AtomExtensionsRendererClient> extensions_renderer_client_;
+  std::unique_ptr<ElectronExtensionsRendererClient> extensions_renderer_client_;
 #endif
 
 #if defined(WIDEVINE_CDM_AVAILABLE)

+ 0 - 195
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<any> = 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', () => {

+ 0 - 149
spec-main/content-script-spec.ts

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

+ 341 - 2
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<any> = 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 }')
+      })
+    })
+  })
 })

+ 2 - 0
spec-main/fixtures/devtools-extensions/foo/devtools.js

@@ -0,0 +1,2 @@
+/* global chrome */
+chrome.devtools.panels.create('Foo', 'foo.png', 'index.html')

+ 1 - 3
spec-main/fixtures/devtools-extensions/foo/foo.html

@@ -3,8 +3,6 @@
   <head>
     <meta charset="utf-8">
     <title>foo</title>
-    <script>
-      chrome.devtools.panels.create('Foo', 'foo.png', 'index.html')
-    </script>
+    <script src="devtools.js"></script>
   </head>
 </html>

+ 1 - 78
spec-main/fixtures/devtools-extensions/foo/index.html

@@ -3,84 +3,7 @@
   <head>
     <meta charset="utf-8">
     <title></title>
-    <script>
-      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
-      ) {
-        var message = JSON.stringify({
-          runtimeId: chrome.runtime.id,
-          tabId: chrome.devtools.inspectedWindow.tabId,
-          i18nString: chrome.i18n.getMessage('foo', ['bar', 'baz']),
-          storageItems: {
-            local: {
-              set: localForSet,
-              remove: localForRemove,
-              clear: localForClear
-            },
-            sync: {
-              set: syncForSet,
-              remove: syncForRemove,
-              clear: syncForClear
-            }
-          }
-        })
-
-        var sendMessage = `require('electron').ipcRenderer.send('answer', ${message})`
-        window.chrome.devtools.inspectedWindow.eval(sendMessage, function () {})
-      })
-    </script>
+    <script src="panel.js"></script>
   </head>
   <body>
     a custom devtools extension

+ 4 - 0
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"

+ 77 - 0
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 () {})
+})

+ 1 - 1
spec-main/fixtures/pages/webview-devtools.html

@@ -4,7 +4,7 @@
     <meta charset="utf-8">
   </head>
   <body>
-    <webview nodeintegration src="./a.html"></webview>
+    <webview nodeintegration src="about:blank"></webview>
     <script>
         var wv = document.querySelector('webview')
         wv.addEventListener('dom-ready', () => {

+ 5 - 3
spec-main/webview-spec.ts

@@ -162,10 +162,12 @@ describe('<webview> tag', function () {
     BrowserWindow.removeDevToolsExtension('foo')
 
     const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
-    BrowserWindow.addDevToolsExtension(extensionPath)
+    await BrowserWindow.addDevToolsExtension(extensionPath)
 
     w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'webview-devtools.html'))
+    let childWebContentsId = 0
     app.once('web-contents-created', (e, webContents) => {
+      childWebContentsId = webContents.id
       webContents.on('devtools-opened', function () {
         const showPanelIntervalId = setInterval(function () {
           if (!webContents.isDestroyed() && webContents.devToolsWebContents) {
@@ -181,8 +183,8 @@ describe('<webview> tag', function () {
     })
 
     const [, { runtimeId, tabId }] = await emittedOnce(ipcMain, 'answer')
-    expect(runtimeId).to.equal('foo')
-    expect(tabId).to.be.not.equal(w.webContents.id)
+    expect(runtimeId).to.match(/^[a-z]{32}$/)
+    expect(tabId).to.equal(childWebContentsId)
   })
 
   describe('zoom behavior', () => {