Skip to content

Commit

Permalink
[ProfilePicker]: Add initial setup for chrome://profile-picker
Browse files Browse the repository at this point in the history
This CL adds an empty page chrome://profile-picker. The page is only
available if 'kNewProfilePicker' feature flag is enabled.

Bug: 1063856
Change-Id: Iec253cb9d28d77455dd684ae48b2d1a7c5feb507
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2156494
Reviewed-by: Samuel Huang <huangs@chromium.org>
Reviewed-by: David Roger <droger@chromium.org>
Reviewed-by: dpapad <dpapad@chromium.org>
Commit-Queue: Monica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762312}
  • Loading branch information
Monica Basta authored and Commit Bot committed Apr 24, 2020
1 parent 78d4edc commit b283c8e
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 9 deletions.
5 changes: 4 additions & 1 deletion chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,10 @@ group("extra_resources") {
}

if (!is_android && !is_chromeos) {
public_deps += [ "//chrome/browser/resources:welcome_resources" ]
public_deps += [
"//chrome/browser/resources:profile_picker_resources",
"//chrome/browser/resources:welcome_resources",
]
}

if (enable_extensions) {
Expand Down
18 changes: 18 additions & 0 deletions chrome/browser/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,24 @@ if (!is_android && !is_chromeos) {
]
output_dir = "$root_gen_dir/chrome"
}

grit("profile_picker_resources") {
source = "signin/profile_picker/profile_picker_resources.grd"

grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
]

defines = chrome_grit_defines
outputs = [
"grit/profile_picker_resources.h",
"grit/profile_picker_resources_map.cc",
"grit/profile_picker_resources_map.h",
"profile_picker_resources.pak",
]
output_dir = "$root_gen_dir/chrome"
}
}

if (enable_extensions) {
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/resources/signin/profile_picker/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://crbug.com/1063856

msalama@chromium.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
</head>
<body>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/profile_picker_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/profile_picker_resources_map.cc"
type="resource_file_map_source" />
<output filename="grit/profile_picker_resources_map.h"
type="resource_map_header" />
<output filename="profile_picker_resources.pak" type="data_package" />
</outputs>
<release seq="1">
<structures>
<structure
name="IDR_PROFILE_PICKER_PROFILE_PICKER_HTML"
file="profile_picker.html"
type="chrome_html"
compress="false"/>
</structures>
</release>
</grit>
2 changes: 2 additions & 0 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,8 @@ jumbo_static_library("ui") {
"webui/settings/system_handler.h",
"webui/signin/inline_login_handler_impl.cc",
"webui/signin/inline_login_handler_impl.h",
"webui/signin/profile_picker_ui.cc",
"webui/signin/profile_picker_ui.h",
"webui/signin/signin_create_profile_handler.cc",
"webui/signin/signin_create_profile_handler.h",
"webui/signin/signin_email_confirmation_dialog.cc",
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@

#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/browser_switch/browser_switch_ui.h"
#include "chrome/browser/ui/webui/signin/profile_picker_ui.h"
#include "chrome/browser/ui/webui/signin/signin_email_confirmation_ui.h"
#include "chrome/browser/ui/webui/signin/signin_error_ui.h"
#include "chrome/browser/ui/webui/signin/user_manager_ui.h"
Expand Down Expand Up @@ -689,6 +691,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
#endif // defined(OS_ANDROID)
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
if (url.host_piece() == chrome::kChromeUIProfilePickerHost &&
base::FeatureList::IsEnabled(features::kNewProfilePicker)) {
return &NewWebUI<ProfilePickerUI>;
}

if (url.host_piece() == chrome::kChromeUIMdUserManagerHost)
return &NewWebUI<UserManagerUI>;
if (url.host_piece() == chrome::kChromeUISigninErrorHost &&
Expand Down
30 changes: 30 additions & 0 deletions chrome/browser/ui/webui/signin/profile_picker_ui.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2020 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/signin/profile_picker_ui.h"

#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/profile_picker_resources.h"
#include "chrome/grit/profile_picker_resources_map.h"
#include "content/public/browser/web_ui_data_source.h"

ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(chrome::kChromeUIProfilePickerHost);

std::string generated_path =
"@out_folder@/gen/chrome/browser/resources/signin/profile_picker/";
webui::SetupWebUIDataSource(
html_source,
base::make_span(kProfilePickerResources, kProfilePickerResourcesSize),
generated_path, IDR_PROFILE_PICKER_PROFILE_PICKER_HTML);

content::WebUIDataSource::Add(profile, html_source);
}

ProfilePickerUI::~ProfilePickerUI() = default;
20 changes: 20 additions & 0 deletions chrome/browser/ui/webui/signin/profile_picker_ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2020 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.

#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_UI_H_
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_UI_H_

#include "content/public/browser/web_ui_controller.h"

// The WebUI controller for chrome://profile-picker/.
class ProfilePickerUI : public content::WebUIController {
public:
explicit ProfilePickerUI(content::WebUI* web_ui);
~ProfilePickerUI() override;

private:
DISALLOW_COPY_AND_ASSIGN(ProfilePickerUI);
};

#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_UI_H_
10 changes: 8 additions & 2 deletions chrome/chrome_paks.gni
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,14 @@ template("chrome_extra_paks") {
}
}
if (!is_android && !is_chromeos) {
sources += [ "$root_gen_dir/chrome/welcome_resources.pak" ]
deps += [ "//chrome/browser/resources:welcome_resources" ]
sources += [
"$root_gen_dir/chrome/profile_picker_resources.pak",
"$root_gen_dir/chrome/welcome_resources.pak",
]
deps += [
"//chrome/browser/resources:profile_picker_resources",
"//chrome/browser/resources:welcome_resources",
]
}
if (enable_extensions) {
sources += [
Expand Down
1 change: 1 addition & 0 deletions chrome/common/webui_url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ const char kChromeUIDiscardsHost[] = "discards";
const char kChromeUIDiscardsURL[] = "chrome://discards/";
const char kChromeUIHatsHost[] = "hats";
const char kChromeUIHatsURL[] = "chrome://hats/";
const char kChromeUIProfilePickerHost[] = "profile-picker";
#endif

#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
Expand Down
1 change: 1 addition & 0 deletions chrome/common/webui_url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ extern const char kChromeUIDiscardsHost[];
extern const char kChromeUIDiscardsURL[];
extern const char kChromeUIHatsHost[];
extern const char kChromeUIHatsURL[];
extern const char kChromeUIProfilePickerHost[];

#endif

Expand Down
15 changes: 9 additions & 6 deletions tools/gritsettings/resource_ids.spec
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,22 @@
"includes": [1810],
"structures": [1820],
},
"chrome/browser/resources/tab_strip/tab_strip_resources.grd": {
"chrome/browser/resources/signin/profile_picker/profile_picker_resources.grd": {
"structures": [1840],
"includes": [1860],
},
"chrome/browser/resources/welcome/welcome_resources.grd": {
"chrome/browser/resources/tab_strip/tab_strip_resources.grd": {
"structures": [1860],
"includes": [1880],
"structures": [1900],
},
"chrome/browser/resources/welcome/welcome_resources.grd": {
"includes": [1900],
"structures": [1920],
},
"chrome/browser/supervised_user/supervised_user_unscaled_resources.grd": {
"includes": [1910],
"includes": [1930],
},
"chrome/browser/vr/testapp/vr_testapp_resources.grd": {
"includes": [1930],
"includes": [1950],
},
# END chrome/browser section.

Expand Down

0 comments on commit b283c8e

Please sign in to comment.