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

Side by Side Diff: chrome/browser/ui/webui/options/language_dictionary_overlay_handler.cc

Issue 11445002: Sync user's custom spellcheck dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge master 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/browser/ui/webui/options/language_dictionary_overlay_handler.h" 5 #include "chrome/browser/ui/webui/options/language_dictionary_overlay_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/spellchecker/spellcheck_factory.h" 10 #include "chrome/browser/spellchecker/spellcheck_factory.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void LanguageDictionaryOverlayHandler::Uninitialize() { 68 void LanguageDictionaryOverlayHandler::Uninitialize() {
69 overlay_initialized_ = false; 69 overlay_initialized_ = false;
70 if (dictionary_) 70 if (dictionary_)
71 dictionary_->RemoveObserver(this); 71 dictionary_->RemoveObserver(this);
72 } 72 }
73 73
74 void LanguageDictionaryOverlayHandler::OnCustomDictionaryLoaded() { 74 void LanguageDictionaryOverlayHandler::OnCustomDictionaryLoaded() {
75 ResetDictionaryWords(); 75 ResetDictionaryWords();
76 } 76 }
77 77
78 void LanguageDictionaryOverlayHandler::OnCustomDictionaryWordAdded( 78 void LanguageDictionaryOverlayHandler::OnCustomDictionaryChanged(
79 const std::string& word) { 79 const SpellcheckCustomDictionary::Change& dictionary_change) {
80 ListValue add_words; 80 ListValue add_words;
81 ListValue remove_words; 81 ListValue remove_words;
82 add_words.AppendString(word); 82 add_words.AppendStrings(dictionary_change.to_add());
83 remove_words.AppendStrings(dictionary_change.to_remove());
83 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords", 84 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords",
84 add_words, 85 add_words,
85 remove_words); 86 remove_words);
86 }
87
88 void LanguageDictionaryOverlayHandler::OnCustomDictionaryWordRemoved(
89 const std::string& word) {
90 ListValue add_words;
91 ListValue remove_words;
92 remove_words.AppendString(word);
93 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords",
94 add_words,
95 remove_words);
96 } 87 }
97 88
98 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { 89 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() {
99 if (!overlay_initialized_) 90 if (!overlay_initialized_)
100 return; 91 return;
101 92
102 if (!dictionary_) { 93 if (!dictionary_) {
103 dictionary_ = SpellcheckServiceFactory::GetForProfile( 94 dictionary_ = SpellcheckServiceFactory::GetForProfile(
104 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); 95 Profile::FromWebUI(web_ui()))->GetCustomDictionary();
105 dictionary_->AddObserver(this); 96 dictionary_->AddObserver(this);
(...skipping 22 matching lines...) Expand all
128 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { 119 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) {
129 std::string old_word; 120 std::string old_word;
130 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { 121 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) {
131 NOTREACHED(); 122 NOTREACHED();
132 return; 123 return;
133 } 124 }
134 dictionary_->RemoveWord(old_word); 125 dictionary_->RemoveWord(old_word);
135 } 126 }
136 127
137 } // namespace options 128 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/language_dictionary_overlay_handler.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698