| OLD | NEW |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords", | 78 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords", |
| 79 add_words, | 79 add_words, |
| 80 remove_words); | 80 remove_words); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { | 83 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { |
| 84 if (!overlay_initialized_) | 84 if (!overlay_initialized_) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 if (!dictionary_) { | 87 if (!dictionary_) { |
| 88 dictionary_ = SpellcheckServiceFactory::GetForProfile( | 88 SpellcheckService* service = SpellcheckServiceFactory::GetForContext( |
| 89 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); | 89 Profile::FromWebUI(web_ui())); |
| 90 dictionary_ = service->GetCustomDictionary(); |
| 90 dictionary_->AddObserver(this); | 91 dictionary_->AddObserver(this); |
| 91 } | 92 } |
| 92 | 93 |
| 93 ListValue list_value; | 94 ListValue list_value; |
| 94 const chrome::spellcheck_common::WordSet& words = dictionary_->GetWords(); | 95 const chrome::spellcheck_common::WordSet& words = dictionary_->GetWords(); |
| 95 for (chrome::spellcheck_common::WordSet::const_iterator it = words.begin(); | 96 for (chrome::spellcheck_common::WordSet::const_iterator it = words.begin(); |
| 96 it != words.end(); ++it) { | 97 it != words.end(); ++it) { |
| 97 list_value.AppendString(*it); | 98 list_value.AppendString(*it); |
| 98 } | 99 } |
| 99 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList", | 100 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList", |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { | 118 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { |
| 118 std::string old_word; | 119 std::string old_word; |
| 119 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { | 120 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { |
| 120 NOTREACHED(); | 121 NOTREACHED(); |
| 121 return; | 122 return; |
| 122 } | 123 } |
| 123 dictionary_->RemoveWord(old_word); | 124 dictionary_->RemoveWord(old_word); |
| 124 } | 125 } |
| 125 | 126 |
| 126 } // namespace options | 127 } // namespace options |
| OLD | NEW |