Commit 3be7c748 authored by Rachel Carpenter's avatar Rachel Carpenter Committed by Commit Bot

Launch Help app post OOBE.

Users should now land on the Help app rather than the welcome tour post
OOBE. Use the same triggering logic as was present before, including
prefs to ensure that users who saw the welcome tour are not subsequently
shown the Help app.

Use AppServiceProxy so that we can track usage through
Apps.DefaultAppLaunch.FromChromeInternal::Get Help

Bug: 1001460, b/145710734
Change-Id: I5aaece65b9a858a913a533209dc33652008021aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003155
Commit-Queue: Rachel Carpenter <carpenterr@google.com>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733811}
parent 1ab7f5d8
......@@ -8,8 +8,8 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/launch_service/launch_service.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/first_run/first_run_controller.h"
......@@ -38,6 +38,8 @@
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "ui/display/types/display_constants.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/geometry/rect.h"
namespace chromeos {
......@@ -45,33 +47,34 @@ namespace first_run {
namespace {
void LaunchDialogForProfile(Profile* profile) {
void LaunchHelpForProfile(Profile* profile) {
extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(profile);
if (!registry)
return;
const extensions::Extension* extension =
registry->GetExtensionById(extension_misc::kFirstRunDialogId,
extensions::ExtensionRegistry::ENABLED);
const extensions::Extension* extension = registry->GetExtensionById(
extension_misc::kGeniusAppId, extensions::ExtensionRegistry::ENABLED);
if (!extension)
return;
apps::LaunchService::Get(profile)->OpenApplication(apps::AppLaunchParams(
extension->id(), apps::mojom::LaunchContainer::kLaunchContainerWindow,
WindowOpenDisposition::NEW_WINDOW,
apps::mojom::AppLaunchSource::kSourceChromeInternal));
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
DCHECK(proxy);
proxy->Launch(extension->id(), ui::EventFlags::EF_NONE,
apps::mojom::LaunchSource::kFromChromeInternal,
display::kInvalidDisplayId);
profile->GetPrefs()->SetBoolean(prefs::kFirstRunTutorialShown, true);
}
void TryLaunchFirstRunDialog(Profile* profile) {
void TryLaunchHelpApp(Profile* profile) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (chromeos::switches::ShouldSkipOobePostLogin())
return;
if (command_line->HasSwitch(switches::kForceFirstRunUI)) {
LaunchDialogForProfile(profile);
LaunchHelpForProfile(profile);
return;
}
......@@ -98,19 +101,16 @@ void TryLaunchFirstRunDialog(Profile* profile) {
if (!is_pref_synced && is_user_ephemeral)
return;
LaunchDialogForProfile(profile);
LaunchHelpForProfile(profile);
}
// Object of this class waits for session start. Then it launches or not
// launches first-run dialog depending on user prefs and flags. Than object
// deletes itself.
class DialogLauncher : public session_manager::SessionManagerObserver {
// Object of this class waits for session start. Then it maybe launches the help
// app depending on user prefs and flags. The object then deletes itself.
class AppLauncher : public session_manager::SessionManagerObserver {
public:
DialogLauncher() {
session_manager::SessionManager::Get()->AddObserver(this);
}
AppLauncher() { session_manager::SessionManager::Get()->AddObserver(this); }
~DialogLauncher() override {
~AppLauncher() override {
session_manager::SessionManager::Get()->RemoveObserver(this);
}
......@@ -118,12 +118,12 @@ class DialogLauncher : public session_manager::SessionManagerObserver {
void OnUserSessionStarted(bool is_primary_user) override {
auto* profile = ProfileHelper::Get()->GetProfileByUser(
user_manager::UserManager::Get()->GetActiveUser());
TryLaunchFirstRunDialog(profile);
TryLaunchHelpApp(profile);
delete this;
}
private:
DISALLOW_COPY_AND_ASSIGN(DialogLauncher);
DISALLOW_COPY_AND_ASSIGN(AppLauncher);
};
} // namespace
......@@ -135,8 +135,8 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kFirstRunTutorialShown, false);
}
void MaybeLaunchDialogAfterSessionStart() {
new DialogLauncher();
void MaybeLaunchHelpAppAfterSessionStart() {
new AppLauncher();
}
void LaunchTutorial() {
......
......@@ -15,10 +15,10 @@ namespace first_run {
// Registers preferences related to ChromeOS first-run tutorial.
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
// Probably launches first-run dialog after session start depending on synced
// user prefs. This method should be called after user already logged in but
// session didn't started yet.
void MaybeLaunchDialogAfterSessionStart();
// Maybe launches the help app after session start (depending on synced user
// prefs and flags). This method should be called after the user has already
// logged in and before the session starts.
void MaybeLaunchHelpAppAfterSessionStart();
// Launches overlay tutorial for current user.
void LaunchTutorial();
......
......@@ -1821,7 +1821,7 @@ void UserSessionManager::InitializeStartUrls() const {
// background.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
::switches::kSilentLaunch);
first_run::MaybeLaunchDialogAfterSessionStart();
first_run::MaybeLaunchHelpAppAfterSessionStart();
} else {
for (size_t i = 0; i < start_urls.size(); ++i) {
base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment