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");