| 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/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 Profile* profile = Profile::FromBrowserContext(context); | 44 Profile* profile = Profile::FromBrowserContext(context); |
| 45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 46 content::Source<Profile>(profile)); | 46 content::Source<Profile>(profile)); |
| 47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 48 content::Source<Profile>(profile)); | 48 content::Source<Profile>(profile)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 SpellcheckAPI::~SpellcheckAPI() { | 51 SpellcheckAPI::~SpellcheckAPI() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 static base::LazyInstance<ProfileKeyedAPIFactory<SpellcheckAPI> > | 54 static base::LazyInstance<BrowserContextKeyedAPIFactory<SpellcheckAPI> > |
| 55 g_factory = LAZY_INSTANCE_INITIALIZER; | 55 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 ProfileKeyedAPIFactory<SpellcheckAPI>* SpellcheckAPI::GetFactoryInstance() { | 58 BrowserContextKeyedAPIFactory<SpellcheckAPI>* |
| 59 SpellcheckAPI::GetFactoryInstance() { |
| 59 return g_factory.Pointer(); | 60 return g_factory.Pointer(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void SpellcheckAPI::Observe(int type, | 63 void SpellcheckAPI::Observe(int type, |
| 63 const content::NotificationSource& source, | 64 const content::NotificationSource& source, |
| 64 const content::NotificationDetails& details) { | 65 const content::NotificationDetails& details) { |
| 65 Profile* profile = content::Source<Profile>(source).ptr(); | 66 Profile* profile = content::Source<Profile>(source).ptr(); |
| 66 SpellcheckService* spellcheck = NULL; | 67 SpellcheckService* spellcheck = NULL; |
| 67 switch (type) { | 68 switch (type) { |
| 68 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 69 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 91 spellcheck->UnloadExternalDictionary(spellcheck_info->path); | 92 spellcheck->UnloadExternalDictionary(spellcheck_info->path); |
| 92 } | 93 } |
| 93 break; | 94 break; |
| 94 } | 95 } |
| 95 default: | 96 default: |
| 96 NOTREACHED(); | 97 NOTREACHED(); |
| 97 } | 98 } |
| 98 } | 99 } |
| 99 | 100 |
| 100 template <> | 101 template <> |
| 101 void ProfileKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { | 102 void |
| 103 BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { |
| 102 DependsOn(SpellcheckServiceFactory::GetInstance()); | 104 DependsOn(SpellcheckServiceFactory::GetInstance()); |
| 103 } | 105 } |
| 104 | 106 |
| 105 } // namespace extensions | 107 } // namespace extensions |
| OLD | NEW |