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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 6392045: Integrating Mac OS Grammar checker into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Caught up some more missings. I'm sorry for the distraction... Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" 140 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h"
141 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 141 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
142 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 142 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
143 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 143 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
144 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" 144 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h"
145 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 145 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
146 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 146 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
147 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 147 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
148 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h " 148 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h "
149 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 149 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
150 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple tion.h"
151 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingResult .h"
150 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 152 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
151 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 153 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
152 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 154 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
153 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" 155 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
154 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 156 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
155 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 157 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
156 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" 158 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
157 #include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h" 159 #include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h"
158 #include "third_party/skia/include/core/SkBitmap.h" 160 #include "third_party/skia/include/core/SkBitmap.h"
159 #include "ui/base/message_box_flags.h" 161 #include "ui/base/message_box_flags.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 using WebKit::WebRect; 255 using WebKit::WebRect;
254 using WebKit::WebScriptSource; 256 using WebKit::WebScriptSource;
255 using WebKit::WebSearchableFormData; 257 using WebKit::WebSearchableFormData;
256 using WebKit::WebSecurityOrigin; 258 using WebKit::WebSecurityOrigin;
257 using WebKit::WebSettings; 259 using WebKit::WebSettings;
258 using WebKit::WebSharedWorker; 260 using WebKit::WebSharedWorker;
259 using WebKit::WebSize; 261 using WebKit::WebSize;
260 using WebKit::WebStorageNamespace; 262 using WebKit::WebStorageNamespace;
261 using WebKit::WebString; 263 using WebKit::WebString;
262 using WebKit::WebTextAffinity; 264 using WebKit::WebTextAffinity;
265 using WebKit::WebTextCheckingResult;
263 using WebKit::WebTextDirection; 266 using WebKit::WebTextDirection;
264 using WebKit::WebURL; 267 using WebKit::WebURL;
265 using WebKit::WebURLError; 268 using WebKit::WebURLError;
266 using WebKit::WebURLRequest; 269 using WebKit::WebURLRequest;
267 using WebKit::WebURLResponse; 270 using WebKit::WebURLResponse;
268 using WebKit::WebVector; 271 using WebKit::WebVector;
269 using WebKit::WebView; 272 using WebKit::WebView;
270 using WebKit::WebWidget; 273 using WebKit::WebWidget;
271 using WebKit::WebWindowFeatures; 274 using WebKit::WebWindowFeatures;
272 using WebKit::WebWorker; 275 using WebKit::WebWorker;
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) 988 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy)
986 #if defined(OS_MACOSX) 989 #if defined(OS_MACOSX)
987 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) 990 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
988 #endif 991 #endif
989 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) 992 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste)
990 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) 993 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace)
991 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellPanel, OnToggleSpellPanel) 994 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellPanel, OnToggleSpellPanel)
992 IPC_MESSAGE_HANDLER(ViewMsg_AdvanceToNextMisspelling, 995 IPC_MESSAGE_HANDLER(ViewMsg_AdvanceToNextMisspelling,
993 OnAdvanceToNextMisspelling) 996 OnAdvanceToNextMisspelling)
994 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck) 997 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck)
998 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_RespondTextCheck,
999 OnRespondTextCheck);
Hironori Bono 2011/02/10 11:02:56 nit: OnRespondTextCheck -> OnSpellCheckerRespondTe
gmorrita 2011/02/17 11:39:44 Done.
995 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 1000 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
996 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 1001 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
997 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 1002 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
998 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 1003 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
999 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 1004 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
1000 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 1005 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
1001 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) 1006 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck)
1002 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 1007 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1003 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, 1008 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL,
1004 OnSetContentSettingsForLoadingURL) 1009 OnSetContentSettingsForLoadingURL)
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 void RenderView::OnToggleSpellPanel(bool is_currently_visible) { 1593 void RenderView::OnToggleSpellPanel(bool is_currently_visible) {
1589 if (!webview()) 1594 if (!webview())
1590 return; 1595 return;
1591 // We need to tell the webView whether the spelling panel is visible or not so 1596 // We need to tell the webView whether the spelling panel is visible or not so
1592 // that it won't need to make ipc calls later. 1597 // that it won't need to make ipc calls later.
1593 spelling_panel_visible_ = is_currently_visible; 1598 spelling_panel_visible_ = is_currently_visible;
1594 webview()->focusedFrame()->executeCommand( 1599 webview()->focusedFrame()->executeCommand(
1595 WebString::fromUTF8("ToggleSpellPanel")); 1600 WebString::fromUTF8("ToggleSpellPanel"));
1596 } 1601 }
1597 1602
1603 void RenderView::OnRespondTextCheck(
1604 int identifier,
1605 int tag,
1606 const std::vector<WebTextCheckingResult>& results) {
1607 WebKit::WebTextCheckingCompletion* completion =
1608 text_check_completions_.Lookup(identifier);
1609 if (!completion)
1610 return;
1611 text_check_completions_.Remove(identifier);
1612 completion->didFinishCheckingText(results);
1613 }
1614
1598 void RenderView::OnToggleSpellCheck() { 1615 void RenderView::OnToggleSpellCheck() {
1599 if (!webview()) 1616 if (!webview())
1600 return; 1617 return;
1601 1618
1602 WebFrame* frame = webview()->focusedFrame(); 1619 WebFrame* frame = webview()->focusedFrame();
1603 frame->enableContinuousSpellChecking( 1620 frame->enableContinuousSpellChecking(
1604 !frame->isContinuousSpellCheckingEnabled()); 1621 !frame->isContinuousSpellCheckingEnabled());
1605 } 1622 }
1606 1623
1607 void RenderView::OnDelete() { 1624 void RenderView::OnDelete() {
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 string16 word(text); 2345 string16 word(text);
2329 RenderThread* thread = RenderThread::current(); 2346 RenderThread* thread = RenderThread::current();
2330 // Will be NULL during unit tests. 2347 // Will be NULL during unit tests.
2331 if (thread) { 2348 if (thread) {
2332 thread->spellchecker()->SpellCheckWord( 2349 thread->spellchecker()->SpellCheckWord(
2333 word.c_str(), word.size(), document_tag_, 2350 word.c_str(), word.size(), document_tag_,
2334 &misspelled_offset, &misspelled_length, NULL); 2351 &misspelled_offset, &misspelled_length, NULL);
2335 } 2352 }
2336 } 2353 }
2337 2354
2355 void RenderView::requestCheckingOfText(
2356 const WebString& text,
2357 WebKit::WebTextCheckingCompletion* completion) {
2358 // Text check (unified request for grammar and spell check) is only
2359 // available for browser process, so we do IPC instead of
2360 // asking the Spellchecker.
2361 int32 id = text_check_completions_.Add(completion);
2362 RenderThread* thread = RenderThread::current();
2363 // Will be NULL during unit tests.
2364 if (thread) {
2365 bool ok = thread->spellchecker()->RequestCheckingOfText(
2366 routing_id_, string16(text), document_tag_, id);
2367 if (ok)
2368 return;
2369 }
2370
2371 text_check_completions_.Remove(id);
2372 completion->didFinishCheckingText
2373 (std::vector<WebTextCheckingResult>());
2374 }
2375
2338 WebString RenderView::autoCorrectWord(const WebKit::WebString& word) { 2376 WebString RenderView::autoCorrectWord(const WebKit::WebString& word) {
2339 string16 autocorrect_word; 2377 string16 autocorrect_word;
2340 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 2378 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
2341 if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) { 2379 if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) {
2342 EnsureDocumentTag(); 2380 EnsureDocumentTag();
2343 RenderThread* thread = RenderThread::current(); 2381 RenderThread* thread = RenderThread::current();
2344 // Will be NULL during unit tests. 2382 // Will be NULL during unit tests.
2345 if (thread) { 2383 if (thread) {
2346 autocorrect_word = 2384 autocorrect_word =
2347 thread->spellchecker()->GetAutoCorrectionWord( 2385 thread->spellchecker()->GetAutoCorrectionWord(
(...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after
5773 } 5811 }
5774 } 5812 }
5775 5813
5776 void RenderView::OnContextMenuClosed( 5814 void RenderView::OnContextMenuClosed(
5777 const webkit_glue::CustomContextMenuContext& custom_context) { 5815 const webkit_glue::CustomContextMenuContext& custom_context) {
5778 if (custom_context.is_pepper_menu) 5816 if (custom_context.is_pepper_menu)
5779 pepper_delegate_.OnContextMenuClosed(custom_context); 5817 pepper_delegate_.OnContextMenuClosed(custom_context);
5780 else 5818 else
5781 context_menu_node_.reset(); 5819 context_menu_node_.reset();
5782 } 5820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698