chromium/chrome/browser/extensions/api/language_settings_private/language_settings_private_delegate.cc

// Copyright 2015 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/extensions/api/language_settings_private/language_settings_private_delegate.h"

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "components/prefs/pref_service.h"
#include "components/spellcheck/browser/pref_names.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"

namespace extensions {

language_settings_private;

LanguageSettingsPrivateDelegate::LanguageSettingsPrivateDelegate(
    content::BrowserContext* context)
    :{}

LanguageSettingsPrivateDelegate::~LanguageSettingsPrivateDelegate() {}

std::unique_ptr<LanguageSettingsPrivateDelegate>
LanguageSettingsPrivateDelegate::Create(content::BrowserContext* context) {}

std::vector<language_settings_private::SpellcheckDictionaryStatus>
LanguageSettingsPrivateDelegate::GetHunspellDictionaryStatuses() {}

void LanguageSettingsPrivateDelegate::Shutdown() {}

void LanguageSettingsPrivateDelegate::OnListenerAdded(
    const EventListenerInfo& details) {}

void LanguageSettingsPrivateDelegate::OnListenerRemoved(
    const EventListenerInfo& details) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void LanguageSettingsPrivateDelegate::InputMethodChanged(
    ash::input_method::InputMethodManager* manager,
    Profile* profile,
    bool show_message) {
  // Nothing to do.
}

void LanguageSettingsPrivateDelegate::OnInputMethodExtensionAdded(
    const std::string& extension_id) {
  auto args(
      language_settings_private::OnInputMethodAdded::Create(extension_id));
  std::unique_ptr<extensions::Event> extension_event(new extensions::Event(
      events::LANGUAGE_SETTINGS_PRIVATE_ON_INPUT_METHOD_ADDED,
      language_settings_private::OnInputMethodAdded::kEventName,
      std::move(args)));
  EventRouter::Get(context_)->BroadcastEvent(std::move(extension_event));
}

void LanguageSettingsPrivateDelegate::OnInputMethodExtensionRemoved(
    const std::string& extension_id) {
  auto args(
      language_settings_private::OnInputMethodRemoved::Create(extension_id));
  std::unique_ptr<extensions::Event> extension_event(new extensions::Event(
      events::LANGUAGE_SETTINGS_PRIVATE_ON_INPUT_METHOD_REMOVED,
      language_settings_private::OnInputMethodRemoved::kEventName,
      std::move(args)));
  EventRouter::Get(context_)->BroadcastEvent(std::move(extension_event));
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

void LanguageSettingsPrivateDelegate::OnHunspellDictionaryInitialized(
    const std::string& language) {}

void LanguageSettingsPrivateDelegate::OnHunspellDictionaryDownloadBegin(
    const std::string& language) {}

void LanguageSettingsPrivateDelegate::OnHunspellDictionaryDownloadSuccess(
    const std::string& language) {}

void LanguageSettingsPrivateDelegate::OnHunspellDictionaryDownloadFailure(
    const std::string& language) {}

void LanguageSettingsPrivateDelegate::OnCustomDictionaryLoaded() {}

void LanguageSettingsPrivateDelegate::OnCustomDictionaryChanged(
    const SpellcheckCustomDictionary::Change& change) {}

void LanguageSettingsPrivateDelegate::RefreshDictionaries(bool was_listening,
                                                          bool should_listen) {}

const LanguageSettingsPrivateDelegate::WeakDictionaries&
LanguageSettingsPrivateDelegate::GetHunspellDictionaries() {}

void LanguageSettingsPrivateDelegate::
    StartOrStopListeningForSpellcheckChanges() {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void LanguageSettingsPrivateDelegate::
    StartOrStopListeningForInputMethodChanges() {
  EventRouter* event_router = EventRouter::Get(context_);
  bool should_listen =
      event_router->HasEventListener(
          language_settings_private::OnInputMethodAdded::kEventName) ||
      event_router->HasEventListener(
          language_settings_private::OnInputMethodRemoved::kEventName);

  auto* input_method_manager = ash::input_method::InputMethodManager::Get();
  if (input_method_manager) {
    if (should_listen && !listening_input_method_)
      input_method_manager->AddObserver(this);
    else if (!should_listen && listening_input_method_)
      input_method_manager->RemoveObserver(this);
  }

  listening_input_method_ = should_listen;
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

void LanguageSettingsPrivateDelegate::RetryDownloadHunspellDictionary(
    const std::string& language) {}

void LanguageSettingsPrivateDelegate::OnSpellcheckDictionariesChanged() {}

void LanguageSettingsPrivateDelegate::BroadcastDictionariesChangedEvent() {}

void LanguageSettingsPrivateDelegate::RemoveDictionaryObservers() {}

}  // namespace extensions