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

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

Issue 11308339: [Spellcheck] Added UMA metrics for WebKit API usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to HEAD Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_provider.h" 5 #include "chrome/renderer/spellchecker/spellcheck_provider.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h"
8 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/spellcheck_messages.h" 10 #include "chrome/common/spellcheck_messages.h"
10 #include "chrome/common/spellcheck_result.h" 11 #include "chrome/common/spellcheck_result.h"
11 #include "chrome/renderer/spellchecker/spellcheck.h" 12 #include "chrome/renderer/spellchecker/spellcheck.h"
12 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_view.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple tion.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple tion.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult .h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult .h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingType.h " 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingType.h "
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void SpellCheckProvider::spellCheck( 138 void SpellCheckProvider::spellCheck(
138 const WebString& text, 139 const WebString& text,
139 int& offset, 140 int& offset,
140 int& length, 141 int& length,
141 WebVector<WebString>* optional_suggestions) { 142 WebVector<WebString>* optional_suggestions) {
142 string16 word(text); 143 string16 word(text);
143 std::vector<string16> suggestions; 144 std::vector<string16> suggestions;
144 spellcheck_->SpellCheckWord( 145 spellcheck_->SpellCheckWord(
145 word.c_str(), word.size(), routing_id(), 146 word.c_str(), word.size(), routing_id(),
146 &offset, &length, optional_suggestions ? & suggestions : NULL); 147 &offset, &length, optional_suggestions ? & suggestions : NULL);
147 if (optional_suggestions) 148 if (optional_suggestions) {
148 *optional_suggestions = suggestions; 149 UMA_HISTOGRAM_COUNTS("SpellCheck.api.check.suggestions", word.size());
149 if (!optional_suggestions) { 150 } else {
151 UMA_HISTOGRAM_COUNTS("SpellCheck.api.check", word.size());
150 // If optional_suggestions is not requested, the API is called 152 // If optional_suggestions is not requested, the API is called
151 // for marking. So we use this for counting markable words. 153 // for marking. So we use this for counting markable words.
152 Send(new SpellCheckHostMsg_NotifyChecked(routing_id(), word, 0 < length)); 154 Send(new SpellCheckHostMsg_NotifyChecked(routing_id(), word, 0 < length));
153 } 155 }
154 } 156 }
155 157
156 void SpellCheckProvider::checkTextOfParagraph( 158 void SpellCheckProvider::checkTextOfParagraph(
157 const WebKit::WebString& text, 159 const WebKit::WebString& text,
158 WebKit::WebTextCheckingTypeMask mask, 160 WebKit::WebTextCheckingTypeMask mask,
159 WebKit::WebVector<WebKit::WebTextCheckingResult>* results) { 161 WebKit::WebVector<WebKit::WebTextCheckingResult>* results) {
160 #if !defined(OS_MACOSX) 162 #if !defined(OS_MACOSX)
161 // Since Mac has its own spell checker, this method will not be used on Mac. 163 // Since Mac has its own spell checker, this method will not be used on Mac.
162 164
163 if (!results) 165 if (!results)
164 return; 166 return;
165 167
166 if (!(mask & WebKit::WebTextCheckingTypeSpelling)) 168 if (!(mask & WebKit::WebTextCheckingTypeSpelling))
167 return; 169 return;
168 170
169 spellcheck_->SpellCheckParagraph(string16(text), results); 171 spellcheck_->SpellCheckParagraph(string16(text), results);
172 UMA_HISTOGRAM_COUNTS("SpellCheck.api.paragraph", text.length());
170 #endif 173 #endif
171 } 174 }
172 175
173 void SpellCheckProvider::requestCheckingOfText( 176 void SpellCheckProvider::requestCheckingOfText(
174 const WebString& text, 177 const WebString& text,
175 WebTextCheckingCompletion* completion) { 178 WebTextCheckingCompletion* completion) {
176 RequestTextChecking(text, completion); 179 RequestTextChecking(text, completion);
180 UMA_HISTOGRAM_COUNTS("SpellCheck.api.async", text.length());
177 } 181 }
178 182
179 WebString SpellCheckProvider::autoCorrectWord(const WebString& word) { 183 WebString SpellCheckProvider::autoCorrectWord(const WebString& word) {
180 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 184 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
181 if (command_line.HasSwitch(switches::kEnableSpellingAutoCorrect)) 185 if (command_line.HasSwitch(switches::kEnableSpellingAutoCorrect)) {
186 UMA_HISTOGRAM_COUNTS("SpellCheck.api.autocorrect", word.length());
182 return spellcheck_->GetAutoCorrectionWord(word, routing_id()); 187 return spellcheck_->GetAutoCorrectionWord(word, routing_id());
188 }
183 return string16(); 189 return string16();
184 } 190 }
185 191
186 void SpellCheckProvider::showSpellingUI(bool show) { 192 void SpellCheckProvider::showSpellingUI(bool show) {
187 #if defined(OS_MACOSX) 193 #if defined(OS_MACOSX)
194 UMA_HISTOGRAM_BOOLEAN("SpellCheck.api.showUI", show);
188 Send(new SpellCheckHostMsg_ShowSpellingPanel(routing_id(), show)); 195 Send(new SpellCheckHostMsg_ShowSpellingPanel(routing_id(), show));
189 #endif 196 #endif
190 } 197 }
191 198
192 bool SpellCheckProvider::isShowingSpellingUI() { 199 bool SpellCheckProvider::isShowingSpellingUI() {
193 return spelling_panel_visible_; 200 return spelling_panel_visible_;
194 } 201 }
195 202
196 void SpellCheckProvider::updateSpellingUIWithMisspelledWord( 203 void SpellCheckProvider::updateSpellingUIWithMisspelledWord(
197 const WebString& word) { 204 const WebString& word) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 results[i].replacement = last_results_[i].replacement; 348 results[i].replacement = last_results_[i].replacement;
342 } 349 }
343 completion->didFinishCheckingText(results); 350 completion->didFinishCheckingText(results);
344 return true; 351 return true;
345 } 352 }
346 } 353 }
347 354
348 return false; 355 return false;
349 } 356 }
350 #endif 357 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698