| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ | 6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 public: | 45 public: |
| 46 explicit SpellingMenuObserver(RenderViewContextMenuProxy* proxy); | 46 explicit SpellingMenuObserver(RenderViewContextMenuProxy* proxy); |
| 47 ~SpellingMenuObserver() override; | 47 ~SpellingMenuObserver() override; |
| 48 | 48 |
| 49 // RenderViewContextMenuObserver implementation. | 49 // RenderViewContextMenuObserver implementation. |
| 50 void InitMenu(const content::ContextMenuParams& params) override; | 50 void InitMenu(const content::ContextMenuParams& params) override; |
| 51 bool IsCommandIdSupported(int command_id) override; | 51 bool IsCommandIdSupported(int command_id) override; |
| 52 bool IsCommandIdChecked(int command_id) override; | 52 bool IsCommandIdChecked(int command_id) override; |
| 53 bool IsCommandIdEnabled(int command_id) override; | 53 bool IsCommandIdEnabled(int command_id) override; |
| 54 void ExecuteCommand(int command_id) override; | 54 void ExecuteCommand(int command_id) override; |
| 55 void OnMenuCancel() override; | |
| 56 | 55 |
| 57 // A callback function called when the Spelling service finishes checking a | 56 // A callback function called when the Spelling service finishes checking a |
| 58 // misspelled word. | 57 // misspelled word. |
| 59 void OnTextCheckComplete( | 58 void OnTextCheckComplete( |
| 60 SpellingServiceClient::ServiceType type, | 59 SpellingServiceClient::ServiceType type, |
| 61 bool success, | 60 bool success, |
| 62 const base::string16& text, | 61 const base::string16& text, |
| 63 const std::vector<SpellCheckResult>& results); | 62 const std::vector<SpellCheckResult>& results); |
| 64 | 63 |
| 65 private: | 64 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 // A flag represending whether a JSON-RPC call to the Spelling service | 84 // A flag represending whether a JSON-RPC call to the Spelling service |
| 86 // finished successfully and its response had a suggestion not included in the | 85 // finished successfully and its response had a suggestion not included in the |
| 87 // ones provided by the local spellchecker. When this flag is true, we enable | 86 // ones provided by the local spellchecker. When this flag is true, we enable |
| 88 // the context-menu item so users can choose it. | 87 // the context-menu item so users can choose it. |
| 89 bool succeeded_; | 88 bool succeeded_; |
| 90 | 89 |
| 91 // The misspelled word. When we choose the "Add to dictionary" item, we add | 90 // The misspelled word. When we choose the "Add to dictionary" item, we add |
| 92 // this word to the custom-word dictionary. | 91 // this word to the custom-word dictionary. |
| 93 base::string16 misspelled_word_; | 92 base::string16 misspelled_word_; |
| 94 | 93 |
| 95 // The hash identifier for the misspelled word. Used for collecting user | |
| 96 // feedback to spellcheck suggestions. | |
| 97 uint32_t misspelling_hash_; | |
| 98 | |
| 99 // The string representing the result of this call. This string is a | 94 // The string representing the result of this call. This string is a |
| 100 // suggestion when this call finished successfully. Otherwise it is error | 95 // suggestion when this call finished successfully. Otherwise it is error |
| 101 // text. Until we receive a response from the Spelling service, this string | 96 // text. Until we receive a response from the Spelling service, this string |
| 102 // stores the input string. (Since the Spelling service sends only misspelled | 97 // stores the input string. (Since the Spelling service sends only misspelled |
| 103 // words, we replace these misspelled words in the input text with the | 98 // words, we replace these misspelled words in the input text with the |
| 104 // suggested words to create suggestion text. | 99 // suggested words to create suggestion text. |
| 105 base::string16 result_; | 100 base::string16 result_; |
| 106 | 101 |
| 107 // The URLFetcher object used for sending a JSON-RPC request. | 102 // The URLFetcher object used for sending a JSON-RPC request. |
| 108 std::unique_ptr<SpellingServiceClient> client_; | 103 std::unique_ptr<SpellingServiceClient> client_; |
| 109 | 104 |
| 110 // A timer used for loading animation. | 105 // A timer used for loading animation. |
| 111 base::RepeatingTimer animation_timer_; | 106 base::RepeatingTimer animation_timer_; |
| 112 | 107 |
| 113 // Flag indicating whether online spelling correction service is enabled. When | 108 // Flag indicating whether online spelling correction service is enabled. When |
| 114 // this variable is true and we right-click a misspelled word, we send a | 109 // this variable is true and we right-click a misspelled word, we send a |
| 115 // JSON-RPC request to the service and retrieve suggestions. | 110 // JSON-RPC request to the service and retrieve suggestions. |
| 116 BooleanPrefMember integrate_spelling_service_; | 111 BooleanPrefMember integrate_spelling_service_; |
| 117 | 112 |
| 118 // Flag indicating whether automatic spelling correction is enabled. | 113 // Flag indicating whether automatic spelling correction is enabled. |
| 119 BooleanPrefMember autocorrect_spelling_; | 114 BooleanPrefMember autocorrect_spelling_; |
| 120 | 115 |
| 121 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserver); | 116 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserver); |
| 122 }; | 117 }; |
| 123 | 118 |
| 124 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ | 119 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ |
| OLD | NEW |