#include "chrome/browser/web_applications/web_app_translation_manager.h"
#include "base/containers/span.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/web_applications/proto/web_app_translations.pb.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "third_party/blink/public/common/features.h"
namespace web_app {
namespace {
constexpr base::TaskTraits kTaskTraits = …;
base::FilePath GetDirectory(const base::FilePath& web_apps_directory) { … }
LocaleOverrides ConvertTranslationItemToLocaleOverrides(
blink::Manifest::TranslationItem translation) { … }
blink::Manifest::TranslationItem ConvertLocaleOverridesToTranslationItem(
const LocaleOverrides& locale_overrides) { … }
AllTranslations ReadProtoBlocking(scoped_refptr<FileUtilsWrapper> utils,
const base::FilePath& web_apps_directory) { … }
bool WriteProtoBlocking(scoped_refptr<FileUtilsWrapper> utils,
const base::FilePath& web_apps_directory,
AllTranslations proto) { … }
bool DeleteTranslationsBlocking(scoped_refptr<FileUtilsWrapper> utils,
const base::FilePath& web_apps_directory,
const webapps::AppId& app_id) { … }
bool WriteTranslationsBlocking(
scoped_refptr<FileUtilsWrapper> utils,
const base::FilePath& web_apps_directory,
const webapps::AppId& app_id,
base::flat_map<Locale, blink::Manifest::TranslationItem> translations) { … }
}
WebAppTranslationManager::WebAppTranslationManager(Profile* profile) { … }
WebAppTranslationManager::~WebAppTranslationManager() = default;
void WebAppTranslationManager::SetProvider(base::PassKey<WebAppProvider>,
WebAppProvider& provider) { … }
void WebAppTranslationManager::Start() { … }
void WebAppTranslationManager::WriteTranslations(
const webapps::AppId& app_id,
const base::flat_map<Locale, blink::Manifest::TranslationItem>&
translations,
WriteCallback callback) { … }
void WebAppTranslationManager::DeleteTranslations(const webapps::AppId& app_id,
WriteCallback callback) { … }
void WebAppTranslationManager::ReadTranslations(ReadCallback callback) { … }
void WebAppTranslationManager::OnTranslationsRead(
ReadCallback callback,
const AllTranslations& proto) { … }
std::string WebAppTranslationManager::GetTranslatedName(
const webapps::AppId& app_id) { … }
std::string WebAppTranslationManager::GetTranslatedDescription(
const webapps::AppId& app_id) { … }
}