1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47

ash / system / nearby_share / nearby_share_controller_impl.h [blame]

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_CONTROLLER_IMPL_H_
#define ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_CONTROLLER_IMPL_H_

#include "ash/public/cpp/nearby_share_controller.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"

namespace ash {

// Handles Nearby Share events from //chrome, providing an observer interface
// within //ash. Singleton, lives on UI thread.
class NearbyShareControllerImpl : public NearbyShareController {
 public:
  class Observer : public base::CheckedObserver {
   public:
    // Relays high visibility state changes from the service to the pod button.
    virtual void OnHighVisibilityEnabledChanged(bool enabled) = 0;

    // Relay visibility state changes from the settings to the pod button.
    virtual void OnVisibilityChanged(
        ::nearby_share::mojom::Visibility visibility) = 0;
  };

  NearbyShareControllerImpl();
  NearbyShareControllerImpl(NearbyShareControllerImpl&) = delete;
  NearbyShareControllerImpl& operator=(NearbyShareControllerImpl&) = delete;
  ~NearbyShareControllerImpl() override;

  // NearbyShareController
  void HighVisibilityEnabledChanged(bool enabled) override;
  void VisibilityChanged(
      ::nearby_share::mojom::Visibility visibility) const override;

  void AddObserver(Observer* obs);
  void RemoveObserver(Observer* obs);

 private:
  base::ObserverList<Observer> observers_;
};

}  // namespace ash

#endif  // ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_CONTROLLER_IMPL_H_