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

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

Issue 866633002: partial PageClickTracker migration to RenderFrameObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make test happy Created 5 years, 10 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
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 "base/metrics/histogram.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/spellcheck_marker.h" 10 #include "chrome/common/spellcheck_marker.h"
11 #include "chrome/common/spellcheck_messages.h" 11 #include "chrome/common/spellcheck_messages.h"
12 #include "chrome/common/spellcheck_result.h" 12 #include "chrome/common/spellcheck_result.h"
13 #include "chrome/renderer/spellchecker/spellcheck.h" 13 #include "chrome/renderer/spellchecker/spellcheck.h"
14 #include "content/public/renderer/render_view.h" 14 #include "content/public/renderer/render_view.h"
15 #include "third_party/WebKit/public/platform/WebVector.h" 15 #include "third_party/WebKit/public/platform/WebVector.h"
16 #include "third_party/WebKit/public/web/WebDocument.h"
16 #include "third_party/WebKit/public/web/WebElement.h" 17 #include "third_party/WebKit/public/web/WebElement.h"
17 #include "third_party/WebKit/public/web/WebFrame.h" 18 #include "third_party/WebKit/public/web/WebFrame.h"
18 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" 19 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
19 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" 20 #include "third_party/WebKit/public/web/WebTextCheckingResult.h"
20 #include "third_party/WebKit/public/web/WebTextDecorationType.h" 21 #include "third_party/WebKit/public/web/WebTextDecorationType.h"
21 #include "third_party/WebKit/public/web/WebView.h" 22 #include "third_party/WebKit/public/web/WebView.h"
22 23
24 using blink::WebElement;
23 using blink::WebFrame; 25 using blink::WebFrame;
24 using blink::WebString; 26 using blink::WebString;
25 using blink::WebTextCheckingCompletion; 27 using blink::WebTextCheckingCompletion;
26 using blink::WebTextCheckingResult; 28 using blink::WebTextCheckingResult;
27 using blink::WebTextDecorationType; 29 using blink::WebTextDecorationType;
28 using blink::WebVector; 30 using blink::WebVector;
29 31
30 static_assert(int(blink::WebTextDecorationTypeSpelling) == 32 static_assert(int(blink::WebTextDecorationTypeSpelling) ==
31 int(SpellCheckResult::SPELLING), "mismatching enums"); 33 int(SpellCheckResult::SPELLING), "mismatching enums");
32 static_assert(int(blink::WebTextDecorationTypeGrammar) == 34 static_assert(int(blink::WebTextDecorationTypeGrammar) ==
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 IPC_MESSAGE_HANDLER(SpellCheckMsg_RespondTextCheck, OnRespondTextCheck) 104 IPC_MESSAGE_HANDLER(SpellCheckMsg_RespondTextCheck, OnRespondTextCheck)
103 IPC_MESSAGE_HANDLER(SpellCheckMsg_ToggleSpellPanel, OnToggleSpellPanel) 105 IPC_MESSAGE_HANDLER(SpellCheckMsg_ToggleSpellPanel, OnToggleSpellPanel)
104 #endif 106 #endif
105 IPC_MESSAGE_UNHANDLED(handled = false) 107 IPC_MESSAGE_UNHANDLED(handled = false)
106 IPC_END_MESSAGE_MAP() 108 IPC_END_MESSAGE_MAP()
107 return handled; 109 return handled;
108 } 110 }
109 111
110 void SpellCheckProvider::FocusedNodeChanged(const blink::WebNode& unused) { 112 void SpellCheckProvider::FocusedNodeChanged(const blink::WebNode& unused) {
111 #if defined(OS_MACOSX) 113 #if defined(OS_MACOSX)
112 bool enabled = false; 114 WebFrame* frame = render_view()->GetWebView()->focusedFrame();
113 blink::WebElement element = render_view()->GetFocusedElement(); 115 WebElement element = frame->document().isNull() ? WebElement() :
114 if (!element.isNull()) 116 frame->document().focusedElement();
115 enabled = render_view()->IsEditableNode(element); 117 bool enabled = !element.isNull() && render_view()->IsEditableNode(element);
116 118
117 bool checked = false; 119 bool checked = enabled && render_view()->GetWebView() &&
118 if (enabled && render_view()->GetWebView()) { 120 frame->isContinuousSpellCheckingEnabled();
119 WebFrame* frame = render_view()->GetWebView()->focusedFrame();
120 if (frame->isContinuousSpellCheckingEnabled())
121 checked = true;
122 }
123 121
124 Send(new SpellCheckHostMsg_ToggleSpellCheck(routing_id(), enabled, checked)); 122 Send(new SpellCheckHostMsg_ToggleSpellCheck(routing_id(), enabled, checked));
125 #endif // OS_MACOSX 123 #endif // OS_MACOSX
126 } 124 }
127 125
128 void SpellCheckProvider::spellCheck( 126 void SpellCheckProvider::spellCheck(
129 const WebString& text, 127 const WebString& text,
130 int& offset, 128 int& offset,
131 int& length, 129 int& length,
132 WebVector<WebString>* optional_suggestions) { 130 WebVector<WebString>* optional_suggestions) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 results[i].length = last_results_[i].length; 351 results[i].length = last_results_[i].length;
354 results[i].replacement = last_results_[i].replacement; 352 results[i].replacement = last_results_[i].replacement;
355 } 353 }
356 completion->didFinishCheckingText(results); 354 completion->didFinishCheckingText(results);
357 return true; 355 return true;
358 } 356 }
359 } 357 }
360 358
361 return false; 359 return false;
362 } 360 }
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/page_click_tracker_browsertest.cc ('k') | components/autofill/content/renderer/autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698