Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.cpp
Line
Count
Source (jump to first uncovered line)
1
/* vim: set ts=2 sw=2 sts=2 tw=80: */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "RemoteSpellCheckEngineParent.h"
7
#include "mozilla/Unused.h"
8
#include "mozilla/mozSpellChecker.h"
9
#include "nsServiceManagerUtils.h"
10
11
namespace mozilla {
12
13
RemoteSpellcheckEngineParent::RemoteSpellcheckEngineParent()
14
0
{
15
0
  mSpellChecker = mozSpellChecker::Create();
16
0
}
17
18
RemoteSpellcheckEngineParent::~RemoteSpellcheckEngineParent()
19
0
{
20
0
}
21
22
mozilla::ipc::IPCResult
23
RemoteSpellcheckEngineParent::RecvSetDictionary(
24
  const nsString& aDictionary,
25
  bool* success)
26
0
{
27
0
  nsresult rv = mSpellChecker->SetCurrentDictionary(aDictionary);
28
0
  *success = NS_SUCCEEDED(rv);
29
0
  return IPC_OK();
30
0
}
31
32
mozilla::ipc::IPCResult
33
RemoteSpellcheckEngineParent::RecvSetDictionaryFromList(
34
                                nsTArray<nsString>&& aList,
35
                                SetDictionaryFromListResolver&& aResolve)
36
0
{
37
0
  for (auto& dictionary : aList) {
38
0
    nsresult rv = mSpellChecker->SetCurrentDictionary(dictionary);
39
0
    if (NS_SUCCEEDED(rv)) {
40
0
      aResolve(Tuple<const bool&, const nsString&>(true, dictionary));
41
0
      return IPC_OK();
42
0
    }
43
0
  }
44
0
  aResolve(Tuple<const bool&, const nsString&>(false, EmptyString()));
45
0
  return IPC_OK();
46
0
}
47
48
mozilla::ipc::IPCResult
49
RemoteSpellcheckEngineParent::RecvCheck(
50
  const nsString& aWord,
51
  bool* aIsMisspelled)
52
0
{
53
0
  nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, nullptr);
54
0
55
0
  // If CheckWord failed, we can't tell whether the word is correctly spelled.
56
0
  if (NS_FAILED(rv))
57
0
    *aIsMisspelled = false;
58
0
  return IPC_OK();
59
0
}
60
61
mozilla::ipc::IPCResult
62
RemoteSpellcheckEngineParent::RecvCheckAndSuggest(
63
  const nsString& aWord,
64
  bool* aIsMisspelled,
65
  InfallibleTArray<nsString>* aSuggestions)
66
0
{
67
0
  nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, aSuggestions);
68
0
  if (NS_FAILED(rv)) {
69
0
    aSuggestions->Clear();
70
0
    *aIsMisspelled = false;
71
0
  }
72
0
  return IPC_OK();
73
0
}
74
75
void
76
RemoteSpellcheckEngineParent::ActorDestroy(ActorDestroyReason aWhy)
77
0
{
78
0
}
79
80
} // namespace mozilla