chore: modernize ListValue usage in dict_util.mm and related files (#34661)
* chore: modernize ListValue usage in dict_util.mm and related files * use base::Value::{Dict,List} instead of raw base::Value * fix compile * fix build * fix build again
This commit is contained in:
parent
cd19a741b1
commit
11924bdbb2
14 changed files with 106 additions and 107 deletions
|
@ -706,13 +706,13 @@ void App::OnWillFinishLaunching() {
|
||||||
Emit("will-finish-launching");
|
Emit("will-finish-launching");
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
|
void App::OnFinishLaunching(base::Value::Dict launch_info) {
|
||||||
#if BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(IS_LINUX)
|
||||||
// Set the application name for audio streams shown in external
|
// Set the application name for audio streams shown in external
|
||||||
// applications. Only affects pulseaudio currently.
|
// applications. Only affects pulseaudio currently.
|
||||||
media::AudioManager::SetGlobalAppName(Browser::Get()->GetName());
|
media::AudioManager::SetGlobalAppName(Browser::Get()->GetName());
|
||||||
#endif
|
#endif
|
||||||
Emit("ready", launch_info);
|
Emit("ready", base::Value(std::move(launch_info)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnPreMainMessageLoopRun() {
|
void App::OnPreMainMessageLoopRun() {
|
||||||
|
@ -756,22 +756,23 @@ void App::OnDidFailToContinueUserActivity(const std::string& type,
|
||||||
|
|
||||||
void App::OnContinueUserActivity(bool* prevent_default,
|
void App::OnContinueUserActivity(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info,
|
base::Value::Dict user_info,
|
||||||
const base::DictionaryValue& details) {
|
base::Value::Dict details) {
|
||||||
if (Emit("continue-activity", type, user_info, details)) {
|
if (Emit("continue-activity", type, base::Value(std::move(user_info)),
|
||||||
|
base::Value(std::move(details)))) {
|
||||||
*prevent_default = true;
|
*prevent_default = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnUserActivityWasContinued(const std::string& type,
|
void App::OnUserActivityWasContinued(const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {
|
base::Value::Dict user_info) {
|
||||||
Emit("activity-was-continued", type, user_info);
|
Emit("activity-was-continued", type, base::Value(std::move(user_info)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnUpdateUserActivityState(bool* prevent_default,
|
void App::OnUpdateUserActivityState(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {
|
base::Value::Dict user_info) {
|
||||||
if (Emit("update-activity-state", type, user_info)) {
|
if (Emit("update-activity-state", type, base::Value(std::move(user_info)))) {
|
||||||
*prevent_default = true;
|
*prevent_default = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class App : public ElectronBrowserClient::Delegate,
|
||||||
void OnOpenURL(const std::string& url) override;
|
void OnOpenURL(const std::string& url) override;
|
||||||
void OnActivate(bool has_visible_windows) override;
|
void OnActivate(bool has_visible_windows) override;
|
||||||
void OnWillFinishLaunching() override;
|
void OnWillFinishLaunching() override;
|
||||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
void OnFinishLaunching(base::Value::Dict launch_info) override;
|
||||||
void OnAccessibilitySupportChanged() override;
|
void OnAccessibilitySupportChanged() override;
|
||||||
void OnPreMainMessageLoopRun() override;
|
void OnPreMainMessageLoopRun() override;
|
||||||
void OnPreCreateThreads() override;
|
void OnPreCreateThreads() override;
|
||||||
|
@ -107,15 +107,13 @@ class App : public ElectronBrowserClient::Delegate,
|
||||||
const std::string& error) override;
|
const std::string& error) override;
|
||||||
void OnContinueUserActivity(bool* prevent_default,
|
void OnContinueUserActivity(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info,
|
base::Value::Dict user_info,
|
||||||
const base::DictionaryValue& details) override;
|
base::Value::Dict details) override;
|
||||||
void OnUserActivityWasContinued(
|
void OnUserActivityWasContinued(const std::string& type,
|
||||||
const std::string& type,
|
base::Value::Dict user_info) override;
|
||||||
const base::DictionaryValue& user_info) override;
|
void OnUpdateUserActivityState(bool* prevent_default,
|
||||||
void OnUpdateUserActivityState(
|
const std::string& type,
|
||||||
bool* prevent_default,
|
base::Value::Dict user_info) override;
|
||||||
const std::string& type,
|
|
||||||
const base::DictionaryValue& user_info) override;
|
|
||||||
void OnNewWindowForTab() override;
|
void OnNewWindowForTab() override;
|
||||||
void OnDidBecomeActive() override;
|
void OnDidBecomeActive() override;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,11 +67,11 @@ class SystemPreferences
|
||||||
void OnSysColorChange() override;
|
void OnSysColorChange() override;
|
||||||
|
|
||||||
// BrowserObserver:
|
// BrowserObserver:
|
||||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
void OnFinishLaunching(base::Value::Dict launch_info) override;
|
||||||
|
|
||||||
#elif BUILDFLAG(IS_MAC)
|
#elif BUILDFLAG(IS_MAC)
|
||||||
using NotificationCallback = base::RepeatingCallback<
|
using NotificationCallback = base::RepeatingCallback<
|
||||||
void(const std::string&, base::DictionaryValue, const std::string&)>;
|
void(const std::string&, base::Value, const std::string&)>;
|
||||||
|
|
||||||
void PostNotification(const std::string& name,
|
void PostNotification(const std::string& name,
|
||||||
base::DictionaryValue user_info,
|
base::DictionaryValue user_info,
|
||||||
|
|
|
@ -147,10 +147,11 @@ void SystemPreferences::PostNotification(const std::string& name,
|
||||||
|
|
||||||
NSDistributedNotificationCenter* center =
|
NSDistributedNotificationCenter* center =
|
||||||
[NSDistributedNotificationCenter defaultCenter];
|
[NSDistributedNotificationCenter defaultCenter];
|
||||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
[center
|
||||||
object:nil
|
postNotificationName:base::SysUTF8ToNSString(name)
|
||||||
userInfo:DictionaryValueToNSDictionary(user_info)
|
object:nil
|
||||||
deliverImmediately:immediate];
|
userInfo:DictionaryValueToNSDictionary(user_info.GetDict())
|
||||||
|
deliverImmediately:immediate];
|
||||||
}
|
}
|
||||||
|
|
||||||
int SystemPreferences::SubscribeNotification(
|
int SystemPreferences::SubscribeNotification(
|
||||||
|
@ -169,9 +170,10 @@ void SystemPreferences::UnsubscribeNotification(int request_id) {
|
||||||
void SystemPreferences::PostLocalNotification(const std::string& name,
|
void SystemPreferences::PostLocalNotification(const std::string& name,
|
||||||
base::DictionaryValue user_info) {
|
base::DictionaryValue user_info) {
|
||||||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
||||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
[center
|
||||||
object:nil
|
postNotificationName:base::SysUTF8ToNSString(name)
|
||||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
object:nil
|
||||||
|
userInfo:DictionaryValueToNSDictionary(user_info.GetDict())];
|
||||||
}
|
}
|
||||||
|
|
||||||
int SystemPreferences::SubscribeLocalNotification(
|
int SystemPreferences::SubscribeLocalNotification(
|
||||||
|
@ -191,9 +193,10 @@ void SystemPreferences::PostWorkspaceNotification(
|
||||||
base::DictionaryValue user_info) {
|
base::DictionaryValue user_info) {
|
||||||
NSNotificationCenter* center =
|
NSNotificationCenter* center =
|
||||||
[[NSWorkspace sharedWorkspace] notificationCenter];
|
[[NSWorkspace sharedWorkspace] notificationCenter];
|
||||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
[center
|
||||||
object:nil
|
postNotificationName:base::SysUTF8ToNSString(name)
|
||||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
object:nil
|
||||||
|
userInfo:DictionaryValueToNSDictionary(user_info.GetDict())];
|
||||||
}
|
}
|
||||||
|
|
||||||
int SystemPreferences::SubscribeWorkspaceNotification(
|
int SystemPreferences::SubscribeWorkspaceNotification(
|
||||||
|
@ -240,7 +243,7 @@ int SystemPreferences::DoSubscribeNotification(
|
||||||
if (notification.userInfo) {
|
if (notification.userInfo) {
|
||||||
copied_callback.Run(
|
copied_callback.Run(
|
||||||
base::SysNSStringToUTF8(notification.name),
|
base::SysNSStringToUTF8(notification.name),
|
||||||
NSDictionaryToDictionaryValue(notification.userInfo),
|
base::Value(NSDictionaryToValue(notification.userInfo)),
|
||||||
object);
|
object);
|
||||||
} else {
|
} else {
|
||||||
copied_callback.Run(
|
copied_callback.Run(
|
||||||
|
@ -282,11 +285,12 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
||||||
return gin::ConvertToV8(isolate,
|
return gin::ConvertToV8(isolate,
|
||||||
net::GURLWithNSURL([defaults URLForKey:key]));
|
net::GURLWithNSURL([defaults URLForKey:key]));
|
||||||
} else if (type == "array") {
|
} else if (type == "array") {
|
||||||
return gin::ConvertToV8(isolate,
|
return gin::ConvertToV8(
|
||||||
NSArrayToListValue([defaults arrayForKey:key]));
|
isolate, base::Value(NSArrayToValue([defaults arrayForKey:key])));
|
||||||
} else if (type == "dictionary") {
|
} else if (type == "dictionary") {
|
||||||
return gin::ConvertToV8(isolate, NSDictionaryToDictionaryValue(
|
return gin::ConvertToV8(
|
||||||
[defaults dictionaryForKey:key]));
|
isolate,
|
||||||
|
base::Value(NSDictionaryToValue([defaults dictionaryForKey:key])));
|
||||||
} else {
|
} else {
|
||||||
return v8::Undefined(isolate);
|
return v8::Undefined(isolate);
|
||||||
}
|
}
|
||||||
|
@ -299,7 +303,7 @@ void SystemPreferences::RegisterDefaults(gin::Arguments* args) {
|
||||||
args->ThrowError();
|
args->ThrowError();
|
||||||
} else {
|
} else {
|
||||||
@try {
|
@try {
|
||||||
NSDictionary* dict = DictionaryValueToNSDictionary(value);
|
NSDictionary* dict = DictionaryValueToNSDictionary(value.GetDict());
|
||||||
for (id key in dict) {
|
for (id key in dict) {
|
||||||
id value = [dict objectForKey:key];
|
id value = [dict objectForKey:key];
|
||||||
if ([value isKindOfClass:[NSNull class]] || value == nil) {
|
if ([value isKindOfClass:[NSNull class]] || value == nil) {
|
||||||
|
@ -359,17 +363,17 @@ void SystemPreferences::SetUserDefault(const std::string& name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == "array") {
|
} else if (type == "array") {
|
||||||
base::ListValue value;
|
base::Value value;
|
||||||
if (args->GetNext(&value)) {
|
if (args->GetNext(&value) && value.is_list()) {
|
||||||
if (NSArray* array = ListValueToNSArray(value)) {
|
if (NSArray* array = ListValueToNSArray(value.GetList())) {
|
||||||
[defaults setObject:array forKey:key];
|
[defaults setObject:array forKey:key];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == "dictionary") {
|
} else if (type == "dictionary") {
|
||||||
base::DictionaryValue value;
|
base::Value value;
|
||||||
if (args->GetNext(&value)) {
|
if (args->GetNext(&value) && value.is_dict()) {
|
||||||
if (NSDictionary* dict = DictionaryValueToNSDictionary(value)) {
|
if (NSDictionary* dict = DictionaryValueToNSDictionary(value.GetDict())) {
|
||||||
[defaults setObject:dict forKey:key];
|
[defaults setObject:dict forKey:key];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,8 +258,7 @@ void SystemPreferences::OnSysColorChange() {
|
||||||
Emit("color-changed");
|
Emit("color-changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemPreferences::OnFinishLaunching(
|
void SystemPreferences::OnFinishLaunching(base::Value::Dict launch_info) {
|
||||||
const base::DictionaryValue& launch_info) {
|
|
||||||
color_change_listener_ =
|
color_change_listener_ =
|
||||||
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ void Browser::WillFinishLaunching() {
|
||||||
observer.OnWillFinishLaunching();
|
observer.OnWillFinishLaunching();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::DidFinishLaunching(base::DictionaryValue launch_info) {
|
void Browser::DidFinishLaunching(base::Value::Dict launch_info) {
|
||||||
// Make sure the userData directory is created.
|
// Make sure the userData directory is created.
|
||||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||||
base::FilePath user_data;
|
base::FilePath user_data;
|
||||||
|
@ -196,7 +196,7 @@ void Browser::DidFinishLaunching(base::DictionaryValue launch_info) {
|
||||||
ready_promise_->Resolve();
|
ready_promise_->Resolve();
|
||||||
}
|
}
|
||||||
for (BrowserObserver& observer : observers_)
|
for (BrowserObserver& observer : observers_)
|
||||||
observer.OnFinishLaunching(launch_info);
|
observer.OnFinishLaunching(launch_info.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> Browser::WhenReady(v8::Isolate* isolate) {
|
v8::Local<v8::Value> Browser::WhenReady(v8::Isolate* isolate) {
|
||||||
|
|
10
shell/browser/browser.h
Executable file → Normal file
10
shell/browser/browser.h
Executable file → Normal file
|
@ -191,16 +191,16 @@ class Browser : public WindowListObserver {
|
||||||
|
|
||||||
// Resumes an activity via hand-off.
|
// Resumes an activity via hand-off.
|
||||||
bool ContinueUserActivity(const std::string& type,
|
bool ContinueUserActivity(const std::string& type,
|
||||||
base::DictionaryValue user_info,
|
base::Value::Dict user_info,
|
||||||
base::DictionaryValue details);
|
base::Value::Dict details);
|
||||||
|
|
||||||
// Indicates that an activity was continued on another device.
|
// Indicates that an activity was continued on another device.
|
||||||
void UserActivityWasContinued(const std::string& type,
|
void UserActivityWasContinued(const std::string& type,
|
||||||
base::DictionaryValue user_info);
|
base::Value::Dict user_info);
|
||||||
|
|
||||||
// Gives an opportunity to update the Handoff payload.
|
// Gives an opportunity to update the Handoff payload.
|
||||||
bool UpdateUserActivityState(const std::string& type,
|
bool UpdateUserActivityState(const std::string& type,
|
||||||
base::DictionaryValue user_info);
|
base::Value::Dict user_info);
|
||||||
|
|
||||||
// Bounce the dock icon.
|
// Bounce the dock icon.
|
||||||
enum class BounceType{
|
enum class BounceType{
|
||||||
|
@ -288,7 +288,7 @@ class Browser : public WindowListObserver {
|
||||||
|
|
||||||
// Tell the application the loading has been done.
|
// Tell the application the loading has been done.
|
||||||
void WillFinishLaunching();
|
void WillFinishLaunching();
|
||||||
void DidFinishLaunching(base::DictionaryValue launch_info);
|
void DidFinishLaunching(base::Value::Dict launch_info);
|
||||||
|
|
||||||
void OnAccessibilitySupportChanged();
|
void OnAccessibilitySupportChanged();
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ void Browser::SetUserActivity(const std::string& type,
|
||||||
|
|
||||||
[[AtomApplication sharedApplication]
|
[[AtomApplication sharedApplication]
|
||||||
setCurrentActivity:base::SysUTF8ToNSString(type)
|
setCurrentActivity:base::SysUTF8ToNSString(type)
|
||||||
withUserInfo:DictionaryValueToNSDictionary(user_info)
|
withUserInfo:DictionaryValueToNSDictionary(user_info.GetDict())
|
||||||
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
|
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ void Browser::UpdateCurrentActivity(const std::string& type,
|
||||||
base::DictionaryValue user_info) {
|
base::DictionaryValue user_info) {
|
||||||
[[AtomApplication sharedApplication]
|
[[AtomApplication sharedApplication]
|
||||||
updateCurrentActivity:base::SysUTF8ToNSString(type)
|
updateCurrentActivity:base::SysUTF8ToNSString(type)
|
||||||
withUserInfo:DictionaryValueToNSDictionary(user_info)];
|
withUserInfo:DictionaryValueToNSDictionary(user_info.GetDict())];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::WillContinueUserActivity(const std::string& type) {
|
bool Browser::WillContinueUserActivity(const std::string& type) {
|
||||||
|
@ -281,25 +281,27 @@ void Browser::DidFailToContinueUserActivity(const std::string& type,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::ContinueUserActivity(const std::string& type,
|
bool Browser::ContinueUserActivity(const std::string& type,
|
||||||
base::DictionaryValue user_info,
|
base::Value::Dict user_info,
|
||||||
base::DictionaryValue details) {
|
base::Value::Dict details) {
|
||||||
bool prevent_default = false;
|
bool prevent_default = false;
|
||||||
for (BrowserObserver& observer : observers_)
|
for (BrowserObserver& observer : observers_)
|
||||||
observer.OnContinueUserActivity(&prevent_default, type, user_info, details);
|
observer.OnContinueUserActivity(&prevent_default, type, user_info.Clone(),
|
||||||
|
details.Clone());
|
||||||
return prevent_default;
|
return prevent_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::UserActivityWasContinued(const std::string& type,
|
void Browser::UserActivityWasContinued(const std::string& type,
|
||||||
base::DictionaryValue user_info) {
|
base::Value::Dict user_info) {
|
||||||
for (BrowserObserver& observer : observers_)
|
for (BrowserObserver& observer : observers_)
|
||||||
observer.OnUserActivityWasContinued(type, user_info);
|
observer.OnUserActivityWasContinued(type, user_info.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::UpdateUserActivityState(const std::string& type,
|
bool Browser::UpdateUserActivityState(const std::string& type,
|
||||||
base::DictionaryValue user_info) {
|
base::Value::Dict user_info) {
|
||||||
bool prevent_default = false;
|
bool prevent_default = false;
|
||||||
for (BrowserObserver& observer : observers_)
|
for (BrowserObserver& observer : observers_)
|
||||||
observer.OnUpdateUserActivityState(&prevent_default, type, user_info);
|
observer.OnUpdateUserActivityState(&prevent_default, type,
|
||||||
|
user_info.Clone());
|
||||||
return prevent_default;
|
return prevent_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +488,8 @@ void Browser::DockSetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::ShowAboutPanel() {
|
void Browser::ShowAboutPanel() {
|
||||||
NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_);
|
NSDictionary* options =
|
||||||
|
DictionaryValueToNSDictionary(about_panel_options_.GetDict());
|
||||||
|
|
||||||
// Credits must be a NSAttributedString instead of NSString
|
// Credits must be a NSAttributedString instead of NSString
|
||||||
NSString* credits = (NSString*)options[@"Credits"];
|
NSString* credits = (NSString*)options[@"Credits"];
|
||||||
|
|
|
@ -47,7 +47,7 @@ class BrowserObserver : public base::CheckedObserver {
|
||||||
|
|
||||||
// The browser has finished loading.
|
// The browser has finished loading.
|
||||||
virtual void OnWillFinishLaunching() {}
|
virtual void OnWillFinishLaunching() {}
|
||||||
virtual void OnFinishLaunching(const base::DictionaryValue& launch_info) {}
|
virtual void OnFinishLaunching(base::Value::Dict launch_info) {}
|
||||||
|
|
||||||
// The browser's accessibility support has changed.
|
// The browser's accessibility support has changed.
|
||||||
virtual void OnAccessibilitySupportChanged() {}
|
virtual void OnAccessibilitySupportChanged() {}
|
||||||
|
@ -70,17 +70,15 @@ class BrowserObserver : public base::CheckedObserver {
|
||||||
// The browser wants to resume a user activity via handoff. (macOS only)
|
// The browser wants to resume a user activity via handoff. (macOS only)
|
||||||
virtual void OnContinueUserActivity(bool* prevent_default,
|
virtual void OnContinueUserActivity(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info,
|
base::Value::Dict user_info,
|
||||||
const base::DictionaryValue& details) {}
|
base::Value::Dict details) {}
|
||||||
// The browser wants to notify that an user activity was resumed. (macOS only)
|
// The browser wants to notify that an user activity was resumed. (macOS only)
|
||||||
virtual void OnUserActivityWasContinued(
|
virtual void OnUserActivityWasContinued(const std::string& type,
|
||||||
const std::string& type,
|
base::Value::Dict user_info) {}
|
||||||
const base::DictionaryValue& user_info) {}
|
|
||||||
// The browser wants to update an user activity payload. (macOS only)
|
// The browser wants to update an user activity payload. (macOS only)
|
||||||
virtual void OnUpdateUserActivityState(
|
virtual void OnUpdateUserActivityState(bool* prevent_default,
|
||||||
bool* prevent_default,
|
const std::string& type,
|
||||||
const std::string& type,
|
base::Value::Dict user_info) {}
|
||||||
const base::DictionaryValue& user_info) {}
|
|
||||||
// User clicked the native macOS new tab button. (macOS only)
|
// User clicked the native macOS new tab button. (macOS only)
|
||||||
virtual void OnNewWindowForTab() {}
|
virtual void OnNewWindowForTab() {}
|
||||||
|
|
||||||
|
|
|
@ -453,7 +453,7 @@ int ElectronBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
#if !BUILDFLAG(IS_MAC)
|
#if !BUILDFLAG(IS_MAC)
|
||||||
// The corresponding call in macOS is in ElectronApplicationDelegate.
|
// The corresponding call in macOS is in ElectronApplicationDelegate.
|
||||||
Browser::Get()->WillFinishLaunching();
|
Browser::Get()->WillFinishLaunching();
|
||||||
Browser::Get()->DidFinishLaunching(base::DictionaryValue());
|
Browser::Get()->DidFinishLaunching(base::Value::Dict());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Notify observers that main thread message loop was initialized.
|
// Notify observers that main thread message loop was initialized.
|
||||||
|
|
|
@ -7,17 +7,14 @@
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
namespace base {
|
#include "base/values.h"
|
||||||
class ListValue;
|
|
||||||
class DictionaryValue;
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
NSArray* ListValueToNSArray(const base::ListValue& value);
|
NSArray* ListValueToNSArray(const base::Value::List& value);
|
||||||
base::ListValue NSArrayToListValue(NSArray* arr);
|
base::Value::List NSArrayToValue(NSArray* arr);
|
||||||
NSDictionary* DictionaryValueToNSDictionary(const base::DictionaryValue& value);
|
NSDictionary* DictionaryValueToNSDictionary(const base::Value::Dict& value);
|
||||||
base::DictionaryValue NSDictionaryToDictionaryValue(NSDictionary* dict);
|
base::Value::Dict NSDictionaryToValue(NSDictionary* dict);
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
NSArray* ListValueToNSArray(const base::ListValue& value) {
|
NSArray* ListValueToNSArray(const base::Value::List& value) {
|
||||||
std::string json;
|
std::string json;
|
||||||
if (!base::JSONWriter::Write(value, &json))
|
if (!base::JSONWriter::Write(base::Value(value.Clone()), &json))
|
||||||
return nil;
|
return nil;
|
||||||
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
||||||
id obj = [NSJSONSerialization JSONObjectWithData:jsonData
|
id obj = [NSJSONSerialization JSONObjectWithData:jsonData
|
||||||
|
@ -25,8 +25,8 @@ NSArray* ListValueToNSArray(const base::ListValue& value) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::ListValue NSArrayToListValue(NSArray* arr) {
|
base::Value::List NSArrayToValue(NSArray* arr) {
|
||||||
base::ListValue result;
|
base::Value::List result;
|
||||||
if (!arr)
|
if (!arr)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ base::ListValue NSArrayToListValue(NSArray* arr) {
|
||||||
else
|
else
|
||||||
result.Append([value intValue]);
|
result.Append([value intValue]);
|
||||||
} else if ([value isKindOfClass:[NSArray class]]) {
|
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||||
result.Append(NSArrayToListValue(value));
|
result.Append(NSArrayToValue(value));
|
||||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||||
result.Append(NSDictionaryToDictionaryValue(value));
|
result.Append(NSDictionaryToValue(value));
|
||||||
} else {
|
} else {
|
||||||
result.Append(base::SysNSStringToUTF8([value description]));
|
result.Append(base::SysNSStringToUTF8([value description]));
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,9 @@ base::ListValue NSArrayToListValue(NSArray* arr) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDictionary* DictionaryValueToNSDictionary(
|
NSDictionary* DictionaryValueToNSDictionary(const base::Value::Dict& value) {
|
||||||
const base::DictionaryValue& value) {
|
|
||||||
std::string json;
|
std::string json;
|
||||||
if (!base::JSONWriter::Write(value, &json))
|
if (!base::JSONWriter::Write(base::Value(value.Clone()), &json))
|
||||||
return nil;
|
return nil;
|
||||||
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
||||||
id obj = [NSJSONSerialization JSONObjectWithData:jsonData
|
id obj = [NSJSONSerialization JSONObjectWithData:jsonData
|
||||||
|
@ -69,8 +68,8 @@ NSDictionary* DictionaryValueToNSDictionary(
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::DictionaryValue NSDictionaryToDictionaryValue(NSDictionary* dict) {
|
base::Value::Dict NSDictionaryToValue(NSDictionary* dict) {
|
||||||
base::DictionaryValue result;
|
base::Value::Dict result;
|
||||||
if (!dict)
|
if (!dict)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -80,24 +79,24 @@ base::DictionaryValue NSDictionaryToDictionaryValue(NSDictionary* dict) {
|
||||||
|
|
||||||
id value = [dict objectForKey:key];
|
id value = [dict objectForKey:key];
|
||||||
if ([value isKindOfClass:[NSString class]]) {
|
if ([value isKindOfClass:[NSString class]]) {
|
||||||
result.SetKey(str_key, base::Value(base::SysNSStringToUTF8(value)));
|
result.Set(str_key, base::Value(base::SysNSStringToUTF8(value)));
|
||||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||||
const char* objc_type = [value objCType];
|
const char* objc_type = [value objCType];
|
||||||
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
|
if (strcmp(objc_type, @encode(BOOL)) == 0 ||
|
||||||
strcmp(objc_type, @encode(char)) == 0)
|
strcmp(objc_type, @encode(char)) == 0)
|
||||||
result.SetKey(str_key, base::Value([value boolValue]));
|
result.Set(str_key, base::Value([value boolValue]));
|
||||||
else if (strcmp(objc_type, @encode(double)) == 0 ||
|
else if (strcmp(objc_type, @encode(double)) == 0 ||
|
||||||
strcmp(objc_type, @encode(float)) == 0)
|
strcmp(objc_type, @encode(float)) == 0)
|
||||||
result.SetKey(str_key, base::Value([value doubleValue]));
|
result.Set(str_key, base::Value([value doubleValue]));
|
||||||
else
|
else
|
||||||
result.SetKey(str_key, base::Value([value intValue]));
|
result.Set(str_key, base::Value([value intValue]));
|
||||||
} else if ([value isKindOfClass:[NSArray class]]) {
|
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||||
result.SetKey(str_key, NSArrayToListValue(value));
|
result.Set(str_key, NSArrayToValue(value));
|
||||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||||
result.SetKey(str_key, NSDictionaryToDictionaryValue(value));
|
result.Set(str_key, NSDictionaryToValue(value));
|
||||||
} else {
|
} else {
|
||||||
result.SetKey(str_key,
|
result.Set(str_key,
|
||||||
base::Value(base::SysNSStringToUTF8([value description])));
|
base::Value(base::SysNSStringToUTF8([value description])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,8 +120,8 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
dispatch_sync_main(^{
|
dispatch_sync_main(^{
|
||||||
std::string activity_type(
|
std::string activity_type(
|
||||||
base::SysNSStringToUTF8(userActivity.activityType));
|
base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
base::DictionaryValue user_info =
|
base::Value::Dict user_info =
|
||||||
electron::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
electron::NSDictionaryToValue(userActivity.userInfo);
|
||||||
|
|
||||||
electron::Browser* browser = electron::Browser::Get();
|
electron::Browser* browser = electron::Browser::Get();
|
||||||
shouldWait =
|
shouldWait =
|
||||||
|
@ -149,8 +149,8 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
std::string activity_type(
|
std::string activity_type(
|
||||||
base::SysNSStringToUTF8(userActivity.activityType));
|
base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
base::DictionaryValue user_info =
|
base::Value::Dict user_info =
|
||||||
electron::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
electron::NSDictionaryToValue(userActivity.userInfo);
|
||||||
|
|
||||||
electron::Browser* browser = electron::Browser::Get();
|
electron::Browser* browser = electron::Browser::Get();
|
||||||
browser->UserActivityWasContinued(activity_type, std::move(user_info));
|
browser->UserActivityWasContinued(activity_type, std::move(user_info));
|
||||||
|
|
|
@ -84,7 +84,7 @@ static NSDictionary* UNNotificationResponseToNSDictionary(
|
||||||
}
|
}
|
||||||
|
|
||||||
electron::Browser::Get()->DidFinishLaunching(
|
electron::Browser::Get()->DidFinishLaunching(
|
||||||
electron::NSDictionaryToDictionaryValue(notification_info));
|
electron::NSDictionaryToValue(notification_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidBecomeActive:(NSNotification*)notification {
|
- (void)applicationDidBecomeActive:(NSNotification*)notification {
|
||||||
|
@ -128,8 +128,8 @@ static NSDictionary* UNNotificationResponseToNSDictionary(
|
||||||
electron::Browser* browser = electron::Browser::Get();
|
electron::Browser* browser = electron::Browser::Get();
|
||||||
return browser->ContinueUserActivity(
|
return browser->ContinueUserActivity(
|
||||||
activity_type,
|
activity_type,
|
||||||
electron::NSDictionaryToDictionaryValue(userActivity.userInfo),
|
electron::NSDictionaryToValue(userActivity.userInfo),
|
||||||
electron::NSDictionaryToDictionaryValue(details))
|
electron::NSDictionaryToValue(details))
|
||||||
? YES
|
? YES
|
||||||
: NO;
|
: NO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue