spellcheck.mojom 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module spellcheck.mojom;
  5. import "mojo/public/mojom/base/read_only_file.mojom";
  6. import "mojo/public/mojom/base/string16.mojom";
  7. // Render process interface exposed to the browser for receiving process-
  8. // wide spellcheck control and updates from the browser process.
  9. //
  10. interface SpellChecker {
  11. // Initialize the render process spellchecker. Called after startup and
  12. // also in response to a renderer's spellcheck.mojom.SpellCheckHost
  13. // RequestDictionary request.
  14. Initialize(array<SpellCheckBDictLanguage> dictionaries,
  15. array<string> custom_words,
  16. bool enable);
  17. // Custom dictionary words have been added or removed: update the local
  18. // custom word list.
  19. CustomDictionaryChanged(array<string> words_added,
  20. array<string> words_removed);
  21. };
  22. struct SpellCheckBDictLanguage {
  23. mojo_base.mojom.ReadOnlyFile? file;
  24. string language;
  25. };
  26. // Browser process interface exposed to the renderer for requesting spell-
  27. // check host services.
  28. //
  29. interface SpellCheckHost {
  30. // Asks the browser to initialize the renderer's spellcheck system. The
  31. // initialize call arrives on interface spellcheck.mojom.SpellChecker
  32. // in async response to this request.
  33. RequestDictionary();
  34. // Tracks spell checking occurrences to collect histograms, where |word|
  35. // was checked, and |misspelled| is true if |word| was misspelt.
  36. NotifyChecked(mojo_base.mojom.String16 word, bool misspelled);
  37. // Asks the host to spellcheck the |text| using a remote Spelling server
  38. // to do the spellchecking. If the remote Spelling server is available,
  39. // returns |success| true, and the spellchecked |results|.
  40. [EnableIf=USE_RENDERER_SPELLCHECKER]
  41. CallSpellingService(mojo_base.mojom.String16 text) =>
  42. (bool success, array<SpellCheckResult> results);
  43. // Asks the host to spellcheck the |text| using a platform-specific spell
  44. // checker, and returns the spellchecked |results|.
  45. // TODO(crbug.com/812959): Try not to pass |route_id|. What SpellCheckHost
  46. // needs is the render frame id, which should be passed in a cleaner way.
  47. [EnableIf=USE_BROWSER_SPELLCHECKER]
  48. RequestTextCheck(mojo_base.mojom.String16 text, int32 route_id) =>
  49. (array<SpellCheckResult> results);
  50. // Disconnects the Android spell checker session bridge.
  51. [EnableIf=is_android]
  52. DisconnectSessionBridge();
  53. // Checks the correctness of a word with a platform-specific spell checker.
  54. // TODO(groby): This needs to originate from SpellcheckProvider.
  55. // TODO(crbug.com/812959): Try not to pass |route_id|. What SpellCheckHost
  56. // needs is the render frame id, which should be passed in a cleaner way.
  57. [EnableIf=USE_BROWSER_SPELLCHECKER, Sync]
  58. CheckSpelling(mojo_base.mojom.String16 word, int32 route_id)
  59. => (bool correct);
  60. // Returns a list of suggestions for a given word with a platform-specific
  61. // spell checker.
  62. [EnableIf=USE_BROWSER_SPELLCHECKER, Sync]
  63. FillSuggestionList(mojo_base.mojom.String16 word) =>
  64. (array<mojo_base.mojom.String16> suggestions);
  65. // Completes initialization of the spellcheck service by loading dictionaries.
  66. [EnableIf=is_win]
  67. InitializeDictionaries() =>
  68. (array<SpellCheckBDictLanguage> dictionaries,
  69. array<string> custom_words,
  70. bool enable);
  71. };
  72. enum Decoration {
  73. kSpelling,
  74. kGrammar,
  75. };
  76. struct SpellCheckResult {
  77. Decoration decoration;
  78. int32 location;
  79. int32 length;
  80. array<mojo_base.mojom.String16> replacements;
  81. };