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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6de3e843c138cf14273b9035762b0803576d1633
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
@@ -0,0 +1,118 @@
+// 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.
+
+#include "chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h"
+
+#include <memory>
+
+#include "base/memory/ptr_util.h"
+#include "base/values.h"
+#include "chrome/grit/chrome_unscaled_resources.h"
+#include "chrome/grit/chromium_strings.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/webui/web_ui_util.h"
+#include "ui/gfx/image/image_skia.h"
+
+namespace {
+
+constexpr char kJsScreenPath[] = "login.ArcKioskSplashScreen";
+
+} // namespace
achuithb 2017/02/03 00:35:00 Can drop this comment
Sergey Poromov 2017/02/03 15:15:36 Done.
+
+namespace chromeos {
+
+ArcKioskSplashScreenHandler::ArcKioskSplashScreenHandler()
+ : BaseScreenHandler(kJsScreenPath), show_on_init_(false) {}
+
+ArcKioskSplashScreenHandler::~ArcKioskSplashScreenHandler() = default;
+
+void ArcKioskSplashScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("arcKioskStartMessage", IDS_APP_START_APP_WAIT_MESSAGE);
+
+ const base::string16 product_os_name =
+ l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME);
+ builder->Add("arcKioskShortcutInfo",
+ l10n_util::GetStringFUTF16(IDS_APP_START_BAILOUT_SHORTCUT_FORMAT,
+ product_os_name));
+ builder->Add("arcKioskProductName", product_os_name);
+}
+
+void ArcKioskSplashScreenHandler::Initialize() {
+ if (!show_on_init_)
+ return;
+ show_on_init_ = false;
+ Show();
+}
+
+void ArcKioskSplashScreenHandler::Show() {
+ if (!page_is_ready()) {
+ show_on_init_ = true;
+ return;
+ }
+
+ base::DictionaryValue data;
+ // |data| will take ownership of |app_info|.
+ std::unique_ptr<base::DictionaryValue> app_info =
+ base::MakeUnique<base::DictionaryValue>();
+ PopulateAppInfo(app_info.get());
+ data.Set("appInfo", std::move(app_info));
+ ShowScreenWithData(OobeScreen::SCREEN_ARC_KIOSK_SPLASH, &data);
+}
+
+void ArcKioskSplashScreenHandler::RegisterMessages() {
+ AddCallback("cancelArcKioskLaunch",
+ &ArcKioskSplashScreenHandler::HandleCancelArcKioskLaunch);
+}
+
+void ArcKioskSplashScreenHandler::UpdateArcKioskState(ArcKioskState state) {
+ if (!page_is_ready())
+ return;
+ SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state)));
+}
+
+void ArcKioskSplashScreenHandler::SetDelegate(
+ ArcKioskSplashScreenHandler::Delegate* delegate) {
+ delegate_ = delegate;
+}
+
+void ArcKioskSplashScreenHandler::PopulateAppInfo(
+ base::DictionaryValue* out_info) {
+ out_info->SetString("name", l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME));
+ out_info->SetString(
+ "iconURL",
+ webui::GetBitmapDataUrl(*ResourceBundle::GetSharedInstance()
+ .GetImageSkiaNamed(IDR_PRODUCT_LOGO_128)
+ ->bitmap()));
+}
+
+void ArcKioskSplashScreenHandler::SetLaunchText(const std::string& text) {
+ CallJS("updateArcKioskMessage", text);
+}
+
+int ArcKioskSplashScreenHandler::GetProgressMessageFromState(
+ ArcKioskState state) {
+ switch (state) {
+ case ArcKioskState::STARTING_SESSION:
+ return IDS_SYNC_SETUP_SPINNER_TITLE;
+ case ArcKioskState::WAITING_APP_LAUNCH:
+ return IDS_APP_START_APP_WAIT_MESSAGE;
+ case ArcKioskState::WAITING_APP_WINDOW:
+ return IDS_APP_START_WAIT_FOR_APP_WINDOW_MESSAGE;
+ }
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.
+ return IDS_SYNC_SETUP_SPINNER_TITLE;
+}
+
+void ArcKioskSplashScreenHandler::HandleCancelArcKioskLaunch() {
+ if (!delegate_) {
+ LOG(WARNING) << "No delegate set to handle cancel app launch";
+ return;
+ }
+ delegate_->OnCancelArcKioskLaunch();
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698