blob: e601e28f4a056c4b84cfa0c3702d45335f4650c3 (
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
|
// Copyright 2018 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.
#include "chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h"
#include "chrome/browser/browser_process.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
namespace {
const char kJsScreenPath[] = "AssistantValuePropScreen";
constexpr const char kUserActionSkipPressed[] = "skip-pressed";
constexpr const char kUserActionNextPressed[] = "next-pressed";
} // namespace
namespace chromeos {
ValuePropScreenHandler::ValuePropScreenHandler(
OnAssistantOptInScreenExitCallback callback)
: BaseWebUIHandler(), exit_callback_(std::move(callback)) {
set_call_js_prefix(kJsScreenPath);
}
ValuePropScreenHandler::~ValuePropScreenHandler() = default;
void ValuePropScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("locale", g_browser_process->GetApplicationLocale());
builder->Add("voiceInteractionValuePropLoading",
IDS_VOICE_INTERACTION_VALUE_PROP_LOADING);
builder->Add("voiceInteractionValuePropLoadErrorTitle",
IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_TITLE);
builder->Add("voiceInteractionValuePropLoadErrorMessage",
IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_MESSAGE);
builder->Add("voiceInteractionValuePropSkipButton",
IDS_VOICE_INTERACTION_VALUE_PROP_SKIP_BUTTON);
builder->Add("voiceInteractionValuePropRetryButton",
IDS_VOICE_INTERACTION_VALUE_PROP_RETRY_BUTTON);
builder->Add("voiceInteractionValuePropNextButton",
IDS_VOICE_INTERACTION_VALUE_PROP_NEXT_BUTTION);
builder->Add("back", IDS_EULA_BACK_BUTTON);
builder->Add("next", IDS_EULA_NEXT_BUTTON);
}
void ValuePropScreenHandler::RegisterMessages() {
AddPrefixedCallback("userActed", &ValuePropScreenHandler::HandleUserAction);
}
void ValuePropScreenHandler::Initialize() {}
void ValuePropScreenHandler::HandleUserAction(const std::string& action) {
DCHECK(exit_callback_);
if (action == kUserActionSkipPressed)
std::move(exit_callback_)
.Run(AssistantOptInScreenExitCode::VALUE_PROP_SKIPPED);
else if (action == kUserActionNextPressed)
std::move(exit_callback_)
.Run(AssistantOptInScreenExitCode::VALUE_PROP_ACCEPTED);
}
} // namespace chromeos
|