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

Side by Side Diff: chrome/browser/extensions/api/spellcheck/spellcheck_api.cc

Issue 242613004: Replace NOTIFICATION_EXTENSION_LOADED to NOTIFICATION_EXTENSION_LOADED_DEPRECATED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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/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 24 matching lines...) Expand all
35 return SpellcheckService::DICT_TEXT; 35 return SpellcheckService::DICT_TEXT;
36 } else { 36 } else {
37 return SpellcheckService::DICT_UNKNOWN; 37 return SpellcheckService::DICT_UNKNOWN;
38 } 38 }
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 SpellcheckAPI::SpellcheckAPI(content::BrowserContext* context) { 43 SpellcheckAPI::SpellcheckAPI(content::BrowserContext* context) {
44 Profile* profile = Profile::FromBrowserContext(context); 44 Profile* profile = Profile::FromBrowserContext(context);
45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 45 registrar_.Add(this,
46 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
46 content::Source<Profile>(profile)); 47 content::Source<Profile>(profile));
47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
48 content::Source<Profile>(profile)); 49 content::Source<Profile>(profile));
49 } 50 }
50 51
51 SpellcheckAPI::~SpellcheckAPI() { 52 SpellcheckAPI::~SpellcheckAPI() {
52 } 53 }
53 54
54 static base::LazyInstance<BrowserContextKeyedAPIFactory<SpellcheckAPI> > 55 static base::LazyInstance<BrowserContextKeyedAPIFactory<SpellcheckAPI> >
55 g_factory = LAZY_INSTANCE_INITIALIZER; 56 g_factory = LAZY_INSTANCE_INITIALIZER;
56 57
57 // static 58 // static
58 BrowserContextKeyedAPIFactory<SpellcheckAPI>* 59 BrowserContextKeyedAPIFactory<SpellcheckAPI>*
59 SpellcheckAPI::GetFactoryInstance() { 60 SpellcheckAPI::GetFactoryInstance() {
60 return g_factory.Pointer(); 61 return g_factory.Pointer();
61 } 62 }
62 63
63 void SpellcheckAPI::Observe(int type, 64 void SpellcheckAPI::Observe(int type,
64 const content::NotificationSource& source, 65 const content::NotificationSource& source,
65 const content::NotificationDetails& details) { 66 const content::NotificationDetails& details) {
66 Profile* profile = content::Source<Profile>(source).ptr(); 67 Profile* profile = content::Source<Profile>(source).ptr();
67 SpellcheckService* spellcheck = NULL; 68 SpellcheckService* spellcheck = NULL;
68 switch (type) { 69 switch (type) {
69 case chrome::NOTIFICATION_EXTENSION_LOADED: { 70 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
70 const Extension* extension = content::Details<Extension>(details).ptr(); 71 const Extension* extension = content::Details<Extension>(details).ptr();
71 SpellcheckDictionaryInfo* spellcheck_info = 72 SpellcheckDictionaryInfo* spellcheck_info =
72 GetSpellcheckDictionaryInfo(extension); 73 GetSpellcheckDictionaryInfo(extension);
73 if (spellcheck_info) { 74 if (spellcheck_info) {
74 // TODO(rlp): Handle load failure. = 75 // TODO(rlp): Handle load failure. =
75 spellcheck = SpellcheckServiceFactory::GetForContext(profile); 76 spellcheck = SpellcheckServiceFactory::GetForContext(profile);
76 spellcheck->LoadExternalDictionary( 77 spellcheck->LoadExternalDictionary(
77 spellcheck_info->language, 78 spellcheck_info->language,
78 spellcheck_info->locale, 79 spellcheck_info->locale,
79 spellcheck_info->path, 80 spellcheck_info->path,
(...skipping 18 matching lines...) Expand all
98 } 99 }
99 } 100 }
100 101
101 template <> 102 template <>
102 void 103 void
103 BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { 104 BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() {
104 DependsOn(SpellcheckServiceFactory::GetInstance()); 105 DependsOn(SpellcheckServiceFactory::GetInstance());
105 } 106 }
106 107
107 } // namespace extensions 108 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698