From 4291168c67519b81fa5e3f4ef46557abc66bee07 Mon Sep 17 00:00:00 2001 From: Marcello Salomao Date: Wed, 15 Mar 2023 03:32:36 +0000 Subject: [PATCH] [DriveFsBulkPinning] Add new Google Drive settings page This is just a UI skeleton. More UI polish is required and will be introduced upon wiring it with the actual business logic. Note: the new Google Drive settings page is gated on the DriveFsBulkPinning feature, so it won't show by default. This feature flag cannot be enabled from chrome://flags. Note: Copy should be finalized and updated in 2-3 weeks from now. Bug: b:262647440 Test: Manual Change-Id: I1e22c62c35a4b2c3710dc98fe805a6c5cb41ae93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4305999 Reviewed-by: Kyle Horimoto Commit-Queue: Marcello Salomao Cr-Commit-Position: refs/heads/main@{#1117353} --- .../app/os_settings_search_tag_strings.grdp | 5 +- chrome/app/os_settings_strings.grdp | 30 ++++++++ .../resources/settings/chromeos/lazy_load.ts | 1 + .../os_files_page/google_drive_subpage.html | 38 ++++++++++ .../os_files_page/google_drive_subpage.ts | 75 +++++++++++++++++++ .../chromeos/os_files_page/os_files_page.html | 31 ++++++-- .../chromeos/os_files_page/os_files_page.ts | 12 +++ .../settings/chromeos/os_settings.gni | 1 + .../settings/chromeos/os_settings_icons.html | 3 + .../settings/chromeos/os_settings_routes.ts | 5 ++ .../ui/webui/settings/ash/files_section.cc | 38 ++++++++++ .../settings/chromeos/constants/routes.mojom | 2 + tools/metrics/histograms/enums.xml | 1 + 13 files changed, 234 insertions(+), 8 deletions(-) create mode 100644 chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.html create mode 100644 chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.ts diff --git a/chrome/app/os_settings_search_tag_strings.grdp b/chrome/app/os_settings_search_tag_strings.grdp index 693c51e55d1a1..0f7886e76677a 100644 --- a/chrome/app/os_settings_search_tag_strings.grdp +++ b/chrome/app/os_settings_search_tag_strings.grdp @@ -1089,7 +1089,7 @@ Files - + Disconnect Google Drive account @@ -1101,6 +1101,9 @@ Office file settings + + Google Drive settings + diff --git a/chrome/app/os_settings_strings.grdp b/chrome/app/os_settings_strings.grdp index f30a76a3af8b2..3a3fb9b2d5f9b 100644 --- a/chrome/app/os_settings_strings.grdp +++ b/chrome/app/os_settings_strings.grdp @@ -865,6 +865,36 @@ Disconnect Google Drive account + + Google Drive + + + Enabled + + + Disabled + + + Disconnect + + + Signed in as + + + Keep your files available when you're offline + + + This will store your Google Drive files on this Chromebook so you can view and edit them without an internet connection. This will use about 12.2 GB leaving 96.8 GB available. + + + Offline Storage + + + Using 0 GB + + + Clear offline storage + Network file shares diff --git a/chrome/browser/resources/settings/chromeos/lazy_load.ts b/chrome/browser/resources/settings/chromeos/lazy_load.ts index c287e2ee95641..1883a6984a92b 100644 --- a/chrome/browser/resources/settings/chromeos/lazy_load.ts +++ b/chrome/browser/resources/settings/chromeos/lazy_load.ts @@ -66,6 +66,7 @@ import './os_a11y_page/switch_access_setup_guide_dialog.js'; import './os_a11y_page/switch_access_setup_guide_warning_dialog.js'; import './os_a11y_page/switch_access_subpage.js'; import './os_a11y_page/tts_subpage.js'; +import './os_files_page/google_drive_subpage.js'; import './os_files_page/office_page.js'; import './os_languages_page/input_method_options_page.js'; import './os_languages_page/input_page.js'; diff --git a/chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.html b/chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.html new file mode 100644 index 0000000000000..2bd46ca59e9a9 --- /dev/null +++ b/chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.html @@ -0,0 +1,38 @@ + + +
+
+ + $i18n{googleDriveSignedInAs} +
+ + $i18n{googleDriveDisconnectLabel} + +
+ +
+ + + + +
+
+ $i18n{googleDriveOfflineClearTitle} +
+ + $i18n{googleDriveOfflineClearSubtitle} +
+
+ + $i18n{googleDriveOfflineClearAction} + +
+ +
diff --git a/chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.ts b/chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.ts new file mode 100644 index 0000000000000..73bb16d5d1737 --- /dev/null +++ b/chrome/browser/resources/settings/chromeos/os_files_page/google_drive_subpage.ts @@ -0,0 +1,75 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'chrome://resources/cr_elements/cr_button/cr_button.js'; +import 'chrome://resources/cr_elements/policy/cr_policy_pref_indicator.js'; +import 'chrome://resources/js/action_link.js'; +import 'chrome://resources/cr_elements/action_link.css.js'; +import 'chrome://resources/cr_components/localized_link/localized_link.js'; +import '../../settings_shared.css.js'; +import '../../settings_vars.css.js'; + +import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +import {DeepLinkingMixin} from '../deep_linking_mixin.js'; +import {Setting} from '../mojom-webui/setting.mojom-webui.js'; +import {routes} from '../os_settings_routes.js'; +import {RouteObserverMixin} from '../route_observer_mixin.js'; +import {Route} from '../router.js'; + +import {getTemplate} from './google_drive_subpage.html.js'; + +const SettingsGoogleDriveSubpageElementBase = + DeepLinkingMixin(RouteObserverMixin(PolymerElement)); + +class SettingsGoogleDriveSubpageElement extends + SettingsGoogleDriveSubpageElementBase { + static get is() { + return 'settings-google-drive-subpage'; + } + + static get template() { + return getTemplate(); + } + + static get properties() { + return { + /** + * Preferences state. + */ + prefs: { + type: Object, + notify: true, + }, + + /** + * Used by DeepLinkingMixin to focus this page's deep links. + */ + supportedSettingIds: { + type: Object, + value: () => new Set([Setting.kGoogleDriveConnection]), + }, + }; + } + + prefs: object; + + override currentRouteChanged(route: Route, _oldRoute?: Route) { + // Does not apply to this page. + if (route !== routes.GOOGLE_DRIVE) { + return; + } + + this.attemptDeepLink(); + } +} + +declare global { + interface HTMLElementTagNameMap { + 'settings-google-drive-subpage': SettingsGoogleDriveSubpageElement; + } +} + +customElements.define( + SettingsGoogleDriveSubpageElement.is, SettingsGoogleDriveSubpageElement); diff --git a/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.html b/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.html index 1997042cb25b2..e96eb7f8a97bb 100644 --- a/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.html +++ b/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.html @@ -2,12 +2,23 @@
- - + + @@ -26,6 +37,12 @@ + - \ No newline at end of file + diff --git a/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.ts b/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.ts index bc7bb831c974d..1925f5facd170 100644 --- a/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.ts +++ b/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.ts @@ -73,6 +73,14 @@ class OsSettingsFilesPageElement extends OsSettingsFilesPageElementBase { return loadTimeData.getBoolean('showOfficeSettings'); }, }, + + /** @private */ + isBulkPinningEnabled_: { + type: Boolean, + value() { + return loadTimeData.getBoolean('enableDriveFsBulkPinning'); + }, + }, }; } @@ -92,6 +100,10 @@ class OsSettingsFilesPageElement extends OsSettingsFilesPageElementBase { Router.getInstance().navigateTo(routes.SMB_SHARES); } + private onGoogleDrive_() { + Router.getInstance().navigateTo(routes.GOOGLE_DRIVE); + } + private onTapOffice_() { Router.getInstance().navigateTo(routes.OFFICE); } diff --git a/chrome/browser/resources/settings/chromeos/os_settings.gni b/chrome/browser/resources/settings/chromeos/os_settings.gni index 20dd6f05f30be..a0a0a077c2192 100644 --- a/chrome/browser/resources/settings/chromeos/os_settings.gni +++ b/chrome/browser/resources/settings/chromeos/os_settings.gni @@ -173,6 +173,7 @@ web_component_files = [ "chromeos/os_files_page/office_page.ts", "chromeos/os_files_page/os_files_page.ts", "chromeos/os_files_page/smb_shares_page.ts", + "chromeos/os_files_page/google_drive_subpage.ts", "chromeos/os_languages_page/add_input_methods_dialog.ts", "chromeos/os_languages_page/add_items_dialog.ts", "chromeos/os_languages_page/add_spellcheck_languages_dialog.ts", diff --git a/chrome/browser/resources/settings/chromeos/os_settings_icons.html b/chrome/browser/resources/settings/chromeos/os_settings_icons.html index 3cab43a5e6d65..ccfc8eb34890d 100644 --- a/chrome/browser/resources/settings/chromeos/os_settings_icons.html +++ b/chrome/browser/resources/settings/chromeos/os_settings_icons.html @@ -61,6 +61,9 @@ + + + diff --git a/chrome/browser/resources/settings/chromeos/os_settings_routes.ts b/chrome/browser/resources/settings/chromeos/os_settings_routes.ts index c908eb41fc563..8dc4a4e5fd24e 100644 --- a/chrome/browser/resources/settings/chromeos/os_settings_routes.ts +++ b/chrome/browser/resources/settings/chromeos/os_settings_routes.ts @@ -150,6 +150,7 @@ export interface OsSettingsRoutes extends MinimumRoutes { FINGERPRINT: Route; FILES: Route; GOOGLE_ASSISTANT: Route; + GOOGLE_DRIVE: Route; HOTSPOT_DETAIL: Route; INTERNET: Route; INTERNET_NETWORKS: Route; @@ -541,6 +542,10 @@ function createOsSettingsRoutes(): OsSettingsRoutes { r.SMB_SHARES = createSubpage( r.FILES, routesMojom.NETWORK_FILE_SHARES_SUBPAGE_PATH, Subpage.kNetworkFileShares); + if (loadTimeData.getBoolean('enableDriveFsBulkPinning')) { + r.GOOGLE_DRIVE = createSubpage( + r.FILES, routesMojom.GOOGLE_DRIVE_SUBPAGE_PATH, Subpage.kGoogleDrive); + } r.OFFICE = createSubpage( r.FILES, routesMojom.OFFICE_FILES_SUBPAGE_PATH, Subpage.kOfficeFiles); } diff --git a/chrome/browser/ui/webui/settings/ash/files_section.cc b/chrome/browser/ui/webui/settings/ash/files_section.cc index de183d4070432..264cc56f56672 100644 --- a/chrome/browser/ui/webui/settings/ash/files_section.cc +++ b/chrome/browser/ui/webui/settings/ash/files_section.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/settings/ash/files_section.h" +#include "ash/constants/ash_features.h" #include "base/functional/callback_helpers.h" #include "base/no_destructor.h" #include "chrome/browser/ash/profiles/profile_helper.h" @@ -23,6 +24,7 @@ namespace ash::settings { namespace mojom { using ::chromeos::settings::mojom::kFilesSectionPath; +using ::chromeos::settings::mojom::kGoogleDriveSubpagePath; using ::chromeos::settings::mojom::kNetworkFileSharesSubpagePath; using ::chromeos::settings::mojom::kOfficeFilesSubpagePath; using ::chromeos::settings::mojom::Section; @@ -69,6 +71,17 @@ const std::vector& GetFilesOfficeSearchConcepts() { return *tags; } +const std::vector& GetFilesGoogleDriveSearchConcepts() { + static const base::NoDestructor> tags( + {{IDS_OS_SETTINGS_TAG_FILES_GOOGLE_DRIVE, + mojom::kGoogleDriveSubpagePath, + mojom::SearchResultIcon::kFolder, + mojom::SearchResultDefaultRank::kMedium, + mojom::SearchResultType::kSubpage, + {.subpage = mojom::Subpage::kGoogleDrive}}}); + return *tags; +} + } // namespace FilesSection::FilesSection(Profile* profile, @@ -79,6 +92,9 @@ FilesSection::FilesSection(Profile* profile, if (cloud_upload::IsEligibleAndEnabledUploadOfficeToCloud()) { updater.AddSearchTags(GetFilesOfficeSearchConcepts()); } + if (ash::features::IsDriveFsBulkPinningEnabled()) { + updater.AddSearchTags(GetFilesGoogleDriveSearchConcepts()); + } } FilesSection::~FilesSection() = default; @@ -86,6 +102,20 @@ FilesSection::~FilesSection() = default; void FilesSection::AddLoadTimeData(content::WebUIDataSource* html_source) { static constexpr webui::LocalizedString kLocalizedStrings[] = { {"disconnectGoogleDriveAccount", IDS_SETTINGS_DISCONNECT_GOOGLE_DRIVE}, + {"googleDriveLabel", IDS_SETTINGS_GOOGLE_DRIVE}, + {"googleDriveEnabledLabel", IDS_SETTINGS_GOOGLE_DRIVE_ENABLED}, + {"googleDriveDisabledLabel", IDS_SETTINGS_GOOGLE_DRIVE_DISABLED}, + {"googleDriveDisconnectLabel", IDS_SETTINGS_GOOGLE_DRIVE_DISCONNECT}, + {"googleDriveSignedInAs", IDS_SETTINGS_GOOGLE_DRIVE_SIGNED_IN_AS}, + {"googleDriveOfflineTitle", IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_TITLE}, + {"googleDriveOfflineSubtitle", + IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_SUBTITLE}, + {"googleDriveOfflineClearTitle", + IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_CLEAR_TITLE}, + {"googleDriveOfflineClearSubtitle", + IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_CLEAR_SUBTITLE}, + {"googleDriveOfflineClearAction", + IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_CLEAR_ACTION}, {"filesPageTitle", IDS_OS_SETTINGS_FILES}, {"smbSharesTitle", IDS_SETTINGS_DOWNLOADS_SMB_SHARES}, {"smbSharesLearnMoreLabel", @@ -125,6 +155,9 @@ void FilesSection::AddLoadTimeData(content::WebUIDataSource* html_source) { ProfileHelper::Get()->GetUserByProfile(profile()); html_source->AddBoolean("isActiveDirectoryUser", user && user->IsActiveDirectoryUser()); + + html_source->AddBoolean("enableDriveFsBulkPinning", + features::IsDriveFsBulkPinningEnabled()); } void FilesSection::AddHandlers(content::WebUI* web_ui) { @@ -168,6 +201,11 @@ void FilesSection::RegisterHierarchy(HierarchyGenerator* generator) const { IDS_SETTINGS_DOWNLOADS_SMB_SHARES, mojom::Subpage::kOfficeFiles, mojom::SearchResultIcon::kFolder, mojom::SearchResultDefaultRank::kMedium, mojom::kNetworkFileSharesSubpagePath); + + generator->RegisterTopLevelSubpage( + IDS_SETTINGS_GOOGLE_DRIVE, mojom::Subpage::kGoogleDrive, + mojom::SearchResultIcon::kFolder, mojom::SearchResultDefaultRank::kMedium, + mojom::kGoogleDriveSubpagePath); } } // namespace ash::settings diff --git a/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom b/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom index 466efe6c90c26..7074ecc871f1e 100644 --- a/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom +++ b/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom @@ -147,6 +147,7 @@ enum Subpage { // Files section. kNetworkFileShares = 1300, kOfficeFiles = 1301, + kGoogleDrive = 1302, // Printing section. kPrintingDetails = 1400, @@ -283,6 +284,7 @@ const string kJapaneseManageUserDictionarySubpagePath = // Files section. const string kFilesSectionPath = "files"; +const string kGoogleDriveSubpagePath = "googleDrive"; const string kNetworkFileSharesSubpagePath = "smbShares"; const string kOfficeFilesSubpagePath = "officeFiles"; diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index d14084b477241..87b28ffeeaf24 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -77511,6 +77511,7 @@ Called by update_net_trust_anchors.py.--> +