| 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/common/system/chromeos/network/vpn_delegate.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "extensions/browser/extension_registry_observer.h" | |
| 16 | |
| 17 namespace extensions { | |
| 18 class ExtensionRegistry; | |
| 19 } | |
| 20 | |
| 21 // Chrome OS implementation of a delegate that provides UI code in ash with | |
| 22 // access to the VPN providers enabled in the primary user's 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 void ShowAddPage(const std::string& extension_id) override; | |
| 32 | |
| 33 // extensions::ExtensionRegistryObserver: | |
| 34 void OnExtensionLoaded(content::BrowserContext* browser_context, | |
| 35 const extensions::Extension* extension) override; | |
| 36 void OnExtensionUnloaded( | |
| 37 content::BrowserContext* browser_context, | |
| 38 const extensions::Extension* extension, | |
| 39 extensions::UnloadedExtensionInfo::Reason reason) override; | |
| 40 void OnShutdown(extensions::ExtensionRegistry* registry) override; | |
| 41 | |
| 42 // content::NotificationObserver: | |
| 43 void Observe(int type, | |
| 44 const content::NotificationSource& source, | |
| 45 const content::NotificationDetails& details) override; | |
| 46 | |
| 47 private: | |
| 48 // 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 | |
| 50 // when a user is logged in and the primary user's extension registry is being | |
| 51 // observed. | |
| 52 void UpdateVPNProviders(); | |
| 53 | |
| 54 // 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 | |
| 56 // initial list. Must only be called when a user is logged in. | |
| 57 void AttachToPrimaryUserExtensionRegistry(); | |
| 58 | |
| 59 // The primary user's extension registry, if a user is logged in. | |
| 60 extensions::ExtensionRegistry* extension_registry_ = nullptr; | |
| 61 | |
| 62 content::NotificationRegistrar registrar_; | |
| 63 | |
| 64 base::WeakPtrFactory<VPNDelegateChromeOS> weak_factory_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(VPNDelegateChromeOS); | |
| 67 }; | |
| 68 | |
| 69 #endif // CHROME_BROWSER_UI_ASH_VPN_DELEGATE_CHROMEOS_H_ | |
| OLD | NEW |