chromium/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"

#include <stddef.h>

#include <algorithm>
#include <functional>
#include <sstream>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/files/file_util.h"
#include "base/files/important_file_writer.h"
#include "base/functional/bind.h"
#include "base/hash/md5.h"
#include "base/observer_list.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "chrome/common/chrome_constants.h"
#include "components/spellcheck/browser/spellcheck_host_metrics.h"
#include "components/spellcheck/common/spellcheck_common.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/model/sync_change_processor.h"
#include "components/sync/protocol/dictionary_specifics.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"

BrowserThread;

namespace {

// Filename extension for backup dictionary file.
const base::FilePath::CharType BACKUP_EXTENSION[] =);

// Prefix for the checksum in the dictionary file.
const char CHECKSUM_PREFIX[] =;

// The status of the checksum in a custom spellcheck dictionary.
enum ChecksumStatus {};

// The result of a dictionary sanitation. Can be used as a bitmap.
enum ChangeSanitationResult {};

// Loads the file at |file_path| into the |words| container. If the file has a
// valid checksum, then returns ChecksumStatus::VALID. If the file has an
// invalid checksum, then returns ChecksumStatus::INVALID and clears |words|.
ChecksumStatus LoadFile(const base::FilePath& file_path,
                        std::set<std::string>* words) {}

// Returns true for valid custom dictionary words.
bool IsValidWord(const std::string& word) {}

// Removes duplicate and invalid words from |to_add| word list. Looks for
// duplicates in both |to_add| and |existing| word lists. Returns a bitmap of
// |ChangeSanitationResult| values.
int SanitizeWordsToAdd(const std::set<std::string>& existing,
                       std::set<std::string>* to_add) {}

// Loads and returns the custom spellcheck dictionary from |path|. Must be
// called on the file thread.
std::unique_ptr<SpellcheckCustomDictionary::LoadFileResult>
LoadDictionaryFileReliably(const base::FilePath& path) {}

// Backs up the original dictionary, saves |custom_words| and its checksum into
// the custom spellcheck dictionary at |path|.
void SaveDictionaryFileReliably(const base::FilePath& path,
                                const std::set<std::string>& custom_words) {}

void SavePassedWordsToDictionaryFileReliably(
    const base::FilePath& path,
    std::unique_ptr<SpellcheckCustomDictionary::LoadFileResult>
        load_file_result) {}

// Removes word from |to_remove| that are missing from |existing| word list and
// sorts |to_remove|. Returns a bitmap of |ChangeSanitationResult| values.
int SanitizeWordsToRemove(const std::set<std::string>& existing,
                          std::set<std::string>* to_remove) {}

}  // namespace

SpellcheckCustomDictionary::Change::Change() {}

SpellcheckCustomDictionary::Change::~Change() {}

void SpellcheckCustomDictionary::Change::AddWord(const std::string& word) {}

void SpellcheckCustomDictionary::Change::AddWords(
    const std::set<std::string>& words) {}

void SpellcheckCustomDictionary::Change::RemoveWord(const std::string& word) {}

void SpellcheckCustomDictionary::Change::Clear() {}

int SpellcheckCustomDictionary::Change::Sanitize(
    const std::set<std::string>& words) {}

SpellcheckCustomDictionary::SpellcheckCustomDictionary(
    const base::FilePath& dictionary_directory_name)
    :{}

SpellcheckCustomDictionary::~SpellcheckCustomDictionary() {}

const std::set<std::string>& SpellcheckCustomDictionary::GetWords() const {}

bool SpellcheckCustomDictionary::AddWord(const std::string& word) {}

bool SpellcheckCustomDictionary::RemoveWord(const std::string& word) {}

bool SpellcheckCustomDictionary::HasWord(const std::string& word) const {}

void SpellcheckCustomDictionary::Clear() {}

void SpellcheckCustomDictionary::AddObserver(Observer* observer) {}

void SpellcheckCustomDictionary::RemoveObserver(Observer* observer) {}

bool SpellcheckCustomDictionary::IsLoaded() {}

bool SpellcheckCustomDictionary::IsSyncing() {}

void SpellcheckCustomDictionary::Load() {}

void SpellcheckCustomDictionary::WaitUntilReadyToSync(base::OnceClosure done) {}

std::optional<syncer::ModelError>
SpellcheckCustomDictionary::MergeDataAndStartSyncing(
    syncer::DataType type,
    const syncer::SyncDataList& initial_sync_data,
    std::unique_ptr<syncer::SyncChangeProcessor> sync_processor) {}

void SpellcheckCustomDictionary::StopSyncing(syncer::DataType type) {}

syncer::SyncDataList SpellcheckCustomDictionary::GetAllSyncDataForTesting(
    syncer::DataType type) const {}

std::optional<syncer::ModelError>
SpellcheckCustomDictionary::ProcessSyncChanges(
    const base::Location& from_here,
    const syncer::SyncChangeList& change_list) {}

base::WeakPtr<syncer::SyncableService> SpellcheckCustomDictionary::AsWeakPtr() {}

SpellcheckCustomDictionary::LoadFileResult::LoadFileResult()
    :{}

SpellcheckCustomDictionary::LoadFileResult::~LoadFileResult() {}

// static
std::unique_ptr<SpellcheckCustomDictionary::LoadFileResult>
SpellcheckCustomDictionary::LoadDictionaryFile(const base::FilePath& path) {}

// static
void SpellcheckCustomDictionary::UpdateDictionaryFile(
    std::unique_ptr<Change> dictionary_change,
    const base::FilePath& path) {}

void SpellcheckCustomDictionary::OnLoaded(
    std::unique_ptr<LoadFileResult> result) {}

void SpellcheckCustomDictionary::Apply(const Change& dictionary_change) {}

void SpellcheckCustomDictionary::FixInvalidFile(
    std::unique_ptr<LoadFileResult> load_file_result) {}

void SpellcheckCustomDictionary::Save(
    std::unique_ptr<Change> dictionary_change) {}

std::optional<syncer::ModelError> SpellcheckCustomDictionary::Sync(
    const Change& dictionary_change) {}

void SpellcheckCustomDictionary::Notify(const Change& dictionary_change) {}