| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::OnCustomDictionaryWordsAdded( |
| 79 const std::string& word) { | 79 const chrome::spellcheck_common::WordList& words) { |
| 80 ListValue list_value; |
| 81 list_value.AppendStrings(words); |
| 82 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.addWords", |
| 83 list_value); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void LanguageDictionaryOverlayHandler::OnCustomDictionaryWordRemoved( | 86 void LanguageDictionaryOverlayHandler::OnCustomDictionaryWordsRemoved( |
| 83 const std::string& word) { | 87 const chrome::spellcheck_common::WordList& words) { |
| 88 ListValue list_value; |
| 89 list_value.AppendStrings(words); |
| 90 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.removeWords", |
| 91 list_value); |
| 84 } | 92 } |
| 85 | 93 |
| 86 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { | 94 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { |
| 87 if (!overlay_initialized_) | 95 if (!overlay_initialized_) |
| 88 return; | 96 return; |
| 89 | 97 |
| 90 if (!dictionary_) { | 98 if (!dictionary_) { |
| 91 dictionary_ = SpellcheckServiceFactory::GetForProfile( | 99 dictionary_ = SpellcheckServiceFactory::GetForProfile( |
| 92 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); | 100 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); |
| 93 dictionary_->AddObserver(this); | 101 dictionary_->AddObserver(this); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 116 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { | 124 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { |
| 117 std::string old_word; | 125 std::string old_word; |
| 118 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { | 126 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { |
| 119 NOTREACHED(); | 127 NOTREACHED(); |
| 120 return; | 128 return; |
| 121 } | 129 } |
| 122 dictionary_->RemoveWord(old_word); | 130 dictionary_->RemoveWord(old_word); |
| 123 } | 131 } |
| 124 | 132 |
| 125 } // namespace options | 133 } // namespace options |
| OLD | NEW |