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.
5 #include "chrome/browser/spellchecker/spellcheck_action.h"
7 #include "base/logging.h"
8 #include "base/values.h"
10 SpellcheckAction::SpellcheckAction() : type(TYPE_PENDING
), index(-1) {}
12 SpellcheckAction::SpellcheckAction(SpellcheckActionType type
,
15 : type(type
), index(index
), value(value
) {}
17 SpellcheckAction::~SpellcheckAction() {}
19 bool SpellcheckAction::IsFinal() const {
20 return type
== TYPE_ADD_TO_DICT
||
21 type
== TYPE_IGNORE
||
22 type
== TYPE_IN_DICTIONARY
||
23 type
== TYPE_MANUALLY_CORRECTED
||
24 type
== TYPE_NO_ACTION
||
28 void SpellcheckAction::Finalize() {
31 type
= TYPE_NO_ACTION
;
33 case TYPE_PENDING_IGNORE
:
42 base::DictionaryValue
* SpellcheckAction::Serialize() const {
43 base::DictionaryValue
* result
= new base::DictionaryValue
;
46 result
->SetString("actionType", "SELECT");
47 result
->SetInteger("actionTargetIndex", index
);
49 case TYPE_ADD_TO_DICT
:
50 result
->SetString("actionType", "ADD_TO_DICT");
53 result
->SetString("actionType", "IGNORE");
55 case TYPE_IN_DICTIONARY
:
56 result
->SetString("actionType", "IN_DICTIONARY");
59 result
->SetString("actionType", "NO_ACTION");
61 case TYPE_MANUALLY_CORRECTED
:
62 result
->SetString("actionType", "MANUALLY_CORRECTED");
63 result
->SetString("actionTargetValue", value
);
66 case TYPE_PENDING_IGNORE
:
67 result
->SetString("actionType", "PENDING");