OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_LANGUAGE_SETTINGS_PRIVATE_LANGUAGE_SETTING
S_PRIVATE_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_LANGUAGE_SETTINGS_PRIVATE_LANGUAGE_SETTING
S_PRIVATE_DELEGATE_H_ |
| 7 |
| 8 #include "chrome/common/extensions/api/language_settings_private.h" |
| 9 #include "components/keyed_service/core/keyed_service.h" |
| 10 #include "extensions/browser/event_router.h" |
| 11 |
| 12 namespace content { |
| 13 class BrowserContext; |
| 14 } |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 // Observes language settings and routes changes as events to listeners of the |
| 19 // languageSettingsPrivate API. |
| 20 class LanguageSettingsPrivateDelegate |
| 21 : public KeyedService, |
| 22 public EventRouter::Observer { |
| 23 public: |
| 24 static LanguageSettingsPrivateDelegate* Create( |
| 25 content::BrowserContext* browser_context); |
| 26 ~LanguageSettingsPrivateDelegate() override; |
| 27 |
| 28 protected: |
| 29 explicit LanguageSettingsPrivateDelegate(content::BrowserContext* context); |
| 30 |
| 31 // KeyedService implementation. |
| 32 void Shutdown() override; |
| 33 |
| 34 // EventRouter::Observer implementation. |
| 35 void OnListenerAdded(const EventListenerInfo& details) override; |
| 36 void OnListenerRemoved(const EventListenerInfo& details) override; |
| 37 |
| 38 private: |
| 39 // If there are any JavaScript listeners registered for spellcheck events, |
| 40 // ensures we are registered for change notifications. Otherwise, unregisters |
| 41 // any observers. |
| 42 void StartOrStopListeningForSpellcheckChanges(); |
| 43 |
| 44 content::BrowserContext* context_; |
| 45 |
| 46 // True if there are observers listening for spellcheck events. |
| 47 bool listening_spellcheck_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(LanguageSettingsPrivateDelegate); |
| 50 }; |
| 51 |
| 52 } // namespace extensions |
| 53 |
| 54 #endif // CHROME_BROWSER_EXTENSIONS_API_LANGUAGE_SETTINGS_PRIVATE_LANGUAGE_SETT
INGS_PRIVATE_DELEGATE_H_ |
OLD | NEW |