-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This CL introduces MVP implementation of the OOBE Code Generator. This tool in a form of the Python script can create all needed boilerplate code with a given screen name and add new files to correct BUILD.gn files. After tool's work is done user will need only to integrate new screen into the wizard controller flow and add their business logic. Bug: b:266668077 Change-Id: I4e366ef5b1e842f5f719e485848c1991370c17b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4400951 Reviewed-by: Danila Kuzmin <dkuzmin@google.com> Commit-Queue: Bohdan Tyshchenko <bohdanty@google.com> Reviewed-by: Dirk Pranke <dpranke@google.com> Reviewed-by: Osama Fathy <osamafathy@google.com> Cr-Commit-Position: refs/heads/main@{#1152078}
- Loading branch information
Showing
13 changed files
with
741 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ash/login/screens/placeholder_screen.h" | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "base/values.h" | ||
#include "chrome/browser/ash/login/oobe_screen.h" | ||
#include "chrome/browser/ash/login/screens/base_screen.h" | ||
#include "chrome/browser/ash/login/wizard_context.h" | ||
#include "chrome/browser/ui/webui/ash/login/placeholder_screen_handler.h" | ||
|
||
namespace ash { | ||
namespace { | ||
|
||
constexpr char kUserActionBackButtonClicked[] = "back"; | ||
constexpr char kUserActionNextButtonClicked[] = "next"; | ||
|
||
} // namespace | ||
|
||
// static | ||
std::string PlaceholderScreen::GetResultString(Result result) { | ||
switch (result) { | ||
case Result::kNext: | ||
return "Next"; | ||
case Result::kBack: | ||
return "Back"; | ||
case Result::kNotApplicable: | ||
return BaseScreen::kNotApplicable; | ||
} | ||
} | ||
|
||
PlaceholderScreen::PlaceholderScreen(base::WeakPtr<PlaceholderScreenView> view, | ||
const ScreenExitCallback& exit_callback) | ||
: BaseScreen(PlaceholderScreenView::kScreenId, OobeScreenPriority::DEFAULT), | ||
view_(std::move(view)), | ||
exit_callback_(exit_callback) {} | ||
|
||
PlaceholderScreen::~PlaceholderScreen() = default; | ||
|
||
bool PlaceholderScreen::MaybeSkip(WizardContext& context) { | ||
return false; | ||
} | ||
|
||
void PlaceholderScreen::ShowImpl() { | ||
if (!view_) { | ||
return; | ||
} | ||
|
||
view_->Show(); | ||
} | ||
|
||
void PlaceholderScreen::HideImpl() {} | ||
|
||
void PlaceholderScreen::OnUserAction(const base::Value::List& args) { | ||
const std::string& action_id = args[0].GetString(); | ||
if (action_id == kUserActionNextButtonClicked) { | ||
exit_callback_.Run(Result::kNext); | ||
} else if (action_id == kUserActionBackButtonClicked) { | ||
exit_callback_.Run(Result::kBack); | ||
} else { | ||
BaseScreen::OnUserAction(args); | ||
} | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_ASH_LOGIN_SCREENS_PLACEHOLDER_SCREEN_H_ | ||
#define CHROME_BROWSER_ASH_LOGIN_SCREENS_PLACEHOLDER_SCREEN_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "base/functional/callback.h" | ||
#include "base/memory/weak_ptr.h" | ||
#include "base/values.h" | ||
#include "chrome/browser/ash/login/screens/base_screen.h" | ||
#include "chrome/browser/ash/login/wizard_context.h" | ||
|
||
namespace ash { | ||
|
||
class PlaceholderScreenView; | ||
|
||
class PlaceholderScreen : public BaseScreen { | ||
public: | ||
using TView = PlaceholderScreenView; | ||
|
||
enum class Result { kNext = 0, kBack, kNotApplicable }; | ||
|
||
using ScreenExitCallback = base::RepeatingCallback<void(Result result)>; | ||
|
||
PlaceholderScreen(base::WeakPtr<PlaceholderScreenView> view, | ||
const ScreenExitCallback& exit_callback); | ||
|
||
PlaceholderScreen(const PlaceholderScreen&) = delete; | ||
PlaceholderScreen& operator=(const PlaceholderScreen&) = delete; | ||
|
||
~PlaceholderScreen() override; | ||
|
||
static std::string GetResultString(Result result); | ||
|
||
private: | ||
// BaseScreen: | ||
bool MaybeSkip(WizardContext& context) override; | ||
void ShowImpl() override; | ||
void HideImpl() override; | ||
void OnUserAction(const base::Value::List& args) override; | ||
|
||
base::WeakPtr<PlaceholderScreenView> view_; | ||
ScreenExitCallback exit_callback_; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // CHROME_BROWSER_ASH_LOGIN_SCREENS_PLACEHOLDER_SCREEN_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
chrome/browser/resources/chromeos/login/screens/common/placeholder.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- | ||
Copyright 2023 The Chromium Authors | ||
Use of this source code is governed by a BSD-style license that can be | ||
found in the LICENSE file. | ||
--> | ||
<style include="oobe-dialog-host-styles"> | ||
|
||
/* Add styles here */ | ||
|
||
</style> | ||
<oobe-adaptive-dialog role="dialog"> | ||
<!-- Add HTML content here --> | ||
<h1 slot="title"> | ||
Your title | ||
</h1> | ||
<div slot="subtitle"> | ||
Your subtitle | ||
</div> | ||
<div slot="content" class="layout vertical"> | ||
Your content | ||
</div> | ||
<div slot="back-navigation"> | ||
<oobe-back-button id="backButton" | ||
on-click="onBackClicked_"></oobe-back-button> | ||
</div> | ||
<div slot="bottom-buttons"> | ||
<oobe-next-button id="nextButton" | ||
on-click="onNextClicked_"></oobe-next-button> | ||
</div> | ||
</oobe-adaptive-dialog> |
66 changes: 66 additions & 0 deletions
66
chrome/browser/resources/chromeos/login/screens/common/placeholder.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import '../../components/buttons/oobe_back_button.js'; | ||
import '../../components/buttons/oobe_next_button.js'; | ||
import '../../components/common_styles/oobe_common_styles.css.js'; | ||
import '../../components/common_styles/oobe_dialog_host_styles.css.js'; | ||
import '../../components/dialogs/oobe_adaptive_dialog.js'; | ||
|
||
import {html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; | ||
|
||
import {LoginScreenBehavior, LoginScreenBehaviorInterface} from '../../components/behaviors/login_screen_behavior.js'; | ||
import {OobeDialogHostBehavior} from '../../components/behaviors/oobe_dialog_host_behavior.js'; | ||
import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js'; | ||
|
||
/** | ||
* @constructor | ||
* @extends {PolymerElement} | ||
* @implements {LoginScreenBehaviorInterface} | ||
* @implements {OobeI18nBehaviorInterface} | ||
*/ | ||
const PlaceholderScreenElementBase = mixinBehaviors( | ||
[OobeI18nBehavior, OobeDialogHostBehavior, LoginScreenBehavior], | ||
PolymerElement); | ||
|
||
/** | ||
* @polymer | ||
*/ | ||
class PlaceholderScreen extends PlaceholderScreenElementBase { | ||
static get is() { | ||
return 'placeholder-element'; | ||
} | ||
|
||
static get template() { | ||
return html`{__html_template__}`; | ||
} | ||
|
||
static get properties() { | ||
return {}; | ||
} | ||
|
||
/** @override */ | ||
ready() { | ||
super.ready(); | ||
this.initializeLoginScreen('PlaceholderScreen'); | ||
} | ||
|
||
/** | ||
* Next button click handler. | ||
* @private | ||
*/ | ||
onNextClicked_() { | ||
this.userActed('next'); | ||
} | ||
|
||
/** | ||
* Back button click handler. | ||
* @private | ||
*/ | ||
onBackClicked_() { | ||
this.userActed('back'); | ||
} | ||
} | ||
|
||
customElements.define(PlaceholderScreen.is, PlaceholderScreen); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
chrome/browser/ui/webui/ash/login/placeholder_screen_handler.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// 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/ash/login/placeholder_screen_handler.h" | ||
|
||
#include "chrome/browser/ui/webui/ash/login/base_screen_handler.h" | ||
#include "components/login/localized_values_builder.h" | ||
|
||
namespace ash { | ||
|
||
PlaceholderScreenHandler::PlaceholderScreenHandler() | ||
: BaseScreenHandler(kScreenId) {} | ||
|
||
PlaceholderScreenHandler::~PlaceholderScreenHandler() = default; | ||
|
||
// Add localized values that you want to propagate to the JS side here. | ||
void PlaceholderScreenHandler::DeclareLocalizedValues( | ||
::login::LocalizedValuesBuilder* builder) {} | ||
|
||
void PlaceholderScreenHandler::Show() { | ||
ShowInWebUI(); | ||
} | ||
|
||
} // namespace ash |
53 changes: 53 additions & 0 deletions
53
chrome/browser/ui/webui/ash/login/placeholder_screen_handler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_UI_WEBUI_ASH_LOGIN_PLACEHOLDER_SCREEN_HANDLER_H_ | ||
#define CHROME_BROWSER_UI_WEBUI_ASH_LOGIN_PLACEHOLDER_SCREEN_HANDLER_H_ | ||
|
||
#include "base/memory/weak_ptr.h" | ||
#include "chrome/browser/ash/login/oobe_screen.h" | ||
#include "chrome/browser/ui/webui/ash/login/base_screen_handler.h" | ||
#include "components/login/localized_values_builder.h" | ||
|
||
namespace ash { | ||
|
||
class PlaceholderScreen; | ||
|
||
// Interface for dependency injection between PlaceholderScreen and its | ||
// WebUI representation. | ||
class PlaceholderScreenView | ||
: public base::SupportsWeakPtr<PlaceholderScreenView> { | ||
public: | ||
inline constexpr static StaticOobeScreenId kScreenId{"placeholder", | ||
"PlaceholderScreen"}; | ||
|
||
virtual ~PlaceholderScreenView() = default; | ||
|
||
// Shows the contents of the screen. | ||
virtual void Show() = 0; | ||
}; | ||
|
||
class PlaceholderScreenHandler : public BaseScreenHandler, | ||
public PlaceholderScreenView { | ||
public: | ||
using TView = PlaceholderScreenView; | ||
|
||
PlaceholderScreenHandler(); | ||
|
||
PlaceholderScreenHandler(const PlaceholderScreenHandler&) = delete; | ||
PlaceholderScreenHandler& operator=(const PlaceholderScreenHandler&) = delete; | ||
|
||
~PlaceholderScreenHandler() override; | ||
|
||
// BaseScreenHandler: | ||
void DeclareLocalizedValues( | ||
::login::LocalizedValuesBuilder* builder) override; | ||
|
||
// PlaceholderScreenView: | ||
void Show() override; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // CHROME_BROWSER_UI_WEBUI_ASH_LOGIN_PLACEHOLDER_SCREEN_HANDLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Metadata information for this directory. | ||
# | ||
# For more information on DIR_METADATA files, see: | ||
# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/README.md | ||
# | ||
# For the schema of this file, see Metadata message: | ||
# https://source.chromium.org/chromium/infra/infra/+/HEAD:go/src/infra/tools/dirmd/proto/dir_metadata.proto | ||
|
||
# ChromeOS > Software > OOBE | ||
buganizer { | ||
component_id: 1263090 | ||
} | ||
|
||
# ChromeOS Pubblic Tracker > UI > OOBE | ||
buganizer_public { | ||
component_id: 1263509 | ||
} | ||
|
||
team_email: "cros-oobe@google.com" | ||
os: CHROME_OS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bohdanty@google.com | ||
dkuzmin@google.com |
Oops, something went wrong.