Files
brave-core/browser/extensions/api/brave_theme_api.cc
T
cdesouza-chromium 7814e17784 [clang-tidy] Modernise namespaces (#24272)
Modernising all namespaces in brave to use nested concat namespace
declarations.

This change is part of a large effort to modernise the brave codebase
across the board with `clang-tidy`, in order to allow future use of
`clang-duty`during code reviews. The idea is to apply a few modernisers
across the codebase in order to have less noise when trying to use
clang-tidy with some sort of autmoation.
2024-06-21 17:12:18 +01:00

43 lines
1.4 KiB
C++

/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "brave/browser/extensions/api/brave_theme_api.h"
#include <memory>
#include <optional>
#include <string>
#include "base/json/json_writer.h"
#include "base/values.h"
#include "brave/browser/themes/brave_dark_mode_utils.h"
#include "brave/common/extensions/api/brave_theme.h"
namespace extensions::api {
ExtensionFunction::ResponseAction BraveThemeGetBraveThemeListFunction::Run() {
std::string json_string;
base::JSONWriter::Write(dark_mode::GetBraveDarkModeTypeList(), &json_string);
return RespondNow(WithArguments(json_string));
}
ExtensionFunction::ResponseAction BraveThemeGetBraveThemeTypeFunction::Run() {
const std::string theme_type =
dark_mode::GetStringFromBraveDarkModeType(
dark_mode::GetActiveBraveDarkModeType());
return RespondNow(WithArguments(theme_type));
}
ExtensionFunction::ResponseAction BraveThemeSetBraveThemeTypeFunction::Run() {
std::optional<brave_theme::SetBraveThemeType::Params> params =
brave_theme::SetBraveThemeType::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params);
dark_mode::SetBraveDarkModeType(params->type);
return RespondNow(NoArguments());
}
} // namespace extensions::api