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