fix: app.setLoginItemSettings
error getting swallowed by gin conversion (#41667)
* fix: errors getting swallowed by gin conversion Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * fix: Windows build Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * test: re-enable disabled test Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
21341a56a7
commit
0f1e52fafe
11 changed files with 211 additions and 154 deletions
|
@ -30,12 +30,14 @@
|
|||
#include "shell/browser/api/electron_api_app.h"
|
||||
#include "shell/browser/badging/badge_manager.h"
|
||||
#include "shell/browser/electron_browser_main_parts.h"
|
||||
#include "shell/browser/javascript_environment.h"
|
||||
#include "shell/browser/ui/message_box.h"
|
||||
#include "shell/browser/ui/win/jump_list.h"
|
||||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/login_item_settings_converter.h"
|
||||
#include "shell/common/gin_helper/arguments.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/skia_util.h"
|
||||
|
@ -154,12 +156,12 @@ bool FormatCommandLineString(std::wstring* exe,
|
|||
// a list of launchItem with matching paths to our application.
|
||||
// if a launchItem with a matching path also has a matching entry within the
|
||||
// startup_approved_key_path, set executable_will_launch_at_login to be `true`
|
||||
std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
|
||||
std::vector<LaunchItem> GetLoginItemSettingsHelper(
|
||||
base::win::RegistryValueIterator* it,
|
||||
boolean* executable_will_launch_at_login,
|
||||
std::wstring scope,
|
||||
const Browser::LoginItemSettings& options) {
|
||||
std::vector<Browser::LaunchItem> launch_items;
|
||||
const LoginItemSettings& options) {
|
||||
std::vector<LaunchItem> launch_items;
|
||||
|
||||
base::FilePath lookup_exe_path;
|
||||
if (options.path.empty()) {
|
||||
|
@ -183,7 +185,7 @@ std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
|
|||
|
||||
// add launch item to vector if it has a matching path (case-insensitive)
|
||||
if (exe_match) {
|
||||
Browser::LaunchItem launch_item;
|
||||
LaunchItem launch_item;
|
||||
launch_item.name = it->Name();
|
||||
launch_item.path = registry_launch_path.value();
|
||||
launch_item.args = registry_launch_cmd.GetArgs();
|
||||
|
@ -656,7 +658,7 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
|||
}
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
v8::Local<v8::Value> Browser::GetLoginItemSettings(
|
||||
const LoginItemSettings& options) {
|
||||
LoginItemSettings settings;
|
||||
std::wstring keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
|
@ -675,7 +677,7 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
|||
// if there exists a launch entry with property enabled=='true',
|
||||
// set executable_will_launch_at_login to 'true'.
|
||||
boolean executable_will_launch_at_login = false;
|
||||
std::vector<Browser::LaunchItem> launch_items;
|
||||
std::vector<LaunchItem> launch_items;
|
||||
base::win::RegistryValueIterator hkcu_iterator(HKEY_CURRENT_USER,
|
||||
keyPath.c_str());
|
||||
base::win::RegistryValueIterator hklm_iterator(HKEY_LOCAL_MACHINE,
|
||||
|
@ -683,16 +685,14 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
|||
|
||||
launch_items = GetLoginItemSettingsHelper(
|
||||
&hkcu_iterator, &executable_will_launch_at_login, L"user", options);
|
||||
std::vector<Browser::LaunchItem> launch_items_hklm =
|
||||
GetLoginItemSettingsHelper(&hklm_iterator,
|
||||
&executable_will_launch_at_login, L"machine",
|
||||
options);
|
||||
std::vector<LaunchItem> launch_items_hklm = GetLoginItemSettingsHelper(
|
||||
&hklm_iterator, &executable_will_launch_at_login, L"machine", options);
|
||||
launch_items.insert(launch_items.end(), launch_items_hklm.begin(),
|
||||
launch_items_hklm.end());
|
||||
|
||||
settings.executable_will_launch_at_login = executable_will_launch_at_login;
|
||||
settings.launch_items = launch_items;
|
||||
return settings;
|
||||
return gin::ConvertToV8(JavascriptEnvironment::GetIsolate(), settings);
|
||||
}
|
||||
|
||||
PCWSTR Browser::GetAppUserModelID() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue