1 // Copyright (c) 2013 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 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_ACTION_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_ACTION_H_ 7 8 #include "base/strings/string16.h" 9 10 namespace base { 11 class DictionaryValue; 12 } 13 14 // User's action on a misspelled word. 15 class SpellcheckAction { 16 public: 17 // Type of spellcheck action. 18 enum SpellcheckActionType { 19 // User added the word to the dictionary and cannot take more actions on 20 // this misspelling. 21 TYPE_ADD_TO_DICT, 22 // User took a look at the suggestions in the context menu, but did not 23 // select any suggestions. The user cannot take any more actions on the 24 // misspelling, because it has been deleted from the web page. 25 TYPE_IGNORE, 26 // The misspelling is in user's custom spellcheck dictionary. The user will 27 // not see spellcheck suggestions for this misspelling. 28 TYPE_IN_DICTIONARY, 29 // The user manually corrected the word to |value|. The user cannot take 30 // more actions on this misspelling. 31 TYPE_MANUALLY_CORRECTED, 32 // The user has taken no action on the misspelling and will not take any 33 // more actions, because the misspelled text has been removed from the web 34 // page. 35 TYPE_NO_ACTION, 36 // The user has taken no action on the misspelled yet, but might take an 37 // action in the future, because the misspelling is still on the web page. 38 TYPE_PENDING, 39 // User took a look at the suggestions in the context menu, but did not 40 // select any suggestions. The user still can take further actions on the 41 // misspelling. 42 TYPE_PENDING_IGNORE, 43 // The user has selected the suggestion at |index| and cannot take more 44 // actions on this misspelling. 45 TYPE_SELECT, 46 }; 47 48 SpellcheckAction(); 49 SpellcheckAction(SpellcheckActionType type, int index, string16 value); 50 ~SpellcheckAction(); 51 52 // Returns true if the action is final and should be sent to the feedback 53 // server. Otherwise returns false. 54 bool IsFinal() const; 55 56 // Makes this action final and ready to be sent to the feedback server. The 57 // method is idempotent. Finalizing an action that is already final does 58 // nothing. 59 void Finalize(); 60 61 // Serializes the data in this object into a dictionary value. The caller owns 62 // the result. 63 base::DictionaryValue* Serialize() const; 64 65 // User action. 66 SpellcheckActionType type; 67 68 // The index for the user action, if applicable. 69 int index; 70 71 // The value for the user action, if applicable. 72 string16 value; 73 }; 74 75 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_ACTION_H_ 76