blob: cd7116700c6f07643253aeead41c33125ce23ff1 (
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
|
// Copyright 2017 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 CHROME_BROWSER_SIGNIN_PROCESS_DICE_HEADER_DELEGATE_IMPL_H_
#define CHROME_BROWSER_SIGNIN_PROCESS_DICE_HEADER_DELEGATE_IMPL_H_
#include "base/memory/raw_ptr.h"
#include "chrome/browser/signin/dice_response_handler.h"
#include <memory>
#include <string>
#include "base/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "components/signin/public/base/signin_metrics.h"
namespace content {
class WebContents;
}
class Profile;
class SigninUIError;
class ProcessDiceHeaderDelegateImpl : public ProcessDiceHeaderDelegate {
public:
// Callback starting Sync.
using EnableSyncCallback =
base::OnceCallback<void(Profile*,
signin_metrics::AccessPoint,
signin_metrics::PromoAction,
signin_metrics::Reason,
content::WebContents*,
const CoreAccountId&)>;
// Callback showing a signin error UI.
using ShowSigninErrorCallback = base::OnceCallback<
void(Profile*, content::WebContents*, const SigninUIError&)>;
// |is_sync_signin_tab| is true if a sync signin flow has been started in that
// tab.
ProcessDiceHeaderDelegateImpl(
content::WebContents* web_contents,
EnableSyncCallback enable_sync_callback,
ShowSigninErrorCallback show_signin_error_callback);
ProcessDiceHeaderDelegateImpl(const ProcessDiceHeaderDelegateImpl&) = delete;
ProcessDiceHeaderDelegateImpl& operator=(
const ProcessDiceHeaderDelegateImpl&) = delete;
~ProcessDiceHeaderDelegateImpl() override;
// ProcessDiceHeaderDelegate:
void HandleTokenExchangeSuccess(CoreAccountId account_id,
bool is_new_account) override;
void EnableSync(const CoreAccountId& account_id) override;
void HandleTokenExchangeFailure(const std::string& email,
const GoogleServiceAuthError& error) override;
private:
// Returns true if sync should be enabled after the user signs in.
bool ShouldEnableSync();
const base::WeakPtr<content::WebContents> web_contents_;
raw_ptr<Profile> profile_;
EnableSyncCallback enable_sync_callback_;
ShowSigninErrorCallback show_signin_error_callback_;
bool is_sync_signin_tab_ = false;
signin_metrics::AccessPoint access_point_ =
signin_metrics::AccessPoint::ACCESS_POINT_UNKNOWN;
signin_metrics::PromoAction promo_action_ =
signin_metrics::PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO;
signin_metrics::Reason reason_ = signin_metrics::Reason::kUnknownReason;
GURL redirect_url_;
};
#endif // CHROME_BROWSER_SIGNIN_PROCESS_DICE_HEADER_DELEGATE_IMPL_H_
|