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

Side by Side Diff: components/test_runner/spell_check_client.cc

Issue 2270293003: Add a switch to TestRunner to enable/disable mock spell checker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use in-class initialization 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
« no previous file with comments | « components/test_runner/spell_check_client.h ('k') | components/test_runner/test_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/test_runner/spell_check_client.h" 5 #include "components/test_runner/spell_check_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 15 matching lines...) Expand all
26 DCHECK(test_runner); 26 DCHECK(test_runner);
27 } 27 }
28 28
29 SpellCheckClient::~SpellCheckClient() { 29 SpellCheckClient::~SpellCheckClient() {
30 } 30 }
31 31
32 void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) { 32 void SpellCheckClient::SetDelegate(WebTestDelegate* delegate) {
33 delegate_ = delegate; 33 delegate_ = delegate;
34 } 34 }
35 35
36 void SpellCheckClient::SetEnabled(bool enabled) {
37 enabled_ = enabled;
38 }
39
36 // blink::WebSpellCheckClient 40 // blink::WebSpellCheckClient
37 void SpellCheckClient::spellCheck( 41 void SpellCheckClient::spellCheck(
38 const blink::WebString& text, 42 const blink::WebString& text,
39 int& misspelled_offset, 43 int& misspelled_offset,
40 int& misspelled_length, 44 int& misspelled_length,
41 blink::WebVector<blink::WebString>* optional_suggestions) { 45 blink::WebVector<blink::WebString>* optional_suggestions) {
46 if (!enabled_) {
47 misspelled_offset = 0;
48 misspelled_length = 0;
49 return;
50 }
51
42 // Check the spelling of the given text. 52 // Check the spelling of the given text.
43 spell_check_.SpellCheckWord(text, &misspelled_offset, &misspelled_length); 53 spell_check_.SpellCheckWord(text, &misspelled_offset, &misspelled_length);
44 } 54 }
45 55
46 void SpellCheckClient::requestCheckingOfText( 56 void SpellCheckClient::requestCheckingOfText(
47 const blink::WebString& text, 57 const blink::WebString& text,
48 const blink::WebVector<uint32_t>& markers, 58 const blink::WebVector<uint32_t>& markers,
49 const blink::WebVector<unsigned>& marker_offsets, 59 const blink::WebVector<unsigned>& marker_offsets,
50 blink::WebTextCheckingCompletion* completion) { 60 blink::WebTextCheckingCompletion* completion) {
51 if (text.isEmpty()) { 61 if (!enabled_ || text.isEmpty()) {
52 if (completion) 62 if (completion)
53 completion->didCancelCheckingText(); 63 completion->didCancelCheckingText();
54 return; 64 return;
55 } 65 }
56 66
57 if (last_requested_text_checking_completion_) 67 if (last_requested_text_checking_completion_)
58 last_requested_text_checking_completion_->didCancelCheckingText(); 68 last_requested_text_checking_completion_->didCancelCheckingText();
59 69
60 last_requested_text_checking_completion_ = completion; 70 last_requested_text_checking_completion_ = completion;
61 last_requested_text_check_string_ = text; 71 last_requested_text_check_string_ = text;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 &results); 115 &results);
106 } 116 }
107 last_requested_text_checking_completion_->didFinishCheckingText(results); 117 last_requested_text_checking_completion_->didFinishCheckingText(results);
108 last_requested_text_checking_completion_ = 0; 118 last_requested_text_checking_completion_ = 0;
109 119
110 if (test_runner_->shouldDumpSpellCheckCallbacks()) 120 if (test_runner_->shouldDumpSpellCheckCallbacks())
111 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); 121 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n");
112 } 122 }
113 123
114 } // namespace test_runner 124 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/spell_check_client.h ('k') | components/test_runner/test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698