OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_IME_COMPOSITION_TEXT_H_ | 5 #ifndef CHROMEOS_IME_COMPOSITION_TEXT_H_ |
6 #define CHROMEOS_IME_COMPOSITION_TEXT_H_ | 6 #define CHROMEOS_IME_COMPOSITION_TEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
| 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/strings/string16.h" |
11 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
12 | 14 |
13 namespace chromeos { | 15 namespace chromeos { |
14 | 16 |
15 class CHROMEOS_EXPORT CompositionText { | 17 class CHROMEOS_EXPORT CompositionText { |
16 public: | 18 public: |
17 enum UnderlineType { | 19 enum UnderlineType { |
18 COMPOSITION_TEXT_UNDERLINE_SINGLE = 1, | 20 COMPOSITION_TEXT_UNDERLINE_SINGLE = 1, |
19 COMPOSITION_TEXT_UNDERLINE_DOUBLE = 2, | 21 COMPOSITION_TEXT_UNDERLINE_DOUBLE = 2, |
20 COMPOSITION_TEXT_UNDERLINE_ERROR = 4, | 22 COMPOSITION_TEXT_UNDERLINE_ERROR = 4, |
21 }; | 23 }; |
22 | 24 |
23 struct UnderlineAttribute { | 25 struct UnderlineAttribute { |
24 UnderlineType type; | 26 UnderlineType type; |
25 uint32 start_index; // The inclusive start index. | 27 uint32 start_index; // The inclusive start index. |
26 uint32 end_index; // The exclusive end index. | 28 uint32 end_index; // The exclusive end index. |
27 }; | 29 }; |
28 | 30 |
29 CompositionText(); | 31 CompositionText(); |
30 virtual ~CompositionText(); | 32 virtual ~CompositionText(); |
31 | 33 |
32 // Accessors | 34 // Accessors |
33 const std::string& text() const { return text_; } | 35 const base::string16& text() const { return text_; } |
34 void set_text(const std::string& text) { text_ = text; } | 36 void set_text(const base::string16& text) { text_ = text; } |
35 | 37 |
36 const std::vector<UnderlineAttribute>& underline_attributes() const { | 38 const std::vector<UnderlineAttribute>& underline_attributes() const { |
37 return underline_attributes_; | 39 return underline_attributes_; |
38 } | 40 } |
39 | 41 |
40 std::vector<UnderlineAttribute>* mutable_underline_attributes() { | 42 std::vector<UnderlineAttribute>* mutable_underline_attributes() { |
41 return &underline_attributes_; | 43 return &underline_attributes_; |
42 } | 44 } |
43 | 45 |
44 uint32 selection_start() const { return selection_start_; } | 46 uint32 selection_start() const { return selection_start_; } |
45 void set_selection_start(uint32 selection_start) { | 47 void set_selection_start(uint32 selection_start) { |
46 selection_start_ = selection_start; | 48 selection_start_ = selection_start; |
47 } | 49 } |
48 | 50 |
49 uint32 selection_end() const { return selection_end_; } | 51 uint32 selection_end() const { return selection_end_; } |
50 void set_selection_end(uint32 selection_end) { | 52 void set_selection_end(uint32 selection_end) { |
51 selection_end_ = selection_end; | 53 selection_end_ = selection_end; |
52 } | 54 } |
53 | 55 |
54 void CopyFrom(const CompositionText& obj); | 56 void CopyFrom(const CompositionText& obj); |
55 | 57 |
56 private: | 58 private: |
57 std::string text_; | 59 base::string16 text_; |
58 std::vector<UnderlineAttribute> underline_attributes_; | 60 std::vector<UnderlineAttribute> underline_attributes_; |
59 uint32 selection_start_; | 61 uint32 selection_start_; |
60 uint32 selection_end_; | 62 uint32 selection_end_; |
61 | 63 |
62 DISALLOW_COPY_AND_ASSIGN(CompositionText); | 64 DISALLOW_COPY_AND_ASSIGN(CompositionText); |
63 }; | 65 }; |
64 | 66 |
65 } // namespace chromeos | 67 } // namespace chromeos |
66 | 68 |
67 #endif // CHROMEOS_IME_COMPOSITION_TEXT_H_ | 69 #endif // CHROMEOS_IME_COMPOSITION_TEXT_H_ |
OLD | NEW |