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

Side by Side Diff: chrome/renderer/spellchecker/spellcheck_language.cc

Issue 105493002: Use base namespace for string16 in chrome/renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/renderer/spellchecker/spellcheck_language.h" 5 #include "chrome/renderer/spellchecker/spellcheck_language.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" 8 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
9 #include "chrome/renderer/spellchecker/spelling_engine.h" 9 #include "chrome/renderer/spellchecker/spelling_engine.h"
10 10
(...skipping 20 matching lines...) Expand all
31 DCHECK(platform_spelling_engine_.get()); 31 DCHECK(platform_spelling_engine_.get());
32 return platform_spelling_engine_->InitializeIfNeeded(); 32 return platform_spelling_engine_->InitializeIfNeeded();
33 } 33 }
34 34
35 bool SpellcheckLanguage::SpellCheckWord( 35 bool SpellcheckLanguage::SpellCheckWord(
36 const char16* in_word, 36 const char16* in_word,
37 int in_word_len, 37 int in_word_len,
38 int tag, 38 int tag,
39 int* misspelling_start, 39 int* misspelling_start,
40 int* misspelling_len, 40 int* misspelling_len,
41 std::vector<string16>* optional_suggestions) { 41 std::vector<base::string16>* optional_suggestions) {
42 DCHECK(in_word_len >= 0); 42 DCHECK(in_word_len >= 0);
43 DCHECK(misspelling_start && misspelling_len) << "Out vars must be given."; 43 DCHECK(misspelling_start && misspelling_len) << "Out vars must be given.";
44 44
45 // Do nothing if we need to delay initialization. (Rather than blocking, 45 // Do nothing if we need to delay initialization. (Rather than blocking,
46 // report the word as correctly spelled.) 46 // report the word as correctly spelled.)
47 if (InitializeIfNeeded()) 47 if (InitializeIfNeeded())
48 return true; 48 return true;
49 49
50 // Do nothing if spell checking is disabled. 50 // Do nothing if spell checking is disabled.
51 if (!platform_spelling_engine_.get() || 51 if (!platform_spelling_engine_.get() ||
52 !platform_spelling_engine_->IsEnabled()) 52 !platform_spelling_engine_->IsEnabled())
53 return true; 53 return true;
54 54
55 *misspelling_start = 0; 55 *misspelling_start = 0;
56 *misspelling_len = 0; 56 *misspelling_len = 0;
57 if (in_word_len == 0) 57 if (in_word_len == 0)
58 return true; // No input means always spelled correctly. 58 return true; // No input means always spelled correctly.
59 59
60 string16 word; 60 base::string16 word;
61 int word_start; 61 int word_start;
62 int word_length; 62 int word_length;
63 if (!text_iterator_.IsInitialized() && 63 if (!text_iterator_.IsInitialized() &&
64 !text_iterator_.Initialize(&character_attributes_, true)) { 64 !text_iterator_.Initialize(&character_attributes_, true)) {
65 // We failed to initialize text_iterator_, return as spelled correctly. 65 // We failed to initialize text_iterator_, return as spelled correctly.
66 VLOG(1) << "Failed to initialize SpellcheckWordIterator"; 66 VLOG(1) << "Failed to initialize SpellcheckWordIterator";
67 return true; 67 return true;
68 } 68 }
69 69
70 text_iterator_.SetText(in_word, in_word_len); 70 text_iterator_.SetText(in_word, in_word_len);
(...skipping 20 matching lines...) Expand all
91 return false; 91 return false;
92 } 92 }
93 93
94 return true; 94 return true;
95 } 95 }
96 96
97 // Returns whether or not the given string is a valid contraction. 97 // Returns whether or not the given string is a valid contraction.
98 // This function is a fall-back when the SpellcheckWordIterator class 98 // This function is a fall-back when the SpellcheckWordIterator class
99 // returns a concatenated word which is not in the selected dictionary 99 // returns a concatenated word which is not in the selected dictionary
100 // (e.g. "in'n'out") but each word is valid. 100 // (e.g. "in'n'out") but each word is valid.
101 bool SpellcheckLanguage::IsValidContraction(const string16& contraction, 101 bool SpellcheckLanguage::IsValidContraction(const base::string16& contraction,
102 int tag) { 102 int tag) {
103 if (!contraction_iterator_.IsInitialized() && 103 if (!contraction_iterator_.IsInitialized() &&
104 !contraction_iterator_.Initialize(&character_attributes_, false)) { 104 !contraction_iterator_.Initialize(&character_attributes_, false)) {
105 // We failed to initialize the word iterator, return as spelled correctly. 105 // We failed to initialize the word iterator, return as spelled correctly.
106 VLOG(1) << "Failed to initialize contraction_iterator_"; 106 VLOG(1) << "Failed to initialize contraction_iterator_";
107 return true; 107 return true;
108 } 108 }
109 109
110 contraction_iterator_.SetText(contraction.c_str(), contraction.length()); 110 contraction_iterator_.SetText(contraction.c_str(), contraction.length());
111 111
112 string16 word; 112 base::string16 word;
113 int word_start; 113 int word_start;
114 int word_length; 114 int word_length;
115 115
116 DCHECK(platform_spelling_engine_.get()); 116 DCHECK(platform_spelling_engine_.get());
117 while (contraction_iterator_.GetNextWord(&word, &word_start, &word_length)) { 117 while (contraction_iterator_.GetNextWord(&word, &word_start, &word_length)) {
118 if (!platform_spelling_engine_->CheckSpelling(word, tag)) 118 if (!platform_spelling_engine_->CheckSpelling(word, tag))
119 return false; 119 return false;
120 } 120 }
121 return true; 121 return true;
122 } 122 }
123 123
124 bool SpellcheckLanguage::IsEnabled() { 124 bool SpellcheckLanguage::IsEnabled() {
125 DCHECK(platform_spelling_engine_.get()); 125 DCHECK(platform_spelling_engine_.get());
126 return platform_spelling_engine_->IsEnabled(); 126 return platform_spelling_engine_->IsEnabled();
127 } 127 }
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck_language.h ('k') | chrome/renderer/spellchecker/spellcheck_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698