Skip to content

Commit

Permalink
[DriveFsBulkPinning] Add new Google Drive settings page
Browse files Browse the repository at this point in the history
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 <khorimoto@chromium.org>
Commit-Queue: Marcello Salomao <msalomao@google.com>
Cr-Commit-Position: refs/heads/main@{#1117353}
  • Loading branch information
Marcello Salomao authored and Chromium LUCI CQ committed Mar 15, 2023
1 parent 15ace56 commit 4291168
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 8 deletions.
5 changes: 4 additions & 1 deletion chrome/app/os_settings_search_tag_strings.grdp
Expand Up @@ -1089,7 +1089,7 @@
<message name="IDS_OS_SETTINGS_TAG_FILES" desc="Text for search result item which, when clicked, navigates the user to files settings.">
Files
</message>
<message name="IDS_OS_SETTINGS_TAG_FILES_DISCONNECT_GOOGLE_DRIVE" desc="Text for search result item which, when clicked, navigates the user to files settings, with a toggle to enable/disable connecting the user's Google Drive account.">
<message name="IDS_OS_SETTINGS_TAG_FILES_DISCONNECT_GOOGLE_DRIVE" desc="Text for search result item that, when clicked, navigates the user to Settings: Google Drive settings, with a toggle to enable/disable connecting the user's Google Drive account.">
Disconnect Google Drive account
</message>
<message name="IDS_OS_SETTINGS_TAG_FILES_NETWORK_FILE_SHARES" desc="Text for search result item which, when clicked, navigates the user to network file share (a.k.a. SMB share) settings. Alternate phrase for: 'SMB share'">
Expand All @@ -1101,6 +1101,9 @@
<message name="IDS_OS_SETTINGS_TAG_FILES_OFFICE" translateable="false" desc="Text for search result item which, when clicked, navigates the user to the Office file handler settings.">
Office file settings
</message>
<message name="IDS_OS_SETTINGS_TAG_FILES_GOOGLE_DRIVE" translateable="false" desc="Text for search result item which, when clicked, navigates the user to the Google Drive settings.">
Google Drive settings
</message>

<!-- Printing section. -->
<message name="IDS_OS_SETTINGS_TAG_PRINTING" desc="Text for search result item which, when clicked, navigates the user to printer settings for CUPS printers (a.k.a. those that can use the Unix protocol). Alternate phrase for: 'Printers', 'CUPS'">
Expand Down
30 changes: 30 additions & 0 deletions chrome/app/os_settings_strings.grdp
Expand Up @@ -865,6 +865,36 @@
<message name="IDS_SETTINGS_DISCONNECT_GOOGLE_DRIVE" desc="Label for the checkbox which enables disconnecting from Google Drive account.">
Disconnect Google Drive account
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE" translateable="false" desc="Label for the settings link that takes the user to the page where they can manage their Google Drive settings.">
Google Drive
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_ENABLED" translateable="false" desc="Label indicating that Google Drive is enabled in Settings: Files: Google Drive.">
Enabled
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_DISABLED" translateable="false" desc="Label indicating that Google Drive is disabled in Settings: Files: Google Drive.">
Disabled
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_DISCONNECT" translateable="false" desc="Action to disconnect from Google Drive in Settings: Files: Google Drive.">
Disconnect
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_SIGNED_IN_AS" translateable="false" desc="Label indicating account signed in with Google Drive in Settings: Files: Google Drive.">
Signed in as
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_TITLE" translateable="false" desc="Title for the everything offline feature in Settings: Files: Google Drive.">
Keep your files available when you're offline
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_SUBTITLE" translateable="false" desc="Subtitle for the everything offline feature in Settings: Files: Google Drive.">
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.
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_CLEAR_TITLE" translateable="false" desc="Title for the Offline Storage row where users can clear their offline storage in Settings: Files: Google Drive.">
Offline Storage
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_CLEAR_SUBTITLE" translateable="false" desc="Subtitle for the Offline Storage row where users can clear their offline storage in Settings: Files: Google Drive.">
Using 0 GB
</message>
<message name="IDS_SETTINGS_GOOGLE_DRIVE_OFFLINE_CLEAR_ACTION" translateable="false" desc="Button for the Offline Storage row where users can clear their offline storage in Settings: Files: Google Drive.">
Clear offline storage
</message>
<message name="IDS_SETTINGS_DOWNLOADS_SMB_SHARES" desc="In Downloads Settings, the title of the SMB shares setting section.">
Network file shares
</message>
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/chromeos/lazy_load.ts
Expand Up @@ -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';
Expand Down
@@ -0,0 +1,38 @@
<style include="settings-shared"></style>

<div
class="settings-box two-line first"
deep-link-focus-id$="[[Setting.kGoogleDriveConnection]]">
<div class="start">
<!-- TODO(b/273399125): email associated with current drive account -->
$i18n{googleDriveSignedInAs}
</div>
<cr-button role="button">
$i18n{googleDriveDisconnectLabel}
</cr-button>
</div>

<div class="hr"></div>

<settings-toggle-button
id="disconnectGoogleDriveAccount"
pref="{{prefs.gdata.disabled}}"
label="$i18n{googleDriveOfflineTitle}"
sub-label="$i18n{googleDriveOfflineSubtitle}"
deep-link-focus-id$="[[Setting.kGoogleDriveConnection]]">
</settings-toggle-button>

<div class="settings-box two-line">
<div class="start">
$i18n{googleDriveOfflineClearTitle}
<div class="secondary">
<!-- TODO(b/273399125): storage being used by offline files -->
$i18n{googleDriveOfflineClearSubtitle}
</div>
</div>
<cr-button role="button">
$i18n{googleDriveOfflineClearAction}
</cr-button>
</div>

<div class="hr"></div>
@@ -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>([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);
Expand Up @@ -2,12 +2,23 @@
<os-settings-animated-pages id="pages" section="files"
focus-config="[[focusConfig_]]">
<div route-path="default">
<settings-toggle-button
id="disconnectGoogleDriveAccount"
pref="{{prefs.gdata.disabled}}"
label="$i18n{disconnectGoogleDriveAccount}"
deep-link-focus-id$="[[Setting.kGoogleDriveConnection]]">
</settings-toggle-button>
<template is="dom-if" if="[[!isBulkPinningEnabled_]]">
<settings-toggle-button
id="disconnectGoogleDriveAccount"
pref="{{prefs.gdata.disabled}}"
label="$i18n{disconnectGoogleDriveAccount}"
deep-link-focus-id$="[[Setting.kGoogleDriveConnection]]">
</settings-toggle-button>
</template>
<template is="dom-if" if="[[isBulkPinningEnabled_]]">
<cr-link-row
id="GoogleDriveLink"
class="hr" on-click="onGoogleDrive_"
label="$i18n{googleDriveLabel}"
sub-label="$i18n{googleDriveEnabledLabel}"
role-description="$i18n{subpageArrowRoleDescription}">
</cr-link-row>
</template>
<cr-link-row id="smbShares" class="hr" on-click="onTapSmbShares_"
label="$i18n{smbSharesTitle}"
role-description="$i18n{subpageArrowRoleDescription}">
Expand All @@ -26,6 +37,12 @@
</settings-smb-shares-page>
</os-settings-subpage>
</template>
<template is="dom-if" route-path="/googleDrive">
<os-settings-subpage page-title="$i18n{googleDriveLabel}">
<settings-google-drive-subpage prefs="[[prefs]]">
</settings-google-drive-subpage>
</os-settings-subpage>
</template>
<template is="dom-if" if="[[showOfficeSettings_]]">
<template is="dom-if" route-path="/officeFiles">
<os-settings-subpage page-title="Office Files">
Expand All @@ -34,4 +51,4 @@
</os-settings-subpage>
</template>
</template>
</os-settings-animated-pages>
</os-settings-animated-pages>
Expand Up @@ -73,6 +73,14 @@ class OsSettingsFilesPageElement extends OsSettingsFilesPageElementBase {
return loadTimeData.getBoolean('showOfficeSettings');
},
},

/** @private */
isBulkPinningEnabled_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('enableDriveFsBulkPinning');
},
},
};
}

Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/chromeos/os_settings.gni
Expand Up @@ -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",
Expand Down
Expand Up @@ -61,6 +61,9 @@
<!-- Files section -->
<g id="folder-outline"><path d="M16 5h-4l-2-2H4c-1.1 0-1.99.9-1.99 2L2 15c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 10H4V7h12v8z"></path></g>

<!-- Offline -->
<g id="offline"><path d="M11.91 6.244a.833.833 0 111.18 1.179l-3.334 3.333a.833.833 0 01-1.179 0L6.911 9.089a.833.833 0 011.178-1.178l1.078 1.077 2.744-2.744zM6.75 12a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-6.5z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-2 0a6 6 0 11-12 0 6 6 0 0112 0z"></path></g>

<!-- MultiDevice Settings UI -->
<g id="multidevice-better-together-suite" viewBox="0 0 24 24"><path d="M17,1.01 L7,1 C5.9,1 5,1.9 5,3 L5,21 C5,22.1 5.9,23 7,23 L17,23 C18.1,23 19,22.1 19,21 L19,3 C19,1.9 18.1,1.01 17,1.01 Z M17,21 L7,21 L7,20 L17,20 L17,21 Z M17,18 L7,18 L7,6 L17,6 L17,18 Z M7,4 L7,3 L17,3 L17,4 L7,4 Z"></path></g>
<g id="multidevice-wifi-sync" viewBox="0 0 24 24" transform="translate(1.000000, 3.000000)" fill-rule="nonzero">
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
38 changes: 38 additions & 0 deletions chrome/browser/ui/webui/settings/ash/files_section.cc
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -69,6 +71,17 @@ const std::vector<SearchConcept>& GetFilesOfficeSearchConcepts() {
return *tags;
}

const std::vector<SearchConcept>& GetFilesGoogleDriveSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> 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,
Expand All @@ -79,13 +92,30 @@ FilesSection::FilesSection(Profile* profile,
if (cloud_upload::IsEligibleAndEnabledUploadOfficeToCloud()) {
updater.AddSearchTags(GetFilesOfficeSearchConcepts());
}
if (ash::features::IsDriveFsBulkPinningEnabled()) {
updater.AddSearchTags(GetFilesGoogleDriveSearchConcepts());
}
}

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",
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Up @@ -147,6 +147,7 @@ enum Subpage {
// Files section.
kNetworkFileShares = 1300,
kOfficeFiles = 1301,
kGoogleDrive = 1302,

// Printing section.
kPrintingDetails = 1400,
Expand Down Expand Up @@ -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";

Expand Down

0 comments on commit 4291168

Please sign in to comment.