Skip to content

Commit

Permalink
Show and start tutorials from chrome://internals/user-education/
Browse files Browse the repository at this point in the history
Wires up the WebUI page to tutorials infrastructure. Currently
starting a tutorial will do nothing since FeatureTutorialService is a
stub.

Bug: 1194751
Change-Id: I32b9df5028195cbe692ae94a1475bcf6cd75da22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2875644
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Dana Fried <dfried@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880629}
  • Loading branch information
chbaker0 authored and Chromium LUCI CQ committed May 7, 2021
1 parent b8ff31b commit 01565ee
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
Expand Up @@ -35,9 +35,9 @@ class UserEducationInternalsElement extends PolymerElement {
/** @override */
ready() {
super.ready();
// TODO(crbug.com/1194751): fetch tutorial IDs from handler and display
// them.
this.tutorials_ = ['test1', 'test2'];
this.handler_.getTutorials().then(({tutorialIds}) => {
this.tutorials_ = tutorialIds;
});
}

/**
Expand Down
Expand Up @@ -7,6 +7,10 @@ module mojom.user_education_internals;
// Provides access to browser-side user education data (including IPH) for
// chrome://internals/user-education
interface UserEducationInternalsPageHandler {
// TODO(crbug.com/1194751): add methods for getting list of tutorials
// and starting a tutorial.
// Get the list of all available tutorials. Only needs to be called once
// since the browser-side list is static and does not change.
GetTutorials() => (array<string> tutorial_ids);

// Start a tutorial listed in the `GetTutorials` result.
StartTutorial(string tutorial_id);
};
Expand Up @@ -4,15 +4,36 @@

#include "chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h"

#include "chrome/browser/ui/user_education/feature_tutorial_service.h"
#include "chrome/browser/ui/user_education/feature_tutorial_service_factory.h"
#include "chrome/browser/ui/user_education/feature_tutorials.h"
#include "chrome/grit/dev_ui_browser_resources.h"
#include "ui/base/webui/resource_path.h"

UserEducationInternalsPageHandlerImpl::UserEducationInternalsPageHandlerImpl(
Profile* profile)
/* : profile_(profile) */ {
// TODO(crbug.com/1194751): get reference to tutorial registry (once
// implemented).
: tutorial_service_(FeatureTutorialServiceFactory::GetForProfile(profile)) {
}

UserEducationInternalsPageHandlerImpl::
~UserEducationInternalsPageHandlerImpl() = default;

void UserEducationInternalsPageHandlerImpl::GetTutorials(
GetTutorialsCallback callback) {
std::vector<base::StringPiece> id_pieces = GetAllFeatureTutorialStringIds();

std::vector<std::string> ids;
for (base::StringPiece piece : id_pieces)
ids.emplace_back(piece.data(), piece.size());

std::move(callback).Run(std::move(ids));
}

void UserEducationInternalsPageHandlerImpl::StartTutorial(
const std::string& tutorial_id) {
base::Optional<FeatureTutorial> tutorial =
GetFeatureTutorialFromStringId(tutorial_id);
if (!tutorial)
return;
tutorial_service_->StartTutorial(*tutorial);
}
Expand Up @@ -9,6 +9,8 @@
#include "chrome/browser/ui/webui/internals/user_education/user_education_internals.mojom.h"
#include "content/public/browser/web_ui_data_source.h"

class FeatureTutorialService;

class UserEducationInternalsPageHandlerImpl
: public mojom::user_education_internals::
UserEducationInternalsPageHandler {
Expand All @@ -21,8 +23,12 @@ class UserEducationInternalsPageHandlerImpl
UserEducationInternalsPageHandlerImpl& operator=(
const UserEducationInternalsPageHandlerImpl&) = delete;

// mojom::user_education_internals::UserEducationInternalsPageHandler:
void GetTutorials(GetTutorialsCallback callback) override;
void StartTutorial(const std::string& tutorial_id) override;

private:
// Profile* profile_ = nullptr;
FeatureTutorialService* const tutorial_service_;
};

#endif // CHROME_BROWSER_UI_WEBUI_INTERNALS_USER_EDUCATION_USER_EDUCATION_INTERNALS_PAGE_HANDLER_IMPL_H_

0 comments on commit 01565ee

Please sign in to comment.