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

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

Issue 6764001: Update the code to have the SpellCheckProvider implement WebSpellCheckClient, in preparation for ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ 5 #ifndef CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_
6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ 6 #define CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/id_map.h" 11 #include "base/id_map.h"
12 #include "content/renderer/render_view_observer.h" 12 #include "content/renderer/render_view_observer.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpellCheckClient.h "
13 14
14 class RenderView; 15 class RenderView;
15 class SpellCheck; 16 class SpellCheck;
16 17
17 namespace WebKit { 18 namespace WebKit {
18 class WebString; 19 class WebString;
19 class WebTextCheckingCompletion; 20 class WebTextCheckingCompletion;
20 struct WebTextCheckingResult; 21 struct WebTextCheckingResult;
21 } 22 }
22 23
23 // This class deals with invoking browser-side spellcheck mechanism 24 // This class deals with invoking browser-side spellcheck mechanism
24 // which is done asynchronously. 25 // which is done asynchronously.
25 class SpellCheckProvider : public RenderViewObserver { 26 class SpellCheckProvider : public RenderViewObserver,
27 public WebKit::WebSpellCheckClient {
26 public: 28 public:
27 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions; 29 typedef IDMap<WebKit::WebTextCheckingCompletion> WebTextCheckCompletions;
28 30
29 SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck); 31 SpellCheckProvider(RenderView* render_view, SpellCheck* spellcheck);
30 virtual ~SpellCheckProvider(); 32 virtual ~SpellCheckProvider();
31 33
32 // Requests async spell and grammar checker to the platform text 34 // Requests async spell and grammar checker to the platform text
33 // checker, which is available on the browser process. 35 // checker, which is available on the browser process.
34 void RequestTextChecking( 36 void RequestTextChecking(
35 const WebKit::WebString& text, 37 const WebKit::WebString& text,
36 int document_tag, 38 int document_tag,
37 WebKit::WebTextCheckingCompletion* completion); 39 WebKit::WebTextCheckingCompletion* completion);
38 40
39 // Check the availability of the platform spellchecker. 41 // Check the availability of the platform spellchecker.
40 // Makes this virtual for overriding on the unittest. 42 // Makes this virtual for overriding on the unittest.
41 virtual bool is_using_platform_spelling_engine() const; 43 virtual bool is_using_platform_spelling_engine() const;
42 44
43 // The number of ongoing IPC requests. 45 // The number of ongoing IPC requests.
44 size_t pending_text_request_size() const { 46 size_t pending_text_request_size() const {
45 return text_check_completions_.size(); 47 return text_check_completions_.size();
46 } 48 }
47 49
50 int document_tag() const { return document_tag_; }
51
48 // RenderViewObserver implementation. 52 // RenderViewObserver implementation.
49 virtual bool OnMessageReceived(const IPC::Message& message); 53 virtual bool OnMessageReceived(const IPC::Message& message);
50 54
51 private: 55 private:
52 // A message handler that receives async results for RequestTextChecking(). 56 // WebKit::WebSpellCheckClient implementation.
57 virtual void spellCheck(const WebKit::WebString& text,
58 int& offset,
59 int& length);
60 virtual void requestCheckingOfText(
61 const WebKit::WebString& text,
62 WebKit::WebTextCheckingCompletion* completion);
63 virtual WebKit::WebString autoCorrectWord(
64 const WebKit::WebString& misspelled_word);
65 virtual void showSpellingUI(bool show);
66 virtual bool isShowingSpellingUI();
67 virtual void updateSpellingUIWithMisspelledWord(
68 const WebKit::WebString& word);
69
70 void OnAdvanceToNextMisspelling();
53 void OnRespondTextCheck( 71 void OnRespondTextCheck(
54 int identifier, 72 int identifier,
55 int tag, 73 int tag,
56 const std::vector<WebKit::WebTextCheckingResult>& results); 74 const std::vector<WebKit::WebTextCheckingResult>& results);
75 void OnToggleSpellCheck();
76 void OnToggleSpellPanel(bool is_currently_visible);
77
78 // Initializes the document_tag_ member if necessary.
79 void EnsureDocumentTag();
57 80
58 // Holds ongoing spellchecking operations, assigns IDs for the IPC routing. 81 // Holds ongoing spellchecking operations, assigns IDs for the IPC routing.
59 WebTextCheckCompletions text_check_completions_; 82 WebTextCheckCompletions text_check_completions_;
83
84 #if defined(OS_MACOSX)
gmorrita 2011/03/29 18:28:37 I don't think this ifdef is necessary. How about t
jam 2011/03/29 18:37:54 I was just copying over the existing logic from Re
85 // True if the current RenderView has been assigned a document tag.
86 bool has_document_tag_;
87 #endif
88
89 int document_tag_;
90
91 // True if the browser is showing the spelling panel for us.
92 bool spelling_panel_visible_;
93
60 // Spellcheck implementation for use. Weak reference. 94 // Spellcheck implementation for use. Weak reference.
61 SpellCheck* spellcheck_; 95 SpellCheck* spellcheck_;
62 96
63 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider); 97 DISALLOW_COPY_AND_ASSIGN(SpellCheckProvider);
64 }; 98 };
65 99
66 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_ 100 #endif // CHROME_RENDERER_SPELLCHECKER_SPELLCHECK_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698