From 660e56620130ba96a729d5630f5ee3e87e2168e0 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 16 Sep 2019 14:23:13 -0700 Subject: [PATCH] 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. --- docs/api/native-theme.md | 2 +- filenames.auto.gni | 5 +---- filenames.gni | 6 +++--- lib/browser/api/module-list.ts | 1 + lib/{common => browser}/api/native-theme.ts | 0 lib/common/api/module-list.ts | 1 - shell/{common => browser}/api/atom_api_native_theme.cc | 2 +- shell/{common => browser}/api/atom_api_native_theme.h | 6 +++--- shell/{common => browser}/api/atom_api_native_theme_mac.mm | 2 +- 9 files changed, 11 insertions(+), 14 deletions(-) rename lib/{common => browser}/api/native-theme.ts (100%) rename shell/{common => browser}/api/atom_api_native_theme.cc (98%) rename shell/{common => browser}/api/atom_api_native_theme.h (91%) rename shell/{common => browser}/api/atom_api_native_theme_mac.mm (95%) diff --git a/docs/api/native-theme.md b/docs/api/native-theme.md index c72e96e12559..2e89ff4d9ee5 100644 --- a/docs/api/native-theme.md +++ b/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 diff --git a/filenames.auto.gni b/filenames.auto.gni index 28b36e7288d5..536a9bd270ec 100644 --- a/filenames.auto.gni +++ b/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", diff --git a/filenames.gni b/filenames.gni index 2af8f748833a..0bbc17f3b671 100644 --- a/filenames.gni +++ b/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", diff --git a/lib/browser/api/module-list.ts b/lib/browser/api/module-list.ts index c6d45853ed5f..dbcba8a9f0be 100644 --- a/lib/browser/api/module-list.ts +++ b/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') }, diff --git a/lib/common/api/native-theme.ts b/lib/browser/api/native-theme.ts similarity index 100% rename from lib/common/api/native-theme.ts rename to lib/browser/api/native-theme.ts diff --git a/lib/common/api/module-list.ts b/lib/common/api/module-list.ts index 4a4009a6d7c2..b329e7e469ee 100644 --- a/lib/common/api/module-list.ts +++ b/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 } diff --git a/shell/common/api/atom_api_native_theme.cc b/shell/browser/api/atom_api_native_theme.cc similarity index 98% rename from shell/common/api/atom_api_native_theme.cc rename to shell/browser/api/atom_api_native_theme.cc index af7db95e484d..9bb009e92e55 100644 --- a/shell/common/api/atom_api_native_theme.cc +++ b/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 diff --git a/shell/common/api/atom_api_native_theme.h b/shell/browser/api/atom_api_native_theme.h similarity index 91% rename from shell/common/api/atom_api_native_theme.h rename to shell/browser/api/atom_api_native_theme.h index ff86b07000fa..28ccea0a622d 100644 --- a/shell/common/api/atom_api_native_theme.h +++ b/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 { } // namespace mate -#endif // SHELL_COMMON_API_ATOM_API_NATIVE_THEME_H_ +#endif // SHELL_BROWSER_API_ATOM_API_NATIVE_THEME_H_ diff --git a/shell/common/api/atom_api_native_theme_mac.mm b/shell/browser/api/atom_api_native_theme_mac.mm similarity index 95% rename from shell/common/api/atom_api_native_theme_mac.mm rename to shell/browser/api/atom_api_native_theme_mac.mm index 47350586cae6..04e25a2ef4ad 100644 --- a/shell/common/api/atom_api_native_theme_mac.mm +++ b/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"