Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/spellchecker/misspelling.h

Issue 2244083002: Componentize spellcheck [4]: spellcheck/browser and android java-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 // An object to store user feedback to a single spellcheck suggestion.
6 //
7 // Stores the spellcheck suggestion, its uint32_t hash identifier, and user's
8 // feedback. The feedback is indirect, in the sense that we record user's
9 // |action| instead of asking them how they feel about a spellcheck suggestion.
10 // The object can serialize itself.
11
12 #ifndef CHROME_BROWSER_SPELLCHECKER_MISSPELLING_H_
13 #define CHROME_BROWSER_SPELLCHECKER_MISSPELLING_H_
14
15 #include <stddef.h>
16 #include <stdint.h>
17
18 #include <memory>
19 #include <vector>
20
21 #include "base/time/time.h"
22 #include "chrome/browser/spellchecker/spellcheck_action.h"
23
24 // Stores user feedback to a spellcheck suggestion. Sample usage:
25 // Misspelling misspelling.
26 // misspelling.context = base::ASCIIToUTF16("Helllo world");
27 // misspelling.location = 0;
28 // misspelling.length = 6;
29 // misspelling.suggestions =
30 // std::vector<base::string16>(1, base::ASCIIToUTF16("Hello"));
31 // misspelling.hash = GenerateRandomHash();
32 // misspelling.action.set_type(SpellcheckAction::TYPE_SELECT);
33 // misspelling.action.set_index(0);
34 // Process(SerializeMisspelling(misspelling));
35 struct Misspelling {
36 Misspelling();
37 Misspelling(const base::string16& context,
38 size_t location,
39 size_t length,
40 const std::vector<base::string16>& suggestions,
41 uint32_t hash);
42 Misspelling(const Misspelling& other);
43 ~Misspelling();
44
45 // A several-word text snippet that immediately surrounds the misspelling.
46 base::string16 context;
47
48 // The number of characters between the beginning of |context| and the first
49 // misspelled character.
50 size_t location;
51
52 // The number of characters in the misspelling.
53 size_t length;
54
55 // Spelling suggestions.
56 std::vector<base::string16> suggestions;
57
58 // The hash that identifies the misspelling.
59 uint32_t hash;
60
61 // User action.
62 SpellcheckAction action;
63
64 // The time when the user applied the action.
65 base::Time timestamp;
66 };
67
68 // Serializes the data in this object into a dictionary value.
69 std::unique_ptr<base::DictionaryValue> SerializeMisspelling(
70 const Misspelling& misspelling);
71
72 // Returns the substring of |context| that begins at |location| and contains
73 // |length| characters.
74 base::string16 GetMisspelledString(const Misspelling& misspelling);
75
76 // Returns the approximate size of the misspelling when serialized.
77 size_t ApproximateSerializedSize(const Misspelling& misspelling);
78
79 #endif // CHROME_BROWSER_SPELLCHECKER_MISSPELLING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698