Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc

Issue 2649103006: arc: Add splash screen for ARC++ Kiosk startup (Closed)
Patch Set: use base::Bind for timer start Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler .h"
6
7 #include <memory>
8
9 #include "base/memory/ptr_util.h"
10 #include "base/values.h"
11 #include "chrome/grit/chrome_unscaled_resources.h"
12 #include "chrome/grit/chromium_strings.h"
13 #include "chrome/grit/generated_resources.h"
14 #include "components/login/localized_values_builder.h"
15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/webui/web_ui_util.h"
18 #include "ui/gfx/image/image_skia.h"
19
20 namespace {
21
22 constexpr char kJsScreenPath[] = "login.ArcKioskSplashScreen";
23
24 } // namespace
achuithb 2017/02/03 00:35:00 Can drop this comment
Sergey Poromov 2017/02/03 15:15:36 Done.
25
26 namespace chromeos {
27
28 ArcKioskSplashScreenHandler::ArcKioskSplashScreenHandler()
29 : BaseScreenHandler(kJsScreenPath), show_on_init_(false) {}
30
31 ArcKioskSplashScreenHandler::~ArcKioskSplashScreenHandler() = default;
32
33 void ArcKioskSplashScreenHandler::DeclareLocalizedValues(
34 ::login::LocalizedValuesBuilder* builder) {
35 builder->Add("arcKioskStartMessage", IDS_APP_START_APP_WAIT_MESSAGE);
36
37 const base::string16 product_os_name =
38 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME);
39 builder->Add("arcKioskShortcutInfo",
40 l10n_util::GetStringFUTF16(IDS_APP_START_BAILOUT_SHORTCUT_FORMAT,
41 product_os_name));
42 builder->Add("arcKioskProductName", product_os_name);
43 }
44
45 void ArcKioskSplashScreenHandler::Initialize() {
46 if (!show_on_init_)
47 return;
48 show_on_init_ = false;
49 Show();
50 }
51
52 void ArcKioskSplashScreenHandler::Show() {
53 if (!page_is_ready()) {
54 show_on_init_ = true;
55 return;
56 }
57
58 base::DictionaryValue data;
59 // |data| will take ownership of |app_info|.
60 std::unique_ptr<base::DictionaryValue> app_info =
61 base::MakeUnique<base::DictionaryValue>();
62 PopulateAppInfo(app_info.get());
63 data.Set("appInfo", std::move(app_info));
64 ShowScreenWithData(OobeScreen::SCREEN_ARC_KIOSK_SPLASH, &data);
65 }
66
67 void ArcKioskSplashScreenHandler::RegisterMessages() {
68 AddCallback("cancelArcKioskLaunch",
69 &ArcKioskSplashScreenHandler::HandleCancelArcKioskLaunch);
70 }
71
72 void ArcKioskSplashScreenHandler::UpdateArcKioskState(ArcKioskState state) {
73 if (!page_is_ready())
74 return;
75 SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state)));
76 }
77
78 void ArcKioskSplashScreenHandler::SetDelegate(
79 ArcKioskSplashScreenHandler::Delegate* delegate) {
80 delegate_ = delegate;
81 }
82
83 void ArcKioskSplashScreenHandler::PopulateAppInfo(
84 base::DictionaryValue* out_info) {
85 out_info->SetString("name", l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME));
86 out_info->SetString(
87 "iconURL",
88 webui::GetBitmapDataUrl(*ResourceBundle::GetSharedInstance()
89 .GetImageSkiaNamed(IDR_PRODUCT_LOGO_128)
90 ->bitmap()));
91 }
92
93 void ArcKioskSplashScreenHandler::SetLaunchText(const std::string& text) {
94 CallJS("updateArcKioskMessage", text);
95 }
96
97 int ArcKioskSplashScreenHandler::GetProgressMessageFromState(
98 ArcKioskState state) {
99 switch (state) {
100 case ArcKioskState::STARTING_SESSION:
101 return IDS_SYNC_SETUP_SPINNER_TITLE;
102 case ArcKioskState::WAITING_APP_LAUNCH:
103 return IDS_APP_START_APP_WAIT_MESSAGE;
104 case ArcKioskState::WAITING_APP_WINDOW:
105 return IDS_APP_START_WAIT_FOR_APP_WINDOW_MESSAGE;
106 }
achuithb 2017/02/03 00:35:00 shouldn't you have a default with an assert?
Sergey Poromov 2017/02/03 15:15:36 Done.
107 return IDS_SYNC_SETUP_SPINNER_TITLE;
108 }
109
110 void ArcKioskSplashScreenHandler::HandleCancelArcKioskLaunch() {
111 if (!delegate_) {
112 LOG(WARNING) << "No delegate set to handle cancel app launch";
113 return;
114 }
115 delegate_->OnCancelArcKioskLaunch();
116 }
117
118 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698