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/spellchecker/spellcheck_factory.h" | 10 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
10 #include "chrome/browser/spellchecker/spellcheck_service.h" | 11 #include "chrome/browser/spellchecker/spellcheck_service.h" |
11 #include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h" | 12 #include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h" |
12 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
13 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
14 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
15 | 16 |
16 namespace extensions { | 17 namespace extensions { |
17 | 18 |
18 namespace errors = manifest_errors; | 19 namespace errors = manifest_errors; |
(...skipping 13 matching lines...) Expand all Loading... |
32 return SpellcheckService::DICT_HUNSPELL; | 33 return SpellcheckService::DICT_HUNSPELL; |
33 } else if (format == "text") { | 34 } else if (format == "text") { |
34 return SpellcheckService::DICT_TEXT; | 35 return SpellcheckService::DICT_TEXT; |
35 } else { | 36 } else { |
36 return SpellcheckService::DICT_UNKNOWN; | 37 return SpellcheckService::DICT_UNKNOWN; |
37 } | 38 } |
38 } | 39 } |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 | 43 SpellcheckAPI::SpellcheckAPI(content::BrowserContext* context) { |
43 SpellcheckAPI::SpellcheckAPI(Profile* profile) { | 44 Profile* profile = Profile::FromBrowserContext(context); |
44 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 45 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
45 content::Source<Profile>(profile)); | 46 content::Source<Profile>(profile)); |
46 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 47 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
47 content::Source<Profile>(profile)); | 48 content::Source<Profile>(profile)); |
48 } | 49 } |
49 | 50 |
50 SpellcheckAPI::~SpellcheckAPI() { | 51 SpellcheckAPI::~SpellcheckAPI() { |
51 } | 52 } |
52 | 53 |
53 static base::LazyInstance<ProfileKeyedAPIFactory<SpellcheckAPI> > | 54 static base::LazyInstance<ProfileKeyedAPIFactory<SpellcheckAPI> > |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 NOTREACHED(); | 96 NOTREACHED(); |
96 } | 97 } |
97 } | 98 } |
98 | 99 |
99 template <> | 100 template <> |
100 void ProfileKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { | 101 void ProfileKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies() { |
101 DependsOn(SpellcheckServiceFactory::GetInstance()); | 102 DependsOn(SpellcheckServiceFactory::GetInstance()); |
102 } | 103 } |
103 | 104 |
104 } // namespace extensions | 105 } // namespace extensions |
OLD | NEW |