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