| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_UI_ASH_VPN_DELEGATE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_VPN_LIST_FORWARDER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_VPN_DELEGATE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_UI_ASH_VPN_LIST_FORWARDER_H_ |
| 7 | 7 |
| 8 #include <vector> | |
| 9 | |
| 10 #include "ash/common/system/chromeos/network/vpn_delegate.h" | |
| 11 #include "base/macros.h" | 8 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 13 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 15 #include "extensions/browser/extension_registry_observer.h" | 12 #include "extensions/browser/extension_registry_observer.h" |
| 16 | 13 |
| 17 namespace extensions { | 14 namespace extensions { |
| 18 class ExtensionRegistry; | 15 class ExtensionRegistry; |
| 19 } | 16 } |
| 20 | 17 |
| 21 // Chrome OS implementation of a delegate that provides UI code in ash with | 18 // Forwards the list of extension-backed VPN providers in the primary user's |
| 22 // access to the VPN providers enabled in the primary user's profile. | 19 // profile to ash over mojo. |
| 23 class VPNDelegateChromeOS : public ash::VPNDelegate, | 20 class VpnListForwarder : public extensions::ExtensionRegistryObserver, |
| 24 public extensions::ExtensionRegistryObserver, | 21 public content::NotificationObserver { |
| 25 public content::NotificationObserver { | |
| 26 public: | 22 public: |
| 27 VPNDelegateChromeOS(); | 23 VpnListForwarder(); |
| 28 ~VPNDelegateChromeOS() override; | 24 ~VpnListForwarder() override; |
| 29 | |
| 30 // ash::VPNDelegate: | |
| 31 void ShowAddPage(const std::string& extension_id) override; | |
| 32 | 25 |
| 33 // extensions::ExtensionRegistryObserver: | 26 // extensions::ExtensionRegistryObserver: |
| 34 void OnExtensionLoaded(content::BrowserContext* browser_context, | 27 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 35 const extensions::Extension* extension) override; | 28 const extensions::Extension* extension) override; |
| 36 void OnExtensionUnloaded( | 29 void OnExtensionUnloaded( |
| 37 content::BrowserContext* browser_context, | 30 content::BrowserContext* browser_context, |
| 38 const extensions::Extension* extension, | 31 const extensions::Extension* extension, |
| 39 extensions::UnloadedExtensionInfo::Reason reason) override; | 32 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 40 void OnShutdown(extensions::ExtensionRegistry* registry) override; | 33 void OnShutdown(extensions::ExtensionRegistry* registry) override; |
| 41 | 34 |
| 42 // content::NotificationObserver: | 35 // content::NotificationObserver: |
| 43 void Observe(int type, | 36 void Observe(int type, |
| 44 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
| 45 const content::NotificationDetails& details) override; | 38 const content::NotificationDetails& details) override; |
| 46 | 39 |
| 47 private: | 40 private: |
| 48 // Retrieves the current list of VPN providers enabled in the primary user's | 41 // Retrieves the current list of VPN providers enabled in the primary user's |
| 49 // profile and notifies observers that it has changed. Must only be called | 42 // profile and notifies observers that it has changed. Must only be called |
| 50 // when a user is logged in and the primary user's extension registry is being | 43 // when a user is logged in and the primary user's extension registry is being |
| 51 // observed. | 44 // observed. |
| 52 void UpdateVPNProviders(); | 45 void UpdateVPNProviders(); |
| 53 | 46 |
| 54 // Starts observing the primary user's extension registry to detect changes to | 47 // Starts observing the primary user's extension registry to detect changes to |
| 55 // the list of VPN providers enabled in the user's profile and caches the | 48 // the list of VPN providers enabled in the user's profile and caches the |
| 56 // initial list. Must only be called when a user is logged in. | 49 // initial list. Must only be called when a user is logged in. |
| 57 void AttachToPrimaryUserExtensionRegistry(); | 50 void AttachToPrimaryUserExtensionRegistry(); |
| 58 | 51 |
| 52 // Whether this object has ever sent a third-party provider list to ash. |
| 53 bool sent_providers_ = false; |
| 54 |
| 59 // The primary user's extension registry, if a user is logged in. | 55 // The primary user's extension registry, if a user is logged in. |
| 60 extensions::ExtensionRegistry* extension_registry_ = nullptr; | 56 extensions::ExtensionRegistry* extension_registry_ = nullptr; |
| 61 | 57 |
| 62 content::NotificationRegistrar registrar_; | 58 content::NotificationRegistrar registrar_; |
| 63 | 59 |
| 64 base::WeakPtrFactory<VPNDelegateChromeOS> weak_factory_; | 60 base::WeakPtrFactory<VpnListForwarder> weak_factory_; |
| 65 | 61 |
| 66 DISALLOW_COPY_AND_ASSIGN(VPNDelegateChromeOS); | 62 DISALLOW_COPY_AND_ASSIGN(VpnListForwarder); |
| 67 }; | 63 }; |
| 68 | 64 |
| 69 #endif // CHROME_BROWSER_UI_ASH_VPN_DELEGATE_CHROMEOS_H_ | 65 #endif // CHROME_BROWSER_UI_ASH_VPN_LIST_FORWARDER_H_ |
| OLD | NEW |