Skip to content

Commit e58951f

Browse files
cwmoo740Chromium LUCI CQ
authored and
Chromium LUCI CQ
committed
personalization: create skeleton SWA at chrome://personalization
Prepare to move wallpaper code out of chrome://os-settings/wallpaper to new SWA. Follow up CL will move existing wallpaper polymer code and browser handler functionality, then delete os_settings wallpaper code. BUG=b:182012553 Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome Change-Id: I778322076a3bc7057499a8ac58d7e333e41ae5f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2737214 Commit-Queue: Jeffrey Young <cowmoo@chromium.org> Reviewed-by: Steven Holte <holte@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org> Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org> Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org> Cr-Commit-Position: refs/heads/master@{#864009}
1 parent f785f34 commit e58951f

28 files changed

+300
-1
lines changed

chrome/app/chromeos_strings.grdp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
Time limit removed for <ph name="APP_NAME">$1<ex>Gmail</ex></ph>
3434
</message>
3535

36-
<!-- Wallpaper Manager -->
36+
<!-- Wallpaper Manager (Deprecated Chrome App Version) -->
3737
<message name="IDS_WALLPAPER_MANAGER_APP_NAME" desc="Name of the app which allows users to pick their wallpaper.">
3838
Wallpaper Picker
3939
</message>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "chrome/browser/ash/web_applications/personalization_app_info.h"
6+
7+
#include <memory>
8+
9+
#include "chrome/browser/ash/web_applications/system_web_app_install_utils.h"
10+
#include "chrome/browser/web_applications/components/web_application_info.h"
11+
#include "chromeos/components/personalization_app/personalization_app_url_constants.h"
12+
#include "chromeos/grit/chromeos_personalization_app_resources.h"
13+
#include "chromeos/strings/grit/chromeos_strings.h"
14+
#include "third_party/blink/public/mojom/manifest/display_mode.mojom.h"
15+
#include "ui/base/l10n/l10n_util.h"
16+
17+
std::unique_ptr<WebApplicationInfo> CreateWebAppInfoForPersonalizationApp() {
18+
std::unique_ptr<WebApplicationInfo> info =
19+
std::make_unique<WebApplicationInfo>();
20+
info->start_url = GURL(chromeos::kChromeUIPersonalizationAppURL);
21+
info->scope = GURL(chromeos::kChromeUIPersonalizationAppURL);
22+
info->title = l10n_util::GetStringUTF16(IDS_PERSONALIZATION_APP_TITLE);
23+
web_app::CreateIconInfoForSystemWebApp(
24+
info->start_url,
25+
{{"app_icon_192.png", 192,
26+
IDR_CHROMEOS_PERSONALIZATION_APP_ICON_192_PNG}},
27+
*info);
28+
info->display_mode = blink::mojom::DisplayMode::kStandalone;
29+
info->open_as_window = true;
30+
31+
return info;
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef CHROME_BROWSER_ASH_WEB_APPLICATIONS_PERSONALIZATION_APP_INFO_H_
6+
#define CHROME_BROWSER_ASH_WEB_APPLICATIONS_PERSONALIZATION_APP_INFO_H_
7+
8+
#include <memory>
9+
10+
struct WebApplicationInfo;
11+
12+
// Return a WebApplicationInfo used to install the app.
13+
std::unique_ptr<WebApplicationInfo> CreateWebAppInfoForPersonalizationApp();
14+
15+
#endif // CHROME_BROWSER_ASH_WEB_APPLICATIONS_PERSONALIZATION_APP_INFO_H_

chrome/browser/chromeos/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ source_set("chromeos") {
134134
"//chromeos/components/multidevice",
135135
"//chromeos/components/multidevice:stub_multidevice_util",
136136
"//chromeos/components/multidevice/logging",
137+
"//chromeos/components/personalization_app",
137138
"//chromeos/components/phonehub",
138139
"//chromeos/components/power",
139140
"//chromeos/components/print_management",
@@ -219,6 +220,7 @@ source_set("chromeos") {
219220
"//chromeos/resources:eche_bundle_resources_grit",
220221
"//chromeos/resources:help_app_resources_grit",
221222
"//chromeos/resources:media_app_resources_grit",
223+
"//chromeos/resources:personalization_app_resources_grit",
222224
"//chromeos/resources:print_management_resources_grit",
223225
"//chromeos/resources:scanning_app_resources_grit",
224226
"//chromeos/services/assistant/public/cpp",
@@ -1292,6 +1294,8 @@ source_set("chromeos") {
12921294
"../ash/web_applications/media_web_app_info.h",
12931295
"../ash/web_applications/os_settings_web_app_info.cc",
12941296
"../ash/web_applications/os_settings_web_app_info.h",
1297+
"../ash/web_applications/personalization_app_info.cc",
1298+
"../ash/web_applications/personalization_app_info.h",
12951299
"../ash/web_applications/print_management_web_app_info.cc",
12961300
"../ash/web_applications/print_management_web_app_info.h",
12971301
"../ash/web_applications/scanning_system_web_app_info.cc",

chrome/browser/ui/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,7 @@ static_library("ui") {
27152715
"//chromeos/components/multidevice/logging",
27162716
"//chromeos/components/network_ui:network_diagnostics_resource_provider",
27172717
"//chromeos/components/network_ui:network_health_resource_provider",
2718+
"//chromeos/components/personalization_app",
27182719
"//chromeos/components/phonehub",
27192720
"//chromeos/components/phonehub:debug",
27202721
"//chromeos/components/print_management",

chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc

+6
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@
223223
#include "chromeos/components/media_app_ui/url_constants.h"
224224
#include "chromeos/components/multidevice/debug_webui/proximity_auth_ui.h"
225225
#include "chromeos/components/multidevice/debug_webui/url_constants.h"
226+
#include "chromeos/components/personalization_app/personalization_app_ui.h"
227+
#include "chromeos/components/personalization_app/personalization_app_url_constants.h"
226228
#include "chromeos/components/print_management/print_management_ui.h"
227229
#include "chromeos/components/print_management/url_constants.h"
228230
#include "chromeos/components/scanning/scanning_ui.h"
@@ -839,6 +841,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
839841
if (url.host_piece() == chrome::kChromeUIPluginVmInternalHost) {
840842
return &NewWebUI<chromeos::PluginVmInternalUI>;
841843
}
844+
if (url.host_piece() == chromeos::kChromeUIPersonalizationAppHost &&
845+
chromeos::features::IsWallpaperWebUIEnabled()) {
846+
return &NewWebUI<chromeos::PersonalizationAppUI>;
847+
}
842848

843849
#if !defined(OFFICIAL_BUILD)
844850
#if !defined(USE_REAL_DBUS_CLIENTS)

chrome/browser/web_applications/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ source_set("web_applications") {
112112
"//chromeos/components/eche_app_ui",
113113
"//chromeos/components/help_app_ui",
114114
"//chromeos/components/media_app_ui",
115+
"//chromeos/components/personalization_app",
115116
"//chromeos/strings",
116117
"//components/arc:arc_base",
117118
"//components/arc/mojom",

chrome/browser/web_applications/components/system_web_app_types.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum class SystemAppType {
3030
CONNECTIVITY_DIAGNOSTICS = 12,
3131
ECHE = 13,
3232
CROSH = 14,
33+
PERSONALIZATION = 15,
3334

3435
// When adding a new System App, remember to:
3536
//

chrome/browser/web_applications/proto/web_app.proto

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ message SystemWebAppDataProto {
7373
CONNECTIVITY_DIAGNOSTICS = 12;
7474
ECHE = 13;
7575
CROSH = 14;
76+
PERSONALIZATION = 15;
7677
};
7778

7879
optional SystemAppType system_app_type = 1;

chrome/browser/web_applications/system_web_app_manager.cc

+14
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "chrome/browser/ash/web_applications/help_app_web_app_info.h"
6565
#include "chrome/browser/ash/web_applications/media_web_app_info.h"
6666
#include "chrome/browser/ash/web_applications/os_settings_web_app_info.h"
67+
#include "chrome/browser/ash/web_applications/personalization_app_info.h"
6768
#include "chrome/browser/ash/web_applications/print_management_web_app_info.h"
6869
#include "chrome/browser/ash/web_applications/scanning_system_web_app_info.h"
6970
#include "chrome/browser/ash/web_applications/terminal_system_web_app_info.h"
@@ -72,6 +73,7 @@
7273
#include "chromeos/components/connectivity_diagnostics/url_constants.h"
7374
#include "chromeos/components/help_app_ui/url_constants.h"
7475
#include "chromeos/components/media_app_ui/url_constants.h"
76+
#include "chromeos/components/personalization_app/personalization_app_url_constants.h"
7577
#include "chromeos/strings/grit/chromeos_strings.h"
7678
#include "extensions/common/constants.h"
7779
#if !defined(OFFICIAL_BUILD)
@@ -247,6 +249,16 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps(
247249
false;
248250
}
249251

252+
if (SystemWebAppManager::IsAppEnabled(SystemAppType::PERSONALIZATION)) {
253+
infos.emplace(
254+
SystemAppType::PERSONALIZATION,
255+
SystemAppInfo(
256+
"Personalization", GURL(chromeos::kChromeUIPersonalizationAppURL),
257+
base::BindRepeating(&CreateWebAppInfoForPersonalizationApp)));
258+
auto& personalization_info = infos.at(SystemAppType::PERSONALIZATION);
259+
personalization_info.capture_navigations = true;
260+
}
261+
250262
#if !defined(OFFICIAL_BUILD)
251263
if (SystemWebAppManager::IsAppEnabled(SystemAppType::TELEMETRY)) {
252264
infos.emplace(
@@ -388,6 +400,8 @@ bool SystemWebAppManager::IsAppEnabled(SystemAppType type) {
388400
return false;
389401
case SystemAppType::ECHE:
390402
return base::FeatureList::IsEnabled(chromeos::features::kEcheSWA);
403+
case SystemAppType::PERSONALIZATION:
404+
return chromeos::features::IsWallpaperWebUIEnabled();
391405
}
392406
#else
393407
return false;

chrome/chrome_paks.gni

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ template("chrome_extra_paks") {
202202
"$root_gen_dir/chromeos/chromeos_help_app_resources.pak",
203203
"$root_gen_dir/chromeos/chromeos_media_app_bundle_resources.pak",
204204
"$root_gen_dir/chromeos/chromeos_media_app_resources.pak",
205+
"$root_gen_dir/chromeos/chromeos_personalization_app_resources.pak",
205206
"$root_gen_dir/chromeos/chromeos_print_management_resources.pak",
206207
"$root_gen_dir/chromeos/chromeos_resources.pak",
207208
"$root_gen_dir/chromeos/chromeos_scanning_app_resources.pak",
@@ -233,6 +234,7 @@ template("chrome_extra_paks") {
233234
"//chromeos/resources:help_app_resources",
234235
"//chromeos/resources:media_app_bundle_resources",
235236
"//chromeos/resources:media_app_resources",
237+
"//chromeos/resources:personalization_app_resources",
236238
"//chromeos/resources:print_management_resources",
237239
"//chromeos/resources:scanning_app_resources",
238240
"//ui/file_manager:file_manager_gen_resources",

chromeos/chromeos_strings.grd

+5
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,11 @@ Try tapping the mic to ask me anything.
13961396
<message name="IDS_NETWORK_DIAGNOSTICS_VIDEO_CONFERENCING_PROBLEM_MEDIA_FAILURE" desc="Error message shown when a connection cannot be established to the video conferencing media servers">
13971397
Unable to connect to media servers
13981398
</message>
1399+
1400+
<!-- Personalization App -->
1401+
<message name="IDS_PERSONALIZATION_APP_TITLE" desc="Name of the system web app for personalizing ChromeOS.">
1402+
Wallpaper
1403+
</message>
13991404
</messages>
14001405
</release>
14011406
</grit>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4a629e521b00d56d08511bad0a29d723dc4ccfa0

chromeos/components/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ group("closure_compile") {
6363
"//chromeos/components/help_app_ui:closure_compile",
6464
"//chromeos/components/media_app_ui:closure_compile",
6565
"//chromeos/components/multidevice/debug_webui/resources:closure_compile",
66+
"//chromeos/components/personalization_app:closure_compile",
6667
"//chromeos/components/print_management:closure_compile",
6768
"//chromeos/components/scanning:closure_compile",
6869
"//chromeos/components/system_apps:closure_compile",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
assert(is_chromeos, "Personalization App is Chrome OS only")
6+
7+
static_library("personalization_app") {
8+
sources = [
9+
"personalization_app_ui.cc",
10+
"personalization_app_ui.h",
11+
"personalization_app_url_constants.cc",
12+
"personalization_app_url_constants.h",
13+
]
14+
15+
deps = [
16+
"//chromeos/resources:personalization_app_resources",
17+
"//chromeos/strings",
18+
"//content/public/browser",
19+
"//ui/webui",
20+
]
21+
}
22+
23+
group("closure_compile") {
24+
deps = [ "resources:closure_compile" ]
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include_rules = [
2+
"-chrome",
3+
"+chromeos/grit/chromeos_personalization_app_resources.h",
4+
"+content/public/browser",
5+
"+ui/webui",
6+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
file://chromeos/assistant/OWNERS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "chromeos/components/personalization_app/personalization_app_ui.h"
6+
7+
#include "chromeos/components/personalization_app/personalization_app_url_constants.h"
8+
#include "chromeos/grit/chromeos_personalization_app_resources.h"
9+
#include "chromeos/grit/chromeos_personalization_app_resources_map.h"
10+
#include "chromeos/strings/grit/chromeos_strings.h"
11+
#include "content/public/browser/web_contents.h"
12+
#include "content/public/browser/web_ui_data_source.h"
13+
#include "ui/webui/mojo_web_ui_controller.h"
14+
15+
namespace chromeos {
16+
17+
namespace {
18+
19+
void AddResources(content::WebUIDataSource* source) {
20+
source->AddResourcePath("", IDR_CHROMEOS_PERSONALIZATION_APP_INDEX_HTML);
21+
source->AddResourcePaths(
22+
base::make_span(kChromeosPersonalizationAppResources,
23+
kChromeosPersonalizationAppResourcesSize));
24+
25+
#if !DCHECK_IS_ON()
26+
source->SetDefaultResource(IDR_CHROMEOS_PERSONALIZATION_APP_INDEX_HTML);
27+
#endif // !DCHECK_IS_ON()
28+
}
29+
30+
void AddStrings(content::WebUIDataSource* source) {
31+
static constexpr webui::LocalizedString kLocalizedStrings[] = {
32+
{"title", IDS_PERSONALIZATION_APP_TITLE}};
33+
source->AddLocalizedStrings(kLocalizedStrings);
34+
source->UseStringsJs();
35+
}
36+
37+
} // namespace
38+
39+
PersonalizationAppUI::PersonalizationAppUI(content::WebUI* web_ui)
40+
: ui::MojoWebUIController(web_ui) {
41+
auto source = base::WrapUnique(
42+
content::WebUIDataSource::Create(kChromeUIPersonalizationAppHost));
43+
44+
AddResources(source.get());
45+
AddStrings(source.get());
46+
47+
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
48+
content::WebUIDataSource::Add(browser_context, source.release());
49+
}
50+
51+
PersonalizationAppUI::~PersonalizationAppUI() = default;
52+
53+
} // namespace chromeos
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef CHROMEOS_COMPONENTS_PERSONALIZATION_APP_PERSONALIZATION_APP_UI_H_
6+
#define CHROMEOS_COMPONENTS_PERSONALIZATION_APP_PERSONALIZATION_APP_UI_H_
7+
8+
#include "ui/webui/mojo_web_ui_controller.h"
9+
10+
namespace chromeos {
11+
12+
class PersonalizationAppUI : public ui::MojoWebUIController {
13+
public:
14+
explicit PersonalizationAppUI(content::WebUI* web_ui);
15+
PersonalizationAppUI(const PersonalizationAppUI&) = delete;
16+
PersonalizationAppUI& operator=(const PersonalizationAppUI&) = delete;
17+
~PersonalizationAppUI() override;
18+
};
19+
20+
} // namespace chromeos
21+
22+
#endif // CHROMEOS_COMPONENTS_PERSONALIZATION_APP_PERSONALIZATION_APP_UI_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "chromeos/components/personalization_app/personalization_app_url_constants.h"
6+
7+
namespace chromeos {
8+
9+
const char kChromeUIPersonalizationAppHost[] = "personalization";
10+
const char kChromeUIPersonalizationAppURL[] = "chrome://personalization";
11+
12+
} // namespace chromeos
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2021 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef CHROMEOS_COMPONENTS_PERSONALIZATION_APP_PERSONALIZATION_APP_URL_CONSTANTS_H_
6+
#define CHROMEOS_COMPONENTS_PERSONALIZATION_APP_PERSONALIZATION_APP_URL_CONSTANTS_H_
7+
8+
namespace chromeos {
9+
10+
extern const char kChromeUIPersonalizationAppHost[];
11+
extern const char kChromeUIPersonalizationAppURL[];
12+
13+
} // namespace chromeos
14+
15+
#endif // CHROMEOS_COMPONENTS_PERSONALIZATION_APP_PERSONALIZATION_APP_URL_CONSTANTS_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("//third_party/closure_compiler/compile_js.gni")
6+
import("//tools/grit/grit_rule.gni")
7+
import("//ui/webui/resources/tools/generate_grd.gni")
8+
9+
generate_grd("build_grd") {
10+
input_files_base_dir = rebase_path(".", "//")
11+
input_files = [
12+
"index.html",
13+
"icon_192.png",
14+
"personalization_app.js",
15+
]
16+
manifest_files = []
17+
grd_prefix = "chromeos_personalization_app"
18+
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
19+
}
20+
21+
js_type_check("closure_compile") {
22+
is_polymer3 = true
23+
deps = [ ":personalization_app" ]
24+
}
25+
26+
js_library("personalization_app") {
27+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- Copyright 2021 The Chromium Authors. All rights reserved.
2+
Use of this source code is governed by a BSD-style license that can be
3+
found in the LICENSE file. -->
4+
<!DOCTYPE html>
5+
<html dir="$i18n{textdirection}" lang="$i18n{language}">
6+
<head>
7+
<title>$i18n{title}</title>
8+
<link rel="icon" type="image/png" sizes="192x192" href="icon_192.png">
9+
<meta charset="utf-8">
10+
<script type="module" src="personalization_app.js" defer></script>
11+
</head>
12+
<body>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)