| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_SIGNED_IN_DEVICES_MANAGE
R_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_SIGNED_IN_DEVICES_MANAGE
R_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_SIGNED_IN_DEVICES_MANAGE
R_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_SIGNED_IN_DEVICES_MANAGE
R_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // The extension id is part of this object as it is needed to fill in the | 37 // The extension id is part of this object as it is needed to fill in the |
| 38 // public ids for devices(public ids for a device, is not the same for | 38 // public ids for devices(public ids for a device, is not the same for |
| 39 // all extensions). | 39 // all extensions). |
| 40 class SignedInDevicesChangeObserver | 40 class SignedInDevicesChangeObserver |
| 41 : public sync_driver::DeviceInfoTracker::Observer { | 41 : public sync_driver::DeviceInfoTracker::Observer { |
| 42 public: | 42 public: |
| 43 SignedInDevicesChangeObserver(const std::string& extension_id, | 43 SignedInDevicesChangeObserver(const std::string& extension_id, |
| 44 Profile* profile); | 44 Profile* profile); |
| 45 virtual ~SignedInDevicesChangeObserver(); | 45 virtual ~SignedInDevicesChangeObserver(); |
| 46 | 46 |
| 47 virtual void OnDeviceInfoChange() OVERRIDE; | 47 virtual void OnDeviceInfoChange() override; |
| 48 | 48 |
| 49 const std::string& extension_id() { | 49 const std::string& extension_id() { |
| 50 return extension_id_; | 50 return extension_id_; |
| 51 } | 51 } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 std::string extension_id_; | 54 std::string extension_id_; |
| 55 Profile* const profile_; | 55 Profile* const profile_; |
| 56 content::NotificationRegistrar registrar_; | 56 content::NotificationRegistrar registrar_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class SignedInDevicesManager : public BrowserContextKeyedAPI, | 59 class SignedInDevicesManager : public BrowserContextKeyedAPI, |
| 60 public ExtensionRegistryObserver, | 60 public ExtensionRegistryObserver, |
| 61 public EventRouter::Observer { | 61 public EventRouter::Observer { |
| 62 public: | 62 public: |
| 63 // Default constructor used for testing. | 63 // Default constructor used for testing. |
| 64 SignedInDevicesManager(); | 64 SignedInDevicesManager(); |
| 65 explicit SignedInDevicesManager(content::BrowserContext* context); | 65 explicit SignedInDevicesManager(content::BrowserContext* context); |
| 66 virtual ~SignedInDevicesManager(); | 66 virtual ~SignedInDevicesManager(); |
| 67 | 67 |
| 68 // BrowserContextKeyedAPI implementation. | 68 // BrowserContextKeyedAPI implementation. |
| 69 static BrowserContextKeyedAPIFactory<SignedInDevicesManager>* | 69 static BrowserContextKeyedAPIFactory<SignedInDevicesManager>* |
| 70 GetFactoryInstance(); | 70 GetFactoryInstance(); |
| 71 | 71 |
| 72 // ExtensionRegistryObserver implementation. | 72 // ExtensionRegistryObserver implementation. |
| 73 virtual void OnExtensionUnloaded( | 73 virtual void OnExtensionUnloaded( |
| 74 content::BrowserContext* browser_context, | 74 content::BrowserContext* browser_context, |
| 75 const Extension* extension, | 75 const Extension* extension, |
| 76 UnloadedExtensionInfo::Reason reason) OVERRIDE; | 76 UnloadedExtensionInfo::Reason reason) override; |
| 77 | 77 |
| 78 // EventRouter::Observer: | 78 // EventRouter::Observer: |
| 79 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 79 virtual void OnListenerAdded(const EventListenerInfo& details) override; |
| 80 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 80 virtual void OnListenerRemoved(const EventListenerInfo& details) override; |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 friend class BrowserContextKeyedAPIFactory<SignedInDevicesManager>; | 83 friend class BrowserContextKeyedAPIFactory<SignedInDevicesManager>; |
| 84 | 84 |
| 85 // BrowserContextKeyedAPI implementation. | 85 // BrowserContextKeyedAPI implementation. |
| 86 static const char* service_name() { | 86 static const char* service_name() { |
| 87 return "SignedInDevicesManager"; | 87 return "SignedInDevicesManager"; |
| 88 } | 88 } |
| 89 static const bool kServiceHasOwnInstanceInIncognito = true; | 89 static const bool kServiceHasOwnInstanceInIncognito = true; |
| 90 | 90 |
| 91 void RemoveChangeObserverForExtension(const std::string& extension_id); | 91 void RemoveChangeObserverForExtension(const std::string& extension_id); |
| 92 | 92 |
| 93 Profile* const profile_; | 93 Profile* const profile_; |
| 94 ScopedVector<SignedInDevicesChangeObserver> change_observers_; | 94 ScopedVector<SignedInDevicesChangeObserver> change_observers_; |
| 95 | 95 |
| 96 // Listen to extension unloaded notification. | 96 // Listen to extension unloaded notification. |
| 97 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 97 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 98 extension_registry_observer_; | 98 extension_registry_observer_; |
| 99 | 99 |
| 100 FRIEND_TEST_ALL_PREFIXES(SignedInDevicesManager, UpdateListener); | 100 FRIEND_TEST_ALL_PREFIXES(SignedInDevicesManager, UpdateListener); |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(SignedInDevicesManager); | 102 DISALLOW_COPY_AND_ASSIGN(SignedInDevicesManager); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace extensions | 105 } // namespace extensions |
| 106 | 106 |
| 107 #endif // CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_SIGNED_IN_DEVICES_MAN
AGER_H__ | 107 #endif // CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_SIGNED_IN_DEVICES_MAN
AGER_H__ |
| OLD | NEW |