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");
|
||||
}
|
||||
|
||||
void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||
void App::OnFinishLaunching(base::Value::Dict launch_info) {
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
// Set the application name for audio streams shown in external
|
||||
// applications. Only affects pulseaudio currently.
|
||||
media::AudioManager::SetGlobalAppName(Browser::Get()->GetName());
|
||||
#endif
|
||||
Emit("ready", launch_info);
|
||||
Emit("ready", base::Value(std::move(launch_info)));
|
||||
}
|
||||
|
||||
void App::OnPreMainMessageLoopRun() {
|
||||
|
@ -756,22 +756,23 @@ void App::OnDidFailToContinueUserActivity(const std::string& type,
|
|||
|
||||
void App::OnContinueUserActivity(bool* prevent_default,
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info,
|
||||
const base::DictionaryValue& details) {
|
||||
if (Emit("continue-activity", type, user_info, details)) {
|
||||
base::Value::Dict user_info,
|
||||
base::Value::Dict details) {
|
||||
if (Emit("continue-activity", type, base::Value(std::move(user_info)),
|
||||
base::Value(std::move(details)))) {
|
||||
*prevent_default = true;
|
||||
}
|
||||
}
|
||||
|
||||
void App::OnUserActivityWasContinued(const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
Emit("activity-was-continued", type, user_info);
|
||||
base::Value::Dict user_info) {
|
||||
Emit("activity-was-continued", type, base::Value(std::move(user_info)));
|
||||
}
|
||||
|
||||
void App::OnUpdateUserActivityState(bool* prevent_default,
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
if (Emit("update-activity-state", type, user_info)) {
|
||||
base::Value::Dict user_info) {
|
||||
if (Emit("update-activity-state", type, base::Value(std::move(user_info)))) {
|
||||
*prevent_default = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class App : public ElectronBrowserClient::Delegate,
|
|||
void OnOpenURL(const std::string& url) override;
|
||||
void OnActivate(bool has_visible_windows) override;
|
||||
void OnWillFinishLaunching() override;
|
||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
||||
void OnFinishLaunching(base::Value::Dict launch_info) override;
|
||||
void OnAccessibilitySupportChanged() override;
|
||||
void OnPreMainMessageLoopRun() override;
|
||||
void OnPreCreateThreads() override;
|
||||
|
@ -107,15 +107,13 @@ class App : public ElectronBrowserClient::Delegate,
|
|||
const std::string& error) override;
|
||||
void OnContinueUserActivity(bool* prevent_default,
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info,
|
||||
const base::DictionaryValue& details) override;
|
||||
void OnUserActivityWasContinued(
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) override;
|
||||
void OnUpdateUserActivityState(
|
||||
bool* prevent_default,
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) override;
|
||||
base::Value::Dict user_info,
|
||||
base::Value::Dict details) override;
|
||||
void OnUserActivityWasContinued(const std::string& type,
|
||||
base::Value::Dict user_info) override;
|
||||
void OnUpdateUserActivityState(bool* prevent_default,
|
||||
const std::string& type,
|
||||
base::Value::Dict user_info) override;
|
||||
void OnNewWindowForTab() override;
|
||||
void OnDidBecomeActive() override;
|
||||
#endif
|
||||
|
|
|
@ -67,11 +67,11 @@ class SystemPreferences
|
|||
void OnSysColorChange() override;
|
||||
|
||||
// BrowserObserver:
|
||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
||||
void OnFinishLaunching(base::Value::Dict launch_info) override;
|
||||
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
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,
|
||||
base::DictionaryValue user_info,
|
||||
|
|
|
@ -147,10 +147,11 @@ void SystemPreferences::PostNotification(const std::string& name,
|
|||
|
||||
NSDistributedNotificationCenter* center =
|
||||
[NSDistributedNotificationCenter defaultCenter];
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)
|
||||
deliverImmediately:immediate];
|
||||
[center
|
||||
postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info.GetDict())
|
||||
deliverImmediately:immediate];
|
||||
}
|
||||
|
||||
int SystemPreferences::SubscribeNotification(
|
||||
|
@ -169,9 +170,10 @@ void SystemPreferences::UnsubscribeNotification(int request_id) {
|
|||
void SystemPreferences::PostLocalNotification(const std::string& name,
|
||||
base::DictionaryValue user_info) {
|
||||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
[center
|
||||
postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info.GetDict())];
|
||||
}
|
||||
|
||||
int SystemPreferences::SubscribeLocalNotification(
|
||||
|
@ -191,9 +193,10 @@ void SystemPreferences::PostWorkspaceNotification(
|
|||
base::DictionaryValue user_info) {
|
||||
NSNotificationCenter* center =
|
||||
[[NSWorkspace sharedWorkspace] notificationCenter];
|
||||
[center postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
[center
|
||||
postNotificationName:base::SysUTF8ToNSString(name)
|
||||
object:nil
|
||||
userInfo:DictionaryValueToNSDictionary(user_info.GetDict())];
|
||||
}
|
||||
|
||||
int SystemPreferences::SubscribeWorkspaceNotification(
|
||||
|
@ -240,7 +243,7 @@ int SystemPreferences::DoSubscribeNotification(
|
|||
if (notification.userInfo) {
|
||||
copied_callback.Run(
|
||||
base::SysNSStringToUTF8(notification.name),
|
||||
NSDictionaryToDictionaryValue(notification.userInfo),
|
||||
base::Value(NSDictionaryToValue(notification.userInfo)),
|
||||
object);
|
||||
} else {
|
||||
copied_callback.Run(
|
||||
|
@ -282,11 +285,12 @@ v8::Local<v8::Value> SystemPreferences::GetUserDefault(
|
|||
return gin::ConvertToV8(isolate,
|
||||
net::GURLWithNSURL([defaults URLForKey:key]));
|
||||
} else if (type == "array") {
|
||||
return gin::ConvertToV8(isolate,
|
||||
NSArrayToListValue([defaults arrayForKey:key]));
|
||||
return gin::ConvertToV8(
|
||||
isolate, base::Value(NSArrayToValue([defaults arrayForKey:key])));
|
||||
} else if (type == "dictionary") {
|
||||
return gin::ConvertToV8(isolate, NSDictionaryToDictionaryValue(
|
||||
[defaults dictionaryForKey:key]));
|
||||
return gin::ConvertToV8(
|
||||
isolate,
|
||||
base::Value(NSDictionaryToValue([defaults dictionaryForKey:key])));
|
||||
} else {
|
||||
return v8::Undefined(isolate);
|
||||
}
|
||||
|
@ -299,7 +303,7 @@ void SystemPreferences::RegisterDefaults(gin::Arguments* args) {
|
|||
args->ThrowError();
|
||||
} else {
|
||||
@try {
|
||||
NSDictionary* dict = DictionaryValueToNSDictionary(value);
|
||||
NSDictionary* dict = DictionaryValueToNSDictionary(value.GetDict());
|
||||
for (id key in dict) {
|
||||
id value = [dict objectForKey:key];
|
||||
if ([value isKindOfClass:[NSNull class]] || value == nil) {
|
||||
|
@ -359,17 +363,17 @@ void SystemPreferences::SetUserDefault(const std::string& name,
|
|||
}
|
||||
}
|
||||
} else if (type == "array") {
|
||||
base::ListValue value;
|
||||
if (args->GetNext(&value)) {
|
||||
if (NSArray* array = ListValueToNSArray(value)) {
|
||||
base::Value value;
|
||||
if (args->GetNext(&value) && value.is_list()) {
|
||||
if (NSArray* array = ListValueToNSArray(value.GetList())) {
|
||||
[defaults setObject:array forKey:key];
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (type == "dictionary") {
|
||||
base::DictionaryValue value;
|
||||
if (args->GetNext(&value)) {
|
||||
if (NSDictionary* dict = DictionaryValueToNSDictionary(value)) {
|
||||
base::Value value;
|
||||
if (args->GetNext(&value) && value.is_dict()) {
|
||||
if (NSDictionary* dict = DictionaryValueToNSDictionary(value.GetDict())) {
|
||||
[defaults setObject:dict forKey:key];
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -258,8 +258,7 @@ void SystemPreferences::OnSysColorChange() {
|
|||
Emit("color-changed");
|
||||
}
|
||||
|
||||
void SystemPreferences::OnFinishLaunching(
|
||||
const base::DictionaryValue& launch_info) {
|
||||
void SystemPreferences::OnFinishLaunching(base::Value::Dict launch_info) {
|
||||
color_change_listener_ =
|
||||
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue