Browse Source

fix: don't expose nativeTheme in the renderer process (#20139)

Exposing these in the renderer didn't make sense as they weren't backed
by the same instance / value store.  This API should be browser only
especially now that we have nativeTheme.themeSource.  Exposing in
//common was a mistake from the beginning.
Samuel Attard 5 years ago
parent
commit
660e566201

+ 1 - 1
docs/api/native-theme.md

@@ -2,7 +2,7 @@
 
 > Read and respond to changes in Chromium's native color theme.
 
-Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
+Process: [Main](../glossary.md#main-process)
 
 ## Events
 

+ 1 - 4
filenames.auto.gni

@@ -132,7 +132,6 @@ auto_filenames = {
     "lib/common/api/deprecate.ts",
     "lib/common/api/module-list.ts",
     "lib/common/api/native-image.js",
-    "lib/common/api/native-theme.ts",
     "lib/common/api/shell.js",
     "lib/common/buffer-utils.ts",
     "lib/common/clipboard-utils.ts",
@@ -224,6 +223,7 @@ auto_filenames = {
     "lib/browser/api/menu-utils.js",
     "lib/browser/api/menu.js",
     "lib/browser/api/module-list.ts",
+    "lib/browser/api/native-theme.ts",
     "lib/browser/api/net-log.js",
     "lib/browser/api/net.js",
     "lib/browser/api/notification.js",
@@ -265,7 +265,6 @@ auto_filenames = {
     "lib/common/api/deprecate.ts",
     "lib/common/api/module-list.ts",
     "lib/common/api/native-image.js",
-    "lib/common/api/native-theme.ts",
     "lib/common/api/shell.js",
     "lib/common/buffer-utils.ts",
     "lib/common/clipboard-utils.ts",
@@ -291,7 +290,6 @@ auto_filenames = {
     "lib/common/api/deprecate.ts",
     "lib/common/api/module-list.ts",
     "lib/common/api/native-image.js",
-    "lib/common/api/native-theme.ts",
     "lib/common/api/shell.js",
     "lib/common/buffer-utils.ts",
     "lib/common/clipboard-utils.ts",
@@ -342,7 +340,6 @@ auto_filenames = {
     "lib/common/api/deprecate.ts",
     "lib/common/api/module-list.ts",
     "lib/common/api/native-image.js",
-    "lib/common/api/native-theme.ts",
     "lib/common/api/shell.js",
     "lib/common/buffer-utils.ts",
     "lib/common/clipboard-utils.ts",

+ 3 - 3
filenames.gni

@@ -65,6 +65,9 @@ filenames = {
     "shell/browser/api/atom_api_menu_mac.mm",
     "shell/browser/api/atom_api_menu_views.cc",
     "shell/browser/api/atom_api_menu_views.h",
+    "shell/browser/api/atom_api_native_theme.cc",
+    "shell/browser/api/atom_api_native_theme.h",
+    "shell/browser/api/atom_api_native_theme_mac.mm",
     "shell/browser/api/atom_api_net.cc",
     "shell/browser/api/atom_api_net.h",
     "shell/browser/api/atom_api_net_log.cc",
@@ -427,9 +430,6 @@ filenames = {
     "shell/common/api/atom_api_native_image.cc",
     "shell/common/api/atom_api_native_image.h",
     "shell/common/api/atom_api_native_image_mac.mm",
-    "shell/common/api/atom_api_native_theme.cc",
-    "shell/common/api/atom_api_native_theme.h",
-    "shell/common/api/atom_api_native_theme_mac.mm",
     "shell/common/api/atom_api_shell.cc",
     "shell/common/api/atom_api_v8_util.cc",
     "shell/common/api/electron_bindings.cc",

+ 1 - 0
lib/browser/api/module-list.ts

@@ -16,6 +16,7 @@ export const browserModuleList: ElectronInternal.ModuleEntry[] = [
   { name: 'inAppPurchase', loader: () => require('./in-app-purchase') },
   { name: 'Menu', loader: () => require('./menu') },
   { name: 'MenuItem', loader: () => require('./menu-item') },
+  { name: 'nativeTheme', loader: () => require('./native-theme') },
   { name: 'net', loader: () => require('./net') },
   { name: 'netLog', loader: () => require('./net-log') },
   { name: 'Notification', loader: () => require('./notification') },

+ 0 - 0
lib/common/api/native-theme.ts → lib/browser/api/native-theme.ts


+ 0 - 1
lib/common/api/module-list.ts

@@ -2,7 +2,6 @@
 export const commonModuleList: ElectronInternal.ModuleEntry[] = [
   { name: 'clipboard', loader: () => require('./clipboard') },
   { name: 'nativeImage', loader: () => require('./native-image') },
-  { name: 'nativeTheme', loader: () => require('./native-theme') },
   { name: 'shell', loader: () => require('./shell') },
   // The internal modules, invisible unless you know their names.
   { name: 'deprecate', loader: () => require('./deprecate'), private: true }

+ 1 - 1
shell/common/api/atom_api_native_theme.cc → shell/browser/api/atom_api_native_theme.cc

@@ -2,7 +2,7 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#include "shell/common/api/atom_api_native_theme.h"
+#include "shell/browser/api/atom_api_native_theme.h"
 
 #include <string>
 

+ 3 - 3
shell/common/api/atom_api_native_theme.h → shell/browser/api/atom_api_native_theme.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_COMMON_API_ATOM_API_NATIVE_THEME_H_
-#define SHELL_COMMON_API_ATOM_API_NATIVE_THEME_H_
+#ifndef SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
+#define SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_
 
 #include "native_mate/handle.h"
 #include "shell/browser/api/event_emitter.h"
@@ -62,4 +62,4 @@ struct Converter<ui::NativeTheme::ThemeSource> {
 
 }  // namespace mate
 
-#endif  // SHELL_COMMON_API_ATOM_API_NATIVE_THEME_H_
+#endif  // SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_

+ 1 - 1
shell/common/api/atom_api_native_theme_mac.mm → shell/browser/api/atom_api_native_theme_mac.mm

@@ -2,7 +2,7 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
-#include "shell/common/api/atom_api_native_theme.h"
+#include "shell/browser/api/atom_api_native_theme.h"
 
 #include "base/mac/sdk_forward_declarations.h"
 #include "shell/browser/mac/atom_application.h"