refactor: Chromium code style for enum classes (#26165)
This commit is contained in:
parent
dbf2931f0e
commit
1c99a9b425
34 changed files with 300 additions and 295 deletions
|
@ -83,7 +83,7 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
|
|||
DCHECK(shell_link);
|
||||
DCHECK(item);
|
||||
|
||||
item->type = JumpListItem::Type::TASK;
|
||||
item->type = JumpListItem::Type::kTask;
|
||||
wchar_t path[MAX_PATH];
|
||||
if (FAILED(shell_link->GetPath(path, base::size(path), nullptr, 0)))
|
||||
return false;
|
||||
|
@ -134,7 +134,7 @@ void ConvertRemovedJumpListItems(IObjectArray* in,
|
|||
IShellLink* shell_link;
|
||||
for (UINT i = 0; i < removed_count; ++i) {
|
||||
if (SUCCEEDED(in->GetAt(i, IID_PPV_ARGS(&shell_item)))) {
|
||||
item.type = JumpListItem::Type::FILE;
|
||||
item.type = JumpListItem::Type::kFile;
|
||||
GetShellItemFileName(shell_item, &item.path);
|
||||
out->push_back(item);
|
||||
shell_item->Release();
|
||||
|
@ -217,22 +217,22 @@ bool JumpList::Delete() {
|
|||
JumpListResult JumpList::AppendCategory(const JumpListCategory& category) {
|
||||
DCHECK(destinations_);
|
||||
if (!destinations_)
|
||||
return JumpListResult::GENERIC_ERROR;
|
||||
return JumpListResult::kGenericError;
|
||||
|
||||
if (category.items.empty())
|
||||
return JumpListResult::SUCCESS;
|
||||
return JumpListResult::kSuccess;
|
||||
|
||||
CComPtr<IObjectCollection> collection;
|
||||
if (FAILED(collection.CoCreateInstance(CLSID_EnumerableObjectCollection))) {
|
||||
return JumpListResult::GENERIC_ERROR;
|
||||
return JumpListResult::kGenericError;
|
||||
}
|
||||
|
||||
auto result = JumpListResult::SUCCESS;
|
||||
auto result = JumpListResult::kSuccess;
|
||||
// Keep track of how many items were actually appended to the category.
|
||||
int appended_count = 0;
|
||||
for (const auto& item : category.items) {
|
||||
switch (item.type) {
|
||||
case JumpListItem::Type::TASK:
|
||||
case JumpListItem::Type::kTask:
|
||||
if (AppendTask(item, collection))
|
||||
++appended_count;
|
||||
else
|
||||
|
@ -241,8 +241,8 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) {
|
|||
"to Jump List.";
|
||||
break;
|
||||
|
||||
case JumpListItem::Type::SEPARATOR:
|
||||
if (category.type == JumpListCategory::Type::TASKS) {
|
||||
case JumpListItem::Type::kSeparator:
|
||||
if (category.type == JumpListCategory::Type::kTasks) {
|
||||
if (AppendSeparator(collection))
|
||||
++appended_count;
|
||||
} else {
|
||||
|
@ -250,11 +250,11 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) {
|
|||
<< "'" << category.name << "'. "
|
||||
<< "Separators are only allowed in the standard 'Tasks' "
|
||||
"Jump List category.";
|
||||
result = JumpListResult::CUSTOM_CATEGORY_SEPARATOR_ERROR;
|
||||
result = JumpListResult::kCustomCategorySeparatorError;
|
||||
}
|
||||
break;
|
||||
|
||||
case JumpListItem::Type::FILE:
|
||||
case JumpListItem::Type::kFile:
|
||||
if (AppendFile(item, collection))
|
||||
++appended_count;
|
||||
else
|
||||
|
@ -269,17 +269,17 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) {
|
|||
return result;
|
||||
|
||||
if ((static_cast<size_t>(appended_count) < category.items.size()) &&
|
||||
(result == JumpListResult::SUCCESS)) {
|
||||
result = JumpListResult::GENERIC_ERROR;
|
||||
(result == JumpListResult::kSuccess)) {
|
||||
result = JumpListResult::kGenericError;
|
||||
}
|
||||
|
||||
CComQIPtr<IObjectArray> items(collection);
|
||||
|
||||
if (category.type == JumpListCategory::Type::TASKS) {
|
||||
if (category.type == JumpListCategory::Type::kTasks) {
|
||||
if (FAILED(destinations_->AddUserTasks(items))) {
|
||||
LOG(ERROR) << "Failed to append items to the standard Tasks category.";
|
||||
if (result == JumpListResult::SUCCESS)
|
||||
result = JumpListResult::GENERIC_ERROR;
|
||||
if (result == JumpListResult::kSuccess)
|
||||
result = JumpListResult::kGenericError;
|
||||
}
|
||||
} else {
|
||||
HRESULT hr = destinations_->AppendCategory(category.name.c_str(), items);
|
||||
|
@ -288,17 +288,17 @@ JumpListResult JumpList::AppendCategory(const JumpListCategory& category) {
|
|||
LOG(ERROR) << "Failed to append custom category "
|
||||
<< "'" << category.name << "' "
|
||||
<< "to Jump List due to missing file type registration.";
|
||||
result = JumpListResult::MISSING_FILE_TYPE_REGISTRATION_ERROR;
|
||||
result = JumpListResult::kMissingFileTypeRegistrationError;
|
||||
} else if (hr == E_ACCESSDENIED) {
|
||||
LOG(ERROR) << "Failed to append custom category "
|
||||
<< "'" << category.name << "' "
|
||||
<< "to Jump List due to system privacy settings.";
|
||||
result = JumpListResult::CUSTOM_CATEGORY_ACCESS_DENIED_ERROR;
|
||||
result = JumpListResult::kCustomCategoryAccessDeniedError;
|
||||
} else {
|
||||
LOG(ERROR) << "Failed to append custom category "
|
||||
<< "'" << category.name << "' to Jump List.";
|
||||
if (result == JumpListResult::SUCCESS)
|
||||
result = JumpListResult::GENERIC_ERROR;
|
||||
if (result == JumpListResult::kSuccess)
|
||||
result = JumpListResult::kGenericError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,36 +313,36 @@ JumpListResult JumpList::AppendCategories(
|
|||
const std::vector<JumpListCategory>& categories) {
|
||||
DCHECK(destinations_);
|
||||
if (!destinations_)
|
||||
return JumpListResult::GENERIC_ERROR;
|
||||
return JumpListResult::kGenericError;
|
||||
|
||||
auto result = JumpListResult::SUCCESS;
|
||||
auto result = JumpListResult::kSuccess;
|
||||
for (const auto& category : categories) {
|
||||
auto latestResult = JumpListResult::SUCCESS;
|
||||
auto latestResult = JumpListResult::kSuccess;
|
||||
switch (category.type) {
|
||||
case JumpListCategory::Type::TASKS:
|
||||
case JumpListCategory::Type::CUSTOM:
|
||||
case JumpListCategory::Type::kTasks:
|
||||
case JumpListCategory::Type::kCustom:
|
||||
latestResult = AppendCategory(category);
|
||||
break;
|
||||
|
||||
case JumpListCategory::Type::RECENT:
|
||||
case JumpListCategory::Type::kRecent:
|
||||
if (FAILED(destinations_->AppendKnownCategory(KDC_RECENT))) {
|
||||
LOG(ERROR) << "Failed to append Recent category to Jump List.";
|
||||
latestResult = JumpListResult::GENERIC_ERROR;
|
||||
latestResult = JumpListResult::kGenericError;
|
||||
}
|
||||
break;
|
||||
|
||||
case JumpListCategory::Type::FREQUENT:
|
||||
case JumpListCategory::Type::kFrequent:
|
||||
if (FAILED(destinations_->AppendKnownCategory(KDC_FREQUENT))) {
|
||||
LOG(ERROR) << "Failed to append Frequent category to Jump List.";
|
||||
latestResult = JumpListResult::GENERIC_ERROR;
|
||||
latestResult = JumpListResult::kGenericError;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Keep the first non-generic error code as only one can be returned from
|
||||
// the function (so try to make it the most useful one).
|
||||
if (((result == JumpListResult::SUCCESS) ||
|
||||
(result == JumpListResult::GENERIC_ERROR)) &&
|
||||
(latestResult != JumpListResult::SUCCESS))
|
||||
if (((result == JumpListResult::kSuccess) ||
|
||||
(result == JumpListResult::kGenericError)) &&
|
||||
(latestResult != JumpListResult::kSuccess))
|
||||
result = latestResult;
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue