Commit 939d7b20 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Update VPN enabled status during open.

VPN feature pod button didn't update when VPN connection state changed
during UnifiedSystemTray is open. It was because it didn't observe the
network state change.

TEST=manual
BUG=896411

Change-Id: I1b9333b277dbcfc86265837b74a5864279b4b3ca
Reviewed-on: https://chromium-review.googlesource.com/c/1288333
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601023}
parent 5f8671e7
......@@ -28,7 +28,8 @@ namespace ash {
VPNFeaturePodController::VPNFeaturePodController(
UnifiedSystemTrayController* tray_controller)
: tray_controller_(tray_controller) {}
: network_state_observer_(std::make_unique<TrayNetworkStateObserver>(this)),
tray_controller_(tray_controller) {}
VPNFeaturePodController::~VPNFeaturePodController() = default;
......@@ -53,6 +54,10 @@ SystemTrayItemUmaType VPNFeaturePodController::GetUmaType() const {
return SystemTrayItemUmaType::UMA_VPN;
}
void VPNFeaturePodController::NetworkStateChanged(bool notify_a11y) {
Update();
}
void VPNFeaturePodController::Update() {
// NetworkHandler can be uninitialized in unit tests.
if (!chromeos::NetworkHandler::IsInitialized())
......
......@@ -5,6 +5,7 @@
#ifndef ASH_SYSTEM_NETWORK_VPN_FEATURE_POD_CONTROLLER_H_
#define ASH_SYSTEM_NETWORK_VPN_FEATURE_POD_CONTROLLER_H_
#include "ash/system/network/tray_network_state_observer.h"
#include "ash/system/unified/feature_pod_controller_base.h"
#include "base/macros.h"
#include "base/strings/string16.h"
......@@ -14,7 +15,8 @@ namespace ash {
class UnifiedSystemTrayController;
// Controller of vpn feature pod button.
class VPNFeaturePodController : public FeaturePodControllerBase {
class VPNFeaturePodController : public FeaturePodControllerBase,
public TrayNetworkStateObserver::Delegate {
public:
VPNFeaturePodController(UnifiedSystemTrayController* tray_controller);
~VPNFeaturePodController() override;
......@@ -24,9 +26,14 @@ class VPNFeaturePodController : public FeaturePodControllerBase {
void OnIconPressed() override;
SystemTrayItemUmaType GetUmaType() const override;
// TrayNetworkStateObserver::Delegate:
void NetworkStateChanged(bool notify_a11y) override;
private:
void Update();
const std::unique_ptr<TrayNetworkStateObserver> network_state_observer_;
// Unowned.
UnifiedSystemTrayController* const tray_controller_;
FeaturePodButton* button_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment