Commit 3bdb21df authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Migrate Google Calendar default web app from JSON to C++

This copies the JSON config for Google Calendar
https://chrome-internal.googlesource.com/chromeos/overlays/chromeos-overlay/+/master/chromeos-base/chromeos-default-apps/files/web_apps/calendar.json
to C++ in the Chrome OS binary. The JSON configs will be removed
in a follow up CL to avoid data duplication in multiple
locations and formats.

This CL also addresses issues found in the existing JSON config:
https://chrome-internal-review.googlesource.com/c/chromeos/overlays/chromeos-overlay/+/3323009/comment/8f887088_d4b89b50/

This migration is to make use of the app name localization machinery.

Bug: 1147410, 1058265
Change-Id: I1a03a1d7d1c5c41cb0027dc8fba2811b5e06083d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550151
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarGlen Robertson <glenrob@chromium.org>
Reviewed-by: default avatarTim Sergeant <tsergeant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830071}
parent cd19e31f
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
<include name="IDR_PREINSTALLED_WEB_APPS_GOOGLE_SLIDES_ICON_192_PNG" file="internal/google_slides_192.png" type="BINDATA" /> <include name="IDR_PREINSTALLED_WEB_APPS_GOOGLE_SLIDES_ICON_192_PNG" file="internal/google_slides_192.png" type="BINDATA" />
<include name="IDR_PREINSTALLED_WEB_APPS_GMAIL_ICON_192_PNG" file="internal/gmail_192.png" type="BINDATA" /> <include name="IDR_PREINSTALLED_WEB_APPS_GMAIL_ICON_192_PNG" file="internal/gmail_192.png" type="BINDATA" />
<include name="IDR_PREINSTALLED_WEB_APPS_YOUTUBE_ICON_192_PNG" file="internal/youtube_192.png" type="BINDATA" /> <include name="IDR_PREINSTALLED_WEB_APPS_YOUTUBE_ICON_192_PNG" file="internal/youtube_192.png" type="BINDATA" />
<if expr="chromeos">
<include name="IDR_PREINSTALLED_WEB_APPS_GOOGLE_CALENDAR_ICON_192_PNG" file="internal/google_calendar_192.png" type="BINDATA" />
</if>
</includes> </includes>
</release> </release>
</grit> </grit>
...@@ -15,7 +15,7 @@ namespace web_app { ...@@ -15,7 +15,7 @@ namespace web_app {
// "chrome://camera-app/views/main.html")) // "chrome://camera-app/views/main.html"))
constexpr char kCameraAppId[] = "njfbnohfdkmbmnjapinfcopialeghnmh"; constexpr char kCameraAppId[] = "njfbnohfdkmbmnjapinfcopialeghnmh";
// Generated as: // web_app::GenerateAppIdFromURL(GURL( // Generated as: web_app::GenerateAppIdFromURL(GURL(
// "https://canvas.apps.chrome/")) // "https://canvas.apps.chrome/"))
constexpr char kCanvasAppId[] = "ieailfmhaghpphfffooibmlghaeopach"; constexpr char kCanvasAppId[] = "ieailfmhaghpphfffooibmlghaeopach";
...@@ -24,8 +24,8 @@ constexpr char kCanvasAppId[] = "ieailfmhaghpphfffooibmlghaeopach"; ...@@ -24,8 +24,8 @@ constexpr char kCanvasAppId[] = "ieailfmhaghpphfffooibmlghaeopach";
constexpr char kGmailAppId[] = "fpgpbaljnbnpjbpnlnjjhfeigfpemdda"; constexpr char kGmailAppId[] = "fpgpbaljnbnpjbpnlnjjhfeigfpemdda";
// Generated as: web_app::GenerateAppIdFromURL(GURL( // Generated as: web_app::GenerateAppIdFromURL(GURL(
// "https://calendar.google.com/calendar/?usp=installed_webapp")) // "https://calendar.google.com/calendar/r"))
constexpr char kGoogleCalendarAppId[] = "anejmkjdeaeoepnomjgklommefloacja"; constexpr char kGoogleCalendarAppId[] = "kjbdgfilnfhdoflbpgamdcdgpehopbep";
// Generated as: web_app::GenerateAppIdFromURL(GURL( // Generated as: web_app::GenerateAppIdFromURL(GURL(
// "https://docs.google.com/document/?usp=installed_webapp")) // "https://docs.google.com/document/?usp=installed_webapp"))
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/test/bind.h" #include "base/test/bind.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h" #include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
...@@ -506,6 +505,11 @@ IN_PROC_BROWSER_TEST_F(ExternalWebAppManagerBrowserTest, PreinstalledWebApps) { ...@@ -506,6 +505,11 @@ IN_PROC_BROWSER_TEST_F(ExternalWebAppManagerBrowserTest, PreinstalledWebApps) {
EXPECT_THAT( EXPECT_THAT(
install_results, install_results,
UnorderedElementsAre( UnorderedElementsAre(
#if BUILDFLAG(IS_CHROMEOS_ASH)
Pair(GURL("https://calendar.google.com/calendar/"
"installwebapp?usp=chrome_default"),
InstallResultCode::kSuccessOfflineOnlyInstall),
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
Pair(GURL("https://docs.google.com/document/" Pair(GURL("https://docs.google.com/document/"
"installwebapp?usp=chrome_default"), "installwebapp?usp=chrome_default"),
InstallResultCode::kSuccessOfflineOnlyInstall), InstallResultCode::kSuccessOfflineOnlyInstall),
...@@ -529,6 +533,11 @@ IN_PROC_BROWSER_TEST_F(ExternalWebAppManagerBrowserTest, PreinstalledWebApps) { ...@@ -529,6 +533,11 @@ IN_PROC_BROWSER_TEST_F(ExternalWebAppManagerBrowserTest, PreinstalledWebApps) {
})); }));
run_loop.Run(); run_loop.Run();
#if BUILDFLAG(IS_CHROMEOS_ASH)
EXPECT_EQ(
provider.registrar().GetAppLaunchUrl(kGoogleCalendarAppId),
GURL("https://calendar.google.com/calendar/r?usp=installed_webapp"));
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
EXPECT_EQ(provider.registrar().GetAppLaunchUrl(kGoogleDocsAppId), EXPECT_EQ(provider.registrar().GetAppLaunchUrl(kGoogleDocsAppId),
GURL("https://docs.google.com/document/?usp=installed_webapp")); GURL("https://docs.google.com/document/?usp=installed_webapp"));
EXPECT_EQ(provider.registrar().GetAppLaunchUrl(kGoogleSlidesAppId), EXPECT_EQ(provider.registrar().GetAppLaunchUrl(kGoogleSlidesAppId),
......
...@@ -15,8 +15,8 @@ source_set("preinstalled_web_apps") { ...@@ -15,8 +15,8 @@ source_set("preinstalled_web_apps") {
deps = [ deps = [
"//base", "//base",
"//build:branding_buildflags", "//build:branding_buildflags",
"//chrome/browser:browser_process",
"//build:chromeos_buildflags", "//build:chromeos_buildflags",
"//chrome/browser:browser_process",
"//chrome/browser/web_applications/components", "//chrome/browser/web_applications/components",
"//skia", "//skia",
"//ui/base", "//ui/base",
...@@ -38,6 +38,13 @@ source_set("preinstalled_web_apps") { ...@@ -38,6 +38,13 @@ source_set("preinstalled_web_apps") {
"youtube.h", "youtube.h",
] ]
if (is_chromeos) {
sources += [
"google_calendar.cc",
"google_calendar.h",
]
}
deps += [ "//chrome/browser/resources:preinstalled_web_apps_resources" ] deps += [ "//chrome/browser/resources:preinstalled_web_apps_resources" ]
} }
} }
......
// 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/web_applications/preinstalled_web_apps/google_docs.h"
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/web_applications/components/external_app_install_features.h"
#include "chrome/browser/web_applications/components/web_application_info.h"
#include "chrome/browser/web_applications/preinstalled_web_apps/preinstalled_web_app_utils.h"
#include "chrome/grit/preinstalled_web_apps_resources.h"
namespace web_app {
namespace {
// clang-format off
constexpr Translation kNameTranslations[] = {
{"af", u8"Google Kalender"},
{"am", u8"Google ቀን መቁጠሪያ"},
{"ar", u8"تقويم Google"},
{"hy", u8"Google Օրացույց"},
{"az", u8"Google Calendar"},
{"eu", u8"Google Calendar"},
{"be", u8"Google Каляндар"},
{"bn", u8"Google Calendar"},
{"bg", u8"Google Календар"},
{"my", u8"Google Calendar"},
{"ca", u8"Google Calendar"},
{"zh-HK", u8"Google 日曆"},
{"zh-CN", u8"Google 日历"},
{"zh-TW", u8"Google 日曆"},
{"hr", u8"Google kalendar"},
{"cs", u8"Kalendář Google"},
{"da", u8"Google Kalender"},
{"nl", u8"Google Agenda"},
{"en-GB", u8"Google Calendar"},
{"et", u8"Google'i kalender"},
{"fil", u8"Google Calendar"},
{"fi", u8"Google Kalenteri"},
{"fr-CA", u8"Google Agenda"},
{"fr", u8"Google Agenda"},
{"gl", u8"Google Calendar"},
{"ka", u8"Google Calendar"},
{"de", u8"Google Kalender"},
{"el", u8"Ημερολόγιο Google"},
{"gu", u8"Google Calendar"},
{"iw", u8"יומן Google"},
{"hi", u8"Google Calendar"},
{"hu", u8"Google Naptár"},
{"is", u8"Google dagatal"},
{"id", u8"Google Kalender"},
{"it", u8"Google Calendar"},
{"ja", u8"Google カレンダー"},
{"kn", u8"Google Calendar"},
{"kk", u8"Google Calendar"},
{"km", u8"Google ប្រតិទិន"},
{"ko", u8"Google 캘린더"},
{"lo", u8"Google ປະຕິທິນ"},
{"lv", u8"Google kalendārs"},
{"lt", u8"„Google“ kalendorius"},
{"ms", u8"Kalendar Google"},
{"ml", u8"Google Calendar"},
{"mr", u8"Google Calendar"},
{"mn", u8"Google Календарь"},
{"ne", u8"Google पात्रो"},
{"no", u8"Google Kalender"},
{"or", u8"Google Calendar"},
{"fa", u8"تقویم Google"},
{"pl", u8"Kalendarz Google"},
{"pt-BR", u8"Google Agenda"},
{"pt-PT", u8"Calendário Google"},
{"pa", u8"Google Calendar"},
{"ro", u8"Google Calendar"},
{"ru", u8"Google Календарь"},
{"sr", u8"Google календар"},
{"si", u8"Google දින දර්ශනය"},
{"sk", u8"Kalendár Google"},
{"sl", u8"Google Koledar"},
{"es-419", u8"Calendario de Google"},
{"es", u8"Google Calendar"},
{"sw", u8"Kalenda ya Google"},
{"sv", u8"Google Kalender"},
{"ta", u8"Google Calendar"},
{"te", u8"Google Calendar"},
{"th", u8"Google ปฏิทิน"},
{"tr", u8"Google Takvim"},
{"uk", u8"Google Календар"},
{"ur", u8"Google کیلنڈر"},
{"vi", u8"Lịch Google"},
{"cy", u8"Google Calendar"},
{"zu", u8"Google Khalenda"},
};
// clang-format on
} // namespace
ExternalInstallOptions GetConfigForGoogleCalendar() {
ExternalInstallOptions options(
/*install_url=*/GURL("https://calendar.google.com/calendar/"
"installwebapp?usp=chrome_default"),
/*user_display_mode=*/DisplayMode::kBrowser,
/*install_source=*/ExternalInstallSource::kExternalDefault);
options.user_type_allowlist = {"unmanaged", "managed", "child"};
options.gate_on_feature = kMigrateDefaultChromeAppToWebAppsGSuite.name;
options.uninstall_and_replace.push_back("ejjicmeblgpmajnghnpcppodonldlgfn");
options.load_and_await_service_worker_registration = false;
options.launch_query_params = "usp=installed_webapp";
options.only_use_app_info_factory = true;
options.app_info_factory = base::BindRepeating([]() {
auto info = std::make_unique<WebApplicationInfo>();
info->title = base::UTF8ToUTF16(
GetTranslatedName("Google Calendar", kNameTranslations));
info->start_url = GURL("https://calendar.google.com/calendar/r");
info->scope = GURL("https://calendar.google.com/calendar/");
info->display_mode = DisplayMode::kStandalone;
info->icon_bitmaps_any = LoadBundledIcons(
{IDR_PREINSTALLED_WEB_APPS_GOOGLE_CALENDAR_ICON_192_PNG});
return info;
});
return options;
}
} // namespace web_app
// 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_WEB_APPLICATIONS_PREINSTALLED_WEB_APPS_GOOGLE_CALENDAR_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_PREINSTALLED_WEB_APPS_GOOGLE_CALENDAR_H_
#include "chrome/browser/web_applications/components/external_install_options.h"
namespace web_app {
ExternalInstallOptions GetConfigForGoogleCalendar();
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_PREINSTALLED_WEB_APPS_GOOGLE_CALENDAR_H_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "chrome/browser/web_applications/components/external_app_install_features.h" #include "chrome/browser/web_applications/components/external_app_install_features.h"
#include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h"
...@@ -17,6 +18,11 @@ ...@@ -17,6 +18,11 @@
#include "chrome/browser/web_applications/preinstalled_web_apps/google_sheets.h" #include "chrome/browser/web_applications/preinstalled_web_apps/google_sheets.h"
#include "chrome/browser/web_applications/preinstalled_web_apps/google_slides.h" #include "chrome/browser/web_applications/preinstalled_web_apps/google_slides.h"
#include "chrome/browser/web_applications/preinstalled_web_apps/youtube.h" #include "chrome/browser/web_applications/preinstalled_web_apps/youtube.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/web_applications/preinstalled_web_apps/google_calendar.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
namespace web_app { namespace web_app {
...@@ -47,6 +53,9 @@ std::vector<ExternalInstallOptions> GetPreinstalledAppData() { ...@@ -47,6 +53,9 @@ std::vector<ExternalInstallOptions> GetPreinstalledAppData() {
GetConfigForGoogleSheets(), GetConfigForGoogleSheets(),
GetConfigForGoogleSlides(), GetConfigForGoogleSlides(),
GetConfigForYouTube(), GetConfigForYouTube(),
#if BUILDFLAG(IS_CHROMEOS_ASH)
GetConfigForGoogleCalendar(),
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// clang-format on // clang-format on
}; };
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
......
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