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

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

Issue 11445002: Sync user's custom spellcheck dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add server-side size limit tests Created 7 years, 11 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.h" 5 #include "chrome/renderer/spellchecker/spellcheck.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 platform_spelling_engine_.reset(CreateNativeSpellingEngine()); 90 platform_spelling_engine_.reset(CreateNativeSpellingEngine());
91 } 91 }
92 92
93 SpellCheck::~SpellCheck() { 93 SpellCheck::~SpellCheck() {
94 } 94 }
95 95
96 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { 96 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) {
97 bool handled = true; 97 bool handled = true;
98 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) 98 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message)
99 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) 99 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit)
100 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnWordAdded) 100 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordsAddedRemoved, OnWordsAddedRemoved)
101 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordRemoved, OnWordRemoved)
102 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, 101 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect,
103 OnEnableAutoSpellCorrect) 102 OnEnableAutoSpellCorrect)
104 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableSpellCheck, OnEnableSpellCheck) 103 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableSpellCheck, OnEnableSpellCheck)
105 IPC_MESSAGE_UNHANDLED(handled = false) 104 IPC_MESSAGE_UNHANDLED(handled = false)
106 IPC_END_MESSAGE_MAP() 105 IPC_END_MESSAGE_MAP()
107 106
108 return handled; 107 return handled;
109 } 108 }
110 109
111 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file, 110 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file,
112 const std::vector<std::string>& custom_words, 111 const std::vector<std::string>& custom_words,
113 const std::string& language, 112 const std::string& language,
114 bool auto_spell_correct) { 113 bool auto_spell_correct) {
115 Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file), 114 Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file),
116 custom_words, language); 115 custom_words, language);
117 auto_spell_correct_turned_on_ = auto_spell_correct; 116 auto_spell_correct_turned_on_ = auto_spell_correct;
118 #if !defined(OS_MACOSX) 117 #if !defined(OS_MACOSX)
119 PostDelayedSpellCheckTask(pending_request_param_.release()); 118 PostDelayedSpellCheckTask(pending_request_param_.release());
120 #endif 119 #endif
121 } 120 }
122 121
123 void SpellCheck::OnWordAdded(const std::string& word) { 122 void SpellCheck::OnWordsAddedRemoved(
123 const std::vector<std::string>& words_added,
124 const std::vector<std::string>& words_removed) {
124 if (platform_spelling_engine_.get()) 125 if (platform_spelling_engine_.get())
125 platform_spelling_engine_->OnWordAdded(word); 126 platform_spelling_engine_->OnWordsAddedRemoved(words_added, words_removed);
126 }
127
128 void SpellCheck::OnWordRemoved(const std::string& word) {
129 if (platform_spelling_engine_.get())
130 platform_spelling_engine_->OnWordRemoved(word);
131 } 127 }
132 128
133 void SpellCheck::OnEnableAutoSpellCorrect(bool enable) { 129 void SpellCheck::OnEnableAutoSpellCorrect(bool enable) {
134 auto_spell_correct_turned_on_ = enable; 130 auto_spell_correct_turned_on_ = enable;
135 } 131 }
136 132
137 void SpellCheck::OnEnableSpellCheck(bool enable) { 133 void SpellCheck::OnEnableSpellCheck(bool enable) {
138 spellcheck_enabled_ = enable; 134 spellcheck_enabled_ = enable;
139 UpdateSpellcheckEnabled updater(enable); 135 UpdateSpellcheckEnabled updater(enable);
140 content::RenderView::ForEach(&updater); 136 content::RenderView::ForEach(&updater);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 type = WebKit::WebTextCheckingTypeGrammar; 419 type = WebKit::WebTextCheckingTypeGrammar;
424 } 420 }
425 } 421 }
426 list[i] = WebKit::WebTextCheckingResult(type, 422 list[i] = WebKit::WebTextCheckingResult(type,
427 word_location + line_offset, 423 word_location + line_offset,
428 word_length, 424 word_length,
429 spellcheck_results[i].replacement); 425 spellcheck_results[i].replacement);
430 } 426 }
431 textcheck_results->swap(list); 427 textcheck_results->swap(list);
432 } 428 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698