summaryrefslogtreecommitdiffstats
path: root/ash/system/user/user_accounts_delegate.h
blob: b717e83aac24a791265859649b389609169a8722 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2014 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 ASH_SYSTEM_USER_USER_ACCOUNTS_DELEGATE_H_
#define ASH_SYSTEM_USER_USER_ACCOUNTS_DELEGATE_H_

#include <string>
#include <vector>

#include "ash/ash_export.h"
#include "base/macros.h"
#include "base/observer_list.h"

namespace ash {
namespace tray {

class ASH_EXPORT UserAccountsDelegate {
 public:
  class Observer {
   public:
    Observer() {}
    virtual ~Observer() {}

    // Called when the account list of user has been changed.
    virtual void AccountListChanged() = 0;

   private:
    DISALLOW_COPY_AND_ASSIGN(Observer);
  };

  UserAccountsDelegate();
  virtual ~UserAccountsDelegate();

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

  // Returns the user's primary account as a canonicalized email address.
  virtual std::string GetPrimaryAccount() = 0;

  // Returns a list of the user's secondary accounts in form of canonicalized
  // email addresses.
  virtual std::vector<std::string> GetSecondaryAccountsList() = 0;

  // Returns display name for given |account_id|. It has form of email but could
  // be uncanonical, e.g. account "test-user@gmail.com" could have display
  // name "Test-user+AfterPlus@gmail.com".
  virtual std::string GetAccountDisplayName(const std::string& account_id) = 0;

  // Deletes given |account_id| from the list of user's account. Passing
  // |account_id| that is not from list is no-op.
  virtual void DeleteAccount(const std::string& account_id) = 0;

  // Launches a dialog which lets the user add a new account.
  virtual void LaunchAddAccountDialog() = 0;

 protected:
  void NotifyAccountListChanged();

 private:
  ObserverList<Observer> observers_;

  DISALLOW_COPY_AND_ASSIGN(UserAccountsDelegate);
};

}  // namespace tray
}  // namespace ash

#endif  // ASH_SYSTEM_USER_USER_ACCOUNTS_DELEGATE_H_