refactor: Chromium code style for enum classes (#26165)

This commit is contained in:
Milan Burda 2020-10-27 18:51:45 +01:00 committed by GitHub
parent dbf2931f0e
commit 1c99a9b425
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 300 additions and 295 deletions

View file

@ -78,13 +78,13 @@ struct Converter<electron::ProcessIntegrityLevel> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
electron::ProcessIntegrityLevel value) {
switch (value) {
case electron::ProcessIntegrityLevel::Untrusted:
case electron::ProcessIntegrityLevel::kUntrusted:
return StringToV8(isolate, "untrusted");
case electron::ProcessIntegrityLevel::Low:
case electron::ProcessIntegrityLevel::kLow:
return StringToV8(isolate, "low");
case electron::ProcessIntegrityLevel::Medium:
case electron::ProcessIntegrityLevel::kMedium:
return StringToV8(isolate, "medium");
case electron::ProcessIntegrityLevel::High:
case electron::ProcessIntegrityLevel::kHigh:
return StringToV8(isolate, "high");
default:
return StringToV8(isolate, "unknown");
@ -127,11 +127,11 @@ struct Converter<JumpListItem::Type> {
return false;
if (item_type == "task")
*out = JumpListItem::Type::TASK;
*out = JumpListItem::Type::kTask;
else if (item_type == "separator")
*out = JumpListItem::Type::SEPARATOR;
*out = JumpListItem::Type::kSeparator;
else if (item_type == "file")
*out = JumpListItem::Type::FILE;
*out = JumpListItem::Type::kFile;
else
return false;
@ -142,15 +142,15 @@ struct Converter<JumpListItem::Type> {
JumpListItem::Type val) {
std::string item_type;
switch (val) {
case JumpListItem::Type::TASK:
case JumpListItem::Type::kTask:
item_type = "task";
break;
case JumpListItem::Type::SEPARATOR:
case JumpListItem::Type::kSeparator:
item_type = "separator";
break;
case JumpListItem::Type::FILE:
case JumpListItem::Type::kFile:
item_type = "file";
break;
}
@ -171,7 +171,7 @@ struct Converter<JumpListItem> {
return false;
switch (out->type) {
case JumpListItem::Type::TASK:
case JumpListItem::Type::kTask:
if (!dict.Get("program", &(out->path)) ||
!dict.Get("title", &(out->title)))
return false;
@ -185,10 +185,10 @@ struct Converter<JumpListItem> {
dict.Get("workingDirectory", &(out->working_dir));
return true;
case JumpListItem::Type::SEPARATOR:
case JumpListItem::Type::kSeparator:
return true;
case JumpListItem::Type::FILE:
case JumpListItem::Type::kFile:
return dict.Get("path", &(out->path));
}
@ -202,7 +202,7 @@ struct Converter<JumpListItem> {
dict.Set("type", val.type);
switch (val.type) {
case JumpListItem::Type::TASK:
case JumpListItem::Type::kTask:
dict.Set("program", val.path);
dict.Set("args", val.arguments);
dict.Set("title", val.title);
@ -212,10 +212,10 @@ struct Converter<JumpListItem> {
dict.Set("workingDirectory", val.working_dir);
break;
case JumpListItem::Type::SEPARATOR:
case JumpListItem::Type::kSeparator:
break;
case JumpListItem::Type::FILE:
case JumpListItem::Type::kFile:
dict.Set("path", val.path);
break;
}
@ -233,13 +233,13 @@ struct Converter<JumpListCategory::Type> {
return false;
if (category_type == "tasks")
*out = JumpListCategory::Type::TASKS;
*out = JumpListCategory::Type::kTasks;
else if (category_type == "frequent")
*out = JumpListCategory::Type::FREQUENT;
*out = JumpListCategory::Type::kFrequent;
else if (category_type == "recent")
*out = JumpListCategory::Type::RECENT;
*out = JumpListCategory::Type::kRecent;
else if (category_type == "custom")
*out = JumpListCategory::Type::CUSTOM;
*out = JumpListCategory::Type::kCustom;
else
return false;
@ -250,19 +250,19 @@ struct Converter<JumpListCategory::Type> {
JumpListCategory::Type val) {
std::string category_type;
switch (val) {
case JumpListCategory::Type::TASKS:
case JumpListCategory::Type::kTasks:
category_type = "tasks";
break;
case JumpListCategory::Type::FREQUENT:
case JumpListCategory::Type::kFrequent:
category_type = "frequent";
break;
case JumpListCategory::Type::RECENT:
case JumpListCategory::Type::kRecent:
category_type = "recent";
break;
case JumpListCategory::Type::CUSTOM:
case JumpListCategory::Type::kCustom:
category_type = "custom";
break;
}
@ -284,13 +284,13 @@ struct Converter<JumpListCategory> {
if (!dict.Get("type", &(out->type))) {
if (out->name.empty())
out->type = JumpListCategory::Type::TASKS;
out->type = JumpListCategory::Type::kTasks;
else
out->type = JumpListCategory::Type::CUSTOM;
out->type = JumpListCategory::Type::kCustom;
}
if ((out->type == JumpListCategory::Type::TASKS) ||
(out->type == JumpListCategory::Type::CUSTOM)) {
if ((out->type == JumpListCategory::Type::kTasks) ||
(out->type == JumpListCategory::Type::kCustom)) {
if (!dict.Get("items", &(out->items)))
return false;
}
@ -305,27 +305,27 @@ struct Converter<JumpListResult> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, JumpListResult val) {
std::string result_code;
switch (val) {
case JumpListResult::SUCCESS:
case JumpListResult::kSuccess:
result_code = "ok";
break;
case JumpListResult::ARGUMENT_ERROR:
case JumpListResult::kArgumentError:
result_code = "argumentError";
break;
case JumpListResult::GENERIC_ERROR:
case JumpListResult::kGenericError:
result_code = "error";
break;
case JumpListResult::CUSTOM_CATEGORY_SEPARATOR_ERROR:
case JumpListResult::kCustomCategorySeparatorError:
result_code = "invalidSeparatorError";
break;
case JumpListResult::MISSING_FILE_TYPE_REGISTRATION_ERROR:
case JumpListResult::kMissingFileTypeRegistrationError:
result_code = "fileTypeRegistrationError";
break;
case JumpListResult::CUSTOM_CATEGORY_ACCESS_DENIED_ERROR:
case JumpListResult::kCustomCategoryAccessDeniedError:
result_code = "customCategoryAccessDeniedError";
break;
}
@ -1253,19 +1253,19 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
!gin::ConvertFromV8(args->isolate(), val, &categories)) {
gin_helper::ErrorThrower(args->isolate())
.ThrowError("Argument must be null or an array of categories");
return JumpListResult::ARGUMENT_ERROR;
return JumpListResult::kArgumentError;
}
JumpList jump_list(Browser::Get()->GetAppUserModelID());
if (delete_jump_list) {
return jump_list.Delete() ? JumpListResult::SUCCESS
: JumpListResult::GENERIC_ERROR;
return jump_list.Delete() ? JumpListResult::kSuccess
: JumpListResult::kGenericError;
}
// Start a transaction that updates the JumpList of this application.
if (!jump_list.Begin())
return JumpListResult::GENERIC_ERROR;
return JumpListResult::kGenericError;
JumpListResult result = jump_list.AppendCategories(categories);
// AppendCategories may have failed to add some categories, but it's better
@ -1275,8 +1275,8 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
// It's more useful to return the earlier error code that might give
// some indication as to why the transaction actually failed, so don't
// overwrite it with a "generic error" code here.
if (result == JumpListResult::SUCCESS)
result = JumpListResult::GENERIC_ERROR;
if (result == JumpListResult::kSuccess)
result = JumpListResult::kGenericError;
}
return result;
@ -1488,9 +1488,10 @@ int DockBounce(gin::Arguments* args) {
args->GetNext(&type);
if (type == "critical")
request_id = Browser::Get()->DockBounce(Browser::BounceType::CRITICAL);
request_id = Browser::Get()->DockBounce(Browser::BounceType::kCritical);
else if (type == "informational")
request_id = Browser::Get()->DockBounce(Browser::BounceType::INFORMATIONAL);
request_id =
Browser::Get()->DockBounce(Browser::BounceType::kInformational);
return request_id;
}