summaryrefslogtreecommitdiffstats
path: root/chromeos/network/favorite_state.h
blob: 13afe37de2dde6126dd30df2f1f08a89748ddff2 (plain)
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
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_NETWORK_FAVORITE_STATE_H_
#define CHROMEOS_NETWORK_FAVORITE_STATE_H_

#include "chromeos/network/managed_state.h"
#include "chromeos/network/onc/onc_constants.h"

namespace chromeos {

// A simple class to provide essential information for Services created
// by Shill corresponding to Profile Entries (i.e. 'preferred' or 'favorite'
// networks).
// Note: NetworkStateHandler will store an entry for each member of
// Manager.ServiceCompleteList, even for visible entries that are not
// favorites. This is necessary to avoid unnecessarily re-requesting entries,
// and to limit the code complexity. The is_favorite() accessor is used to skip
// entries that are not actually favorites.
class CHROMEOS_EXPORT FavoriteState : public ManagedState {
 public:
  explicit FavoriteState(const std::string& path);
  virtual ~FavoriteState();

  // ManagedState overrides
  virtual bool PropertyChanged(const std::string& key,
                               const base::Value& value) OVERRIDE;

  // Accessors
  const std::string& profile_path() const { return profile_path_; }
  bool is_favorite() const { return !profile_path_.empty(); }
  onc::ONCSource onc_source() const { return onc_source_; }

  bool IsManaged() const;
  bool IsShared() const;

 private:
  std::string profile_path_;
  onc::ONCSource onc_source_;

  DISALLOW_COPY_AND_ASSIGN(FavoriteState);
};

}  // namespace chromeos

#endif  // CHROMEOS_NETWORK_FAVORITE_STATE_H_