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

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: Fix compile on some platforms 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 } 80 ListValue add_words;
81 81 ListValue remove_words;
82 void LanguageDictionaryOverlayHandler::OnCustomDictionaryWordRemoved( 82 add_words.AppendStrings(dictionary_change.to_add());
83 const std::string& word) { 83 remove_words.AppendStrings(dictionary_change.to_remove());
84 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords",
85 add_words,
86 remove_words);
84 } 87 }
85 88
86 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { 89 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() {
87 if (!overlay_initialized_) 90 if (!overlay_initialized_)
88 return; 91 return;
89 92
90 if (!dictionary_) { 93 if (!dictionary_) {
91 dictionary_ = SpellcheckServiceFactory::GetForProfile( 94 dictionary_ = SpellcheckServiceFactory::GetForProfile(
92 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); 95 Profile::FromWebUI(web_ui()))->GetCustomDictionary();
93 dictionary_->AddObserver(this); 96 dictionary_->AddObserver(this);
(...skipping 22 matching lines...) Expand all
116 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { 119 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) {
117 std::string old_word; 120 std::string old_word;
118 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { 121 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) {
119 NOTREACHED(); 122 NOTREACHED();
120 return; 123 return;
121 } 124 }
122 dictionary_->RemoveWord(old_word); 125 dictionary_->RemoveWord(old_word);
123 } 126 }
124 127
125 } // namespace options 128 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698