extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.cpp
author Andreas Pehrson <pehrsons@gmail.com>
Thu, 05 Nov 2015 15:42:24 +0800
changeset 306659 481d2dace480c02b375a91e902ece00eef223c2b
parent 293114 bc496e1c596316188b986f1c6c8ab632794d7e4e
child 438920 010029d6698eae08c7816ca2dd8dd6f3548b68d7
permissions -rw-r--r--
Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

/* vim: set ts=2 sw=2 sts=2 tw=80: */
/* 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 "RemoteSpellCheckEngineParent.h"
#include "nsISpellChecker.h"
#include "nsServiceManagerUtils.h"

namespace mozilla {

RemoteSpellcheckEngineParent::RemoteSpellcheckEngineParent()
{
  mSpellChecker = do_CreateInstance(NS_SPELLCHECKER_CONTRACTID);
}

RemoteSpellcheckEngineParent::~RemoteSpellcheckEngineParent()
{
}

bool
RemoteSpellcheckEngineParent::RecvSetDictionary(
  const nsString& aDictionary,
  bool* success)
{
  nsresult rv = mSpellChecker->SetCurrentDictionary(aDictionary);
  *success = NS_SUCCEEDED(rv);
  return true;
}

bool
RemoteSpellcheckEngineParent::RecvCheck(
  const nsString& aWord,
  bool* aIsMisspelled)
{
  nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, nullptr);

  // If CheckWord failed, we can't tell whether the word is correctly spelled.
  if (NS_FAILED(rv))
    *aIsMisspelled = false;
  return true;
}

bool
RemoteSpellcheckEngineParent::RecvCheckAndSuggest(
  const nsString& aWord,
  bool* aIsMisspelled,
  InfallibleTArray<nsString>* aSuggestions)
{
  nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, aSuggestions);
  if (NS_FAILED(rv)) {
    aSuggestions->Clear();
    *aIsMisspelled = false;
  }
  return true;
}

void
RemoteSpellcheckEngineParent::ActorDestroy(ActorDestroyReason aWhy)
{
}

} // namespace mozilla