| 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/extensions/api/spellcheck/spellcheck_api.h" | 5 #include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 9 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 10 #include "chrome/browser/spellchecker/spellcheck_service.h" | 10 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const content::NotificationDetails& details) { | 63 const content::NotificationDetails& details) { |
| 64 Profile* profile = content::Source<Profile>(source).ptr(); | 64 Profile* profile = content::Source<Profile>(source).ptr(); |
| 65 SpellcheckService* spellcheck = NULL; | 65 SpellcheckService* spellcheck = NULL; |
| 66 switch (type) { | 66 switch (type) { |
| 67 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 67 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| 68 const Extension* extension = content::Details<Extension>(details).ptr(); | 68 const Extension* extension = content::Details<Extension>(details).ptr(); |
| 69 SpellcheckDictionaryInfo* spellcheck_info = | 69 SpellcheckDictionaryInfo* spellcheck_info = |
| 70 GetSpellcheckDictionaryInfo(extension); | 70 GetSpellcheckDictionaryInfo(extension); |
| 71 if (spellcheck_info) { | 71 if (spellcheck_info) { |
| 72 // TODO(rlp): Handle load failure. = | 72 // TODO(rlp): Handle load failure. = |
| 73 spellcheck = SpellcheckServiceFactory::GetForProfile(profile); | 73 spellcheck = SpellcheckServiceFactory::GetForContext(profile); |
| 74 spellcheck->LoadExternalDictionary( | 74 spellcheck->LoadExternalDictionary( |
| 75 spellcheck_info->language, | 75 spellcheck_info->language, |
| 76 spellcheck_info->locale, | 76 spellcheck_info->locale, |
| 77 spellcheck_info->path, | 77 spellcheck_info->path, |
| 78 GetDictionaryFormat(spellcheck_info->format)); | 78 GetDictionaryFormat(spellcheck_info->format)); |
| 79 } | 79 } |
| 80 break; | 80 break; |
| 81 } | 81 } |
| 82 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 82 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
| 83 const Extension* extension = | 83 const Extension* extension = |
| 84 content::Details<UnloadedExtensionInfo>(details)->extension; | 84 content::Details<UnloadedExtensionInfo>(details)->extension; |
| 85 SpellcheckDictionaryInfo* spellcheck_info = | 85 SpellcheckDictionaryInfo* spellcheck_info = |
| 86 GetSpellcheckDictionaryInfo(extension); | 86 GetSpellcheckDictionaryInfo(extension); |
| 87 if (spellcheck_info) { | 87 if (spellcheck_info) { |
| 88 // TODO(rlp): Handle unload failure. | 88 // TODO(rlp): Handle unload failure. |
| 89 spellcheck = SpellcheckServiceFactory::GetForProfile(profile); | 89 spellcheck = SpellcheckServiceFactory::GetForContext(profile); |
| 90 spellcheck->UnloadExternalDictionary(spellcheck_info->path); | 90 spellcheck->UnloadExternalDictionary(spellcheck_info->path); |
| 91 } | 91 } |
| 92 break; | 92 break; |
| 93 } | 93 } |
| 94 default: | 94 default: |
| 95 NOTREACHED(); | 95 NOTREACHED(); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 template <> | 99 template <> |
| 100 void ProfileKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { | 100 void ProfileKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { |
| 101 DependsOn(SpellcheckServiceFactory::GetInstance()); | 101 DependsOn(SpellcheckServiceFactory::GetInstance()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace extensions | 104 } // namespace extensions |
| OLD | NEW |