summaryrefslogtreecommitdiff
path: root/chromium/components/spellcheck/common/spellcheck.mojom
blob: 2475c1c06dd37e7fec9a40dd457cfa9ccde5f172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module spellcheck.mojom;

import "mojo/common/file.mojom";
import "mojo/common/string16.mojom";

// Render process interface exposed to the browser for receiving process-
// wide spellcheck control and updates from the browser process.
//
interface SpellChecker {
  // Initialize the render process spellchecker. Called after startup and
  // also in response to a renderer's spellcheck::mojom::SpellCheckHost
  // RequestDictionary request.
  Initialize(array<SpellCheckBDictLanguage> dictionaries,
             array<string> custom_words,
             bool enable);

  // Custom dictionary words have been added or removed: update the local
  // custom word list.
  CustomDictionaryChanged(array<string> words_added,
                          array<string> words_removed);
};

struct SpellCheckBDictLanguage {
  mojo.common.mojom.File? file;
  string language;
};

// Browser process interface exposed to the renderer for requesting spell-
// check host services.
//
interface SpellCheckHost {
  // Asks the browser to initialize the renderer's spellcheck system. The
  // initialize call arrives on interface spellcheck::mojom::SpellChecker
  // in async response to this request.
  RequestDictionary();

  // Tracks spell checking occurrences to collect histograms, where |word|
  // was checked, and |misspelled| is true if |word| was misspelt.
  NotifyChecked(mojo.common.mojom.String16 word, bool misspelled);

  // Asks the host to spellcheck the |text| using a remote Spelling server
  // to do the spellchecking. If the remote Spelling server is available,
  // returns |success| true, and the spellchecked |results|. Note this API
  // requires a !BUILDFLAG(USE_BROWSER_SPELLCHECKER) build.
  CallSpellingService(mojo.common.mojom.String16 text) =>
      (bool success, array<SpellCheckResult> results);
};

enum Decoration {
  kSpelling,
  kGrammar,
};

struct SpellCheckResult {
  Decoration decoration;
  int32 location;
  int32 length;
  array<string> replacements;
};