1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/spellchecker/spellcheck_action.h"
#include "base/logging.h"
#include "base/values.h"
SpellcheckAction::SpellcheckAction() : type(TYPE_PENDING), index(-1) {}
SpellcheckAction::SpellcheckAction(SpellcheckActionType type,
int index,
string16 value)
: type(type), index(index), value(value) {}
SpellcheckAction::~SpellcheckAction() {}
bool SpellcheckAction::IsFinal() const {
return type == TYPE_ADD_TO_DICT ||
type == TYPE_IGNORE ||
type == TYPE_IN_DICTIONARY ||
type == TYPE_MANUALLY_CORRECTED ||
type == TYPE_NO_ACTION ||
type == TYPE_SELECT;
}
void SpellcheckAction::Finalize() {
switch (type) {
case TYPE_PENDING:
type = TYPE_NO_ACTION;
break;
case TYPE_PENDING_IGNORE:
type = TYPE_IGNORE;
break;
default:
DCHECK(IsFinal());
break;
}
}
base::DictionaryValue* SpellcheckAction::Serialize() const {
base::DictionaryValue* result = new base::DictionaryValue;
switch (type) {
case TYPE_SELECT:
result->SetString("actionType", "SELECT");
result->SetInteger("actionTargetIndex", index);
break;
case TYPE_ADD_TO_DICT:
result->SetString("actionType", "ADD_TO_DICT");
break;
case TYPE_IGNORE:
result->SetString("actionType", "IGNORE");
break;
case TYPE_IN_DICTIONARY:
result->SetString("actionType", "IN_DICTIONARY");
break;
case TYPE_NO_ACTION:
result->SetString("actionType", "NO_ACTION");
break;
case TYPE_MANUALLY_CORRECTED:
result->SetString("actionType", "MANUALLY_CORRECTED");
result->SetString("actionTargetValue", value);
break;
case TYPE_PENDING:
case TYPE_PENDING_IGNORE:
result->SetString("actionType", "PENDING");
break;
default:
NOTREACHED();
break;
}
return result;
}
|