summaryrefslogtreecommitdiff
path: root/chromium/components/signin/internal/identity_manager/accounts_cookie_mutator_impl.h
blob: 1f4d5f56a7440b8806c296452a82b45c1b3562b2 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2019 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 COMPONENTS_SIGNIN_INTERNAL_IDENTITY_MANAGER_ACCOUNTS_COOKIE_MUTATOR_IMPL_H_
#define COMPONENTS_SIGNIN_INTERNAL_IDENTITY_MANAGER_ACCOUNTS_COOKIE_MUTATOR_IMPL_H_

#include <string>
#include <vector>

#include "base/callback_forward.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "components/signin/internal/identity_manager/oauth_multilogin_helper.h"
#include "components/signin/public/identity_manager/accounts_cookie_mutator.h"

class AccountTrackerService;
class GaiaCookieManagerService;
class ProfileOAuth2TokenService;
class SigninClient;

namespace gaia {
class GaiaSource;
}

namespace signin {

// Concrete implementation of the AccountsCookieMutator interface.
class AccountsCookieMutatorImpl : public AccountsCookieMutator {
 public:
  explicit AccountsCookieMutatorImpl(
      SigninClient* signin_client,
      ProfileOAuth2TokenService* token_service,
      GaiaCookieManagerService* gaia_cookie_manager_service,
      AccountTrackerService* account_tracker_service);
  ~AccountsCookieMutatorImpl() override;

  void AddAccountToCookie(
      const CoreAccountId& account_id,
      gaia::GaiaSource source,
      AddAccountToCookieCompletedCallback completion_callback) override;

  void AddAccountToCookieWithToken(
      const CoreAccountId& account_id,
      const std::string& access_token,
      gaia::GaiaSource source,
      AddAccountToCookieCompletedCallback completion_callback) override;

  void SetAccountsInCookie(
      const MultiloginParameters& parameters,
      gaia::GaiaSource source,
      base::OnceCallback<void(SetAccountsInCookieResult)>
          set_accounts_in_cookies_completed_callback) override;

  std::unique_ptr<SetAccountsInCookieTask> SetAccountsInCookieForPartition(
      PartitionDelegate* partition_delegate,
      const MultiloginParameters& parameters,
      base::OnceCallback<void(SetAccountsInCookieResult)>
          set_accounts_in_cookies_completed_callback) override;

  void TriggerCookieJarUpdate() override;

#if defined(OS_IOS)
  void ForceTriggerOnCookieChange() override;
#endif

  void LogOutAllAccounts(
      gaia::GaiaSource source,
      LogOutFromCookieCompletedCallback completion_callback) override;

 private:
  class MultiloginHelperWrapper : public SetAccountsInCookieTask {
   public:
    MultiloginHelperWrapper(std::unique_ptr<OAuthMultiloginHelper> helper);
    ~MultiloginHelperWrapper() override;

   private:
    std::unique_ptr<OAuthMultiloginHelper> helper_;
  };

  SigninClient* signin_client_;
  ProfileOAuth2TokenService* token_service_;
  GaiaCookieManagerService* gaia_cookie_manager_service_;
  AccountTrackerService* account_tracker_service_;

  DISALLOW_COPY_AND_ASSIGN(AccountsCookieMutatorImpl);
};

}  // namespace signin

#endif  // COMPONENTS_SIGNIN_INTERNAL_IDENTITY_MANAGER_ACCOUNTS_COOKIE_MUTATOR_IMPL_H_