blob: b22f586ee0a9ae3df3893452ac3e7d789c395e90 (
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// Copyright (c) 2012 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_CHROMEOS_EXTENSIONS_ECHO_PRIVATE_API_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_ECHO_PRIVATE_API_H_
#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/ui/echo_dialog_listener.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
class PrefRegistrySimple;
namespace chromeos {
class EchoDialogView;
// Namespace to register the EchoCheckedOffers field in Local State.
namespace echo_offer {
void RegisterPrefs(PrefRegistrySimple* registry);
} // namespace echo_offer
} // namespace chromeos
class EchoPrivateGetRegistrationCodeFunction
: public ChromeSyncExtensionFunction {
public:
EchoPrivateGetRegistrationCodeFunction();
protected:
virtual ~EchoPrivateGetRegistrationCodeFunction();
virtual bool RunImpl() OVERRIDE;
private:
void GetRegistrationCode(const std::string& type);
DECLARE_EXTENSION_FUNCTION("echoPrivate.getRegistrationCode",
ECHOPRIVATE_GETREGISTRATIONCODE)
};
class EchoPrivateGetOobeTimestampFunction
: public ChromeAsyncExtensionFunction {
public:
EchoPrivateGetOobeTimestampFunction();
protected:
virtual ~EchoPrivateGetOobeTimestampFunction();
virtual bool RunImpl() OVERRIDE;
private:
bool GetOobeTimestampOnFileThread();
DECLARE_EXTENSION_FUNCTION("echoPrivate.getOobeTimestamp",
ECHOPRIVATE_GETOOBETIMESTAMP)
};
class EchoPrivateSetOfferInfoFunction : public ChromeSyncExtensionFunction {
public:
EchoPrivateSetOfferInfoFunction();
protected:
virtual ~EchoPrivateSetOfferInfoFunction();
virtual bool RunImpl() OVERRIDE;
private:
DECLARE_EXTENSION_FUNCTION("echoPrivate.setOfferInfo",
ECHOPRIVATE_SETOFFERINFO)
};
class EchoPrivateGetOfferInfoFunction : public ChromeSyncExtensionFunction {
public:
EchoPrivateGetOfferInfoFunction();
protected:
virtual ~EchoPrivateGetOfferInfoFunction();
virtual bool RunImpl() OVERRIDE;
private:
DECLARE_EXTENSION_FUNCTION("echoPrivate.getOfferInfo",
ECHOPRIVATE_GETOFFERINFO)
};
// The function first checks if offers redeeming is allowed by the device
// policy. It should then show a dialog that, depending on the check result,
// either asks user's consent to verify the device's eligibility for the offer,
// or informs the user that the offers redeeming is disabled.
// It returns whether the user consent was given.
class EchoPrivateGetUserConsentFunction : public ChromeAsyncExtensionFunction,
public chromeos::EchoDialogListener {
public:
// Type for the dialog shown callback used in tests.
typedef base::Callback<void(chromeos::EchoDialogView* dialog)>
DialogShownTestCallback;
EchoPrivateGetUserConsentFunction();
// Creates the function with non-null dialog_shown_callback_.
// To be used in tests.
static scoped_refptr<EchoPrivateGetUserConsentFunction> CreateForTest(
const DialogShownTestCallback& dialog_shown_callback);
protected:
virtual ~EchoPrivateGetUserConsentFunction();
virtual bool RunImpl() OVERRIDE;
private:
// chromeos::EchoDialogListener overrides.
virtual void OnAccept() OVERRIDE;
virtual void OnCancel() OVERRIDE;
virtual void OnMoreInfoLinkClicked() OVERRIDE;
// Checks whether "allow redeem ChromeOS registration offers" setting is
// disabled in cros settings. It may be asynchronous if the needed settings
// provider is not yet trusted.
// Upon completion |OnRedeemOffersAllowed| is called.
void CheckRedeemOffersAllowed();
void OnRedeemOffersAllowedChecked(bool is_allowed);
// Sets result and calls SendResponse.
void Finalize(bool consent);
// Result of |CheckRedeemOffersAllowed()|.
bool redeem_offers_allowed_;
// Callback used in tests. Called after an echo dialog is shown.
DialogShownTestCallback dialog_shown_callback_;
DECLARE_EXTENSION_FUNCTION("echoPrivate.getUserConsent",
ECHOPRIVATE_GETUSERCONSENT)
};
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_ECHO_PRIVATE_API_H_
|