Skip to content

Commit

Permalink
Add ARC++ resize lock setting to Chrome OS settings
Browse files Browse the repository at this point in the history
ARC++ apps in resize lock mode have restrictions on various
features such as window resizing (resize lock), and users can
disable these restrictions via Chrome OS settings.

This CL adds a toggle to the Chrome OS settings. This value is
in sync via app service with the value stored in ArcAppListPref,
which is the source of truth.

This setting is hidden for apps that are not subject to resize
lock mode.

BUG=b:181614099
BUG=b:180252634
BUG=b:180252639
TEST=The setting appears and togglable for resize-locked apps

Change-Id: I126c838144a1eb5089abf9256fcb4966b2611d4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2734380
Commit-Queue: Kazuki Takise <takise@chromium.org>
Auto-Submit: Kazuki Takise <takise@chromium.org>
Reviewed-by: Jeevan Shikaram <jshikaram@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894057}
  • Loading branch information
takisejr authored and Chromium LUCI CQ committed Jun 19, 2021
1 parent 14d005b commit cac2822
Show file tree
Hide file tree
Showing 22 changed files with 297 additions and 6 deletions.
6 changes: 6 additions & 0 deletions chrome/app/app_management_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<message name="IDS_APP_MANAGEMENT_PIN_TO_SHELF" desc="Label for the pin to shelf button in the app settings page.">
Pin to shelf
</message>
<message name="IDS_APP_MANAGEMENT_PRESET_WINDOW_SIZES" desc="Label for the preset window sizes toggle in the app settings page.">
Preset window sizes
</message>
<message name="IDS_APP_MANAGEMENT_PRESET_WINDOW_SIZES_TEXT" desc="Label for the description of the window preset toggle in the app settings page.">
Use presets for phone, tablet, or resizable windows to prevent app from misbehaving
</message>
<message name="IDS_APP_MANAGEMENT_PRINTING" desc="Label for the printing permission toggle.">
Printers
</message>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
32432d4b79aa8ed7d48e20e0a796fb722b89a737
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
32432d4b79aa8ed7d48e20e0a796fb722b89a737
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ preprocess_if_expr("preprocess_gen_v3") {
"chromeos/os_apps_page/app_management_page/plugin_vm_page/plugin_vm_detail_view.m.js",
"chromeos/os_apps_page/app_management_page/pwa_detail_view.m.js",
"chromeos/os_apps_page/app_management_page/reducers.m.js",
"chromeos/os_apps_page/app_management_page/resize_lock_item.m.js",
"chromeos/os_apps_page/app_management_page/shared_style.m.js",
"chromeos/os_apps_page/app_management_page/shared_vars.m.js",
"chromeos/os_apps_page/app_management_page/store.m.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ js_type_check("closure_compile_module") {
":pin_to_shelf_item.m",
":pwa_detail_view.m",
":reducers.m",
":resize_lock_item.m",
":shared_style.m",
":shared_vars.m",
":store.m",
Expand Down Expand Up @@ -226,6 +227,19 @@ js_library("reducers.m") {
extra_deps = [ ":modulize" ]
}

js_library("resize_lock_item.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_apps_page/app_management_page/resize_lock_item.m.js" ]
deps = [
":browser_proxy.m",
":constants.m",
":toggle_row.m",
":types.m",
":util.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":resize_lock_item_module" ]
}

js_library("store.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_apps_page/app_management_page/store.m.js" ]
deps = [
Expand Down Expand Up @@ -313,6 +327,7 @@ group("polymer3_elements") {
":permission_item_module",
":pin_to_shelf_item_module",
":pwa_detail_view_module",
":resize_lock_item_module",
":shared_style_module",
":shared_vars_module",
":toggle_row_module",
Expand Down Expand Up @@ -416,6 +431,15 @@ polymer_modulizer("pwa_detail_view") {
auto_imports = os_settings_auto_imports
}

polymer_modulizer("resize_lock_item") {
js_file = "resize_lock_item.js"
html_file = "resize_lock_item.html"
html_type = "dom-module"
migrated_imports = os_settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}

polymer_modulizer("shared_style") {
js_file = "shared_style.m.js"
html_file = "shared_style.html"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="import" href="shared_style.html">
<link rel="import" href="store_client.html">
<link rel="import" href="pin_to_shelf_item.html">
<link rel="import" href="resize_lock_item.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">

Expand Down Expand Up @@ -69,6 +70,11 @@
</template>
</div>
</div>
<app-management-resize-lock-item
id="resize-lock-setting"
class="permission-card-row separated-row row-with-description"
app="[[app_]]">
</app-management-resize-lock-item>
<div id="more-settings"
class="permission-card-row separated-row header-text clickable"
on-click="onClickNativeSettingsButton_">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@
StorageTurnedOff: 16,
PrintingTurnedOn: 17,
PrintingTurnedOff: 18,
ResizeLockTurnedOn: 19,
ResizeLockTurnedOff: 20,
};
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ cr.define('app_management', function() {
hidePinToShelf: false,
isPreferredApp: false,
windowMode: apps.mojom.WindowMode.kWindow,
resizeLocked: false,
hideResizeLocked: true,
};

if (optConfig) {
Expand Down Expand Up @@ -196,6 +198,33 @@ cr.define('app_management', function() {
this.page.onAppChanged(newApp);
}

/**
* @param {string} appId
* @param {boolean} locked
*/
setResizeLocked(appId, locked) {
const app =
app_management.AppManagementStore.getInstance().data.apps[appId];

const newApp =
/** @type {!App} */ (Object.assign({}, app, {resizeLocked: locked}));
this.page.onAppChanged(newApp);
}

/**
* @param {string} appId
* @param {boolean} hide
*/
setHideResizeLocked(appId, hide) {
const app =
app_management.AppManagementStore.getInstance().data.apps[appId];

const newApp =
/** @type {!App} */ (
Object.assign({}, app, {hideResizeLocked: hide}));
this.page.onAppChanged(newApp);
}

/**
* @param {string} appId
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="toggle_row.html">
<link rel="import" href="util.html">
<link rel="import" href="browser_proxy.html">
<link rel="import" href="constants.html">
<link rel="import" href="../../metrics_recorder.html">

<dom-module id="app-management-resize-lock-item">
<template>
<style>
:host {
cursor: pointer;
}
</style>
<app-management-toggle-row
id="toggle-row"
label="$i18n{appManagementPresetWindowSizesLabel}"
value="[[getValue_(app)]]"
description="$i18n{appManagementPresetWindowSizesText}">
</app-management-toggle-row>
</template>
<script src="resize_lock_item.js"></script>
</dom-module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2021 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.
Polymer({
is: 'app-management-resize-lock-item',

properties: {
/**
* @type {App}
*/
app: Object,

/**
* @type {boolean}
*/
hidden: {
type: Boolean,
computed: 'isHidden_(app)',
reflectToAttribute: true,
},
},

listeners: {
click: 'onClick_',
change: 'toggleSetting_',
},

/**
* @param {App} app
* @returns {boolean} true if the app is resize locked.
* @private
*/
getValue_(app) {
if (app === undefined) {
return false;
}
assert(app);
return app.resizeLocked;
},

/**
* @param {App} app
* @returns {boolean} true if resize lock setting is hidden.
*/
isHidden_(app) {
if (app === undefined) {
return true;
}
assert(app);
return app.hideResizeLocked;
},

toggleSetting_() {
const newState = !this.app.resizeLocked;
assert(newState === this.$['toggle-row'].isChecked());
app_management.BrowserProxy.getInstance().handler.setResizeLocked(
this.app.id,
newState,
);
settings.recordSettingChange();
const userAction = newState ? AppManagementUserAction.ResizeLockTurnedOn :
AppManagementUserAction.ResizeLockTurnedOff;
app_management.util.recordAppManagementUserAction(
this.app.type, userAction);
},

/**
* @private
*/
onClick_() {
this.$['toggle-row'].click();
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
flex: 0 0 var(--permission-list-item-height);
}

.row-with-description {
flex: 0 0 var(--permission-list-item-with-description-height);
}

.native-settings-icon {
display: flex;
margin-inline-start: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
--permission-icon-color: var(--cros-app-management-permission-icon-color);
--permission-icon-padding: 20px;
--permission-list-item-height: 48px;
--permission-list-item-with-description-height: 64px;
--primary-text-color: var(--cros-text-color-primary);
--row-item-icon-padding: 12px;
--secondary-font-weight: 400;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@
}
</style>

<div id="left-content" class="horizontal-align" aria-hidden="true">
<template is="dom-if" if="[[icon]]">
<iron-icon id="icon" icon="[[icon]]"></iron-icon>
</template>
<div id="label">[[label]]</div>
<div id="left-content" aria-hidden="true">
<div class="horizontal-align">
<template is="dom-if" if="[[icon]]">
<iron-icon id="icon" icon="[[icon]]"></iron-icon>
</template>
<div class="vertical-align">
<div id="label" class="header-text">[[label]]</div>
<template is="dom-if" if="[[description]]">
<div id="description" class="secondary-text">
[[description]]
</div>
</template>
</div>
</div>
</div>
<div id="right-content" class="horizontal-align">
<template is="dom-if" if="[[managed]]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Polymer({
* @type {boolean}
*/
value: {type: Boolean, value: false, reflectToAttribute: true},
/**
* @type {string}
*/
description: String,
},

listeners: {
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/webui/app_management/app_management.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct App {
bool hide_pin_to_shelf;
bool is_preferred_app;
apps.mojom.WindowMode window_mode;
bool resize_locked;
bool hide_resize_locked;
};

// Extension-based apps primarily use install-time permissions that cannot be
Expand All @@ -49,6 +51,7 @@ interface PageHandler {
SetPinned(string app_id, apps.mojom.OptionalBool pinned);
SetPermission(string app_id,
apps.mojom.Permission permission);
SetResizeLocked(string app_id, bool locked);
Uninstall(string app_id);
OpenNativeSettings(string app_id);
SetPreferredApp(string app_id, bool is_preferred_app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "components/arc/session/connection_holder.h"
#endif

using apps::mojom::OptionalBool;
Expand Down Expand Up @@ -176,6 +177,16 @@ void AppManagementPageHandler::SetPermission(
app_id, std::move(permission));
}

void AppManagementPageHandler::SetResizeLocked(const std::string& app_id,
bool locked) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
apps::AppServiceProxyFactory::GetForProfile(profile_)->SetResizeLocked(
app_id, locked ? OptionalBool::kTrue : OptionalBool::kFalse);
#else
NOTREACHED();
#endif
}

void AppManagementPageHandler::Uninstall(const std::string& app_id) {
apps::AppServiceProxyFactory::GetForProfile(profile_)->Uninstall(
app_id, apps::mojom::UninstallSource::kAppManagement,
Expand Down Expand Up @@ -256,6 +267,9 @@ app_management::mojom::AppPtr AppManagementPageHandler::CreateUIAppPtr(
app->is_policy_pinned = shelf_delegate_.IsPolicyPinned(update.AppId())
? OptionalBool::kTrue
: OptionalBool::kFalse;
app->resize_locked = update.ResizeLocked() == OptionalBool::kTrue;
app->hide_resize_locked =
update.ResizeLocked() == apps::mojom::OptionalBool::kUnknown;
#endif
app->is_preferred_app =
preferred_apps_list_.IsPreferredAppForSupportedLinks(update.AppId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AppManagementPageHandler : public app_management::mojom::PageHandler,
apps::mojom::OptionalBool pinned) override;
void SetPermission(const std::string& app_id,
apps::mojom::PermissionPtr permission) override;
void SetResizeLocked(const std::string& app_id, bool locked) override;
void Uninstall(const std::string& app_id) override;
void OpenNativeSettings(const std::string& app_id) override;
void SetPreferredApp(const std::string& app_id,
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/webui/settings/chromeos/apps_section.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ void AddAppManagementStrings(content::WebUIDataSource* html_source) {
{"appManagementNotificationsLabel", IDS_APP_MANAGEMENT_NOTIFICATIONS},
{"appManagementPermissionsLabel", IDS_APP_MANAGEMENT_PERMISSIONS},
{"appManagementPinToShelfLabel", IDS_APP_MANAGEMENT_PIN_TO_SHELF},
{"appManagementPresetWindowSizesLabel",
IDS_APP_MANAGEMENT_PRESET_WINDOW_SIZES},
{"appManagementPresetWindowSizesText",
IDS_APP_MANAGEMENT_PRESET_WINDOW_SIZES_TEXT},
{"appManagementPrintingPermissionLabel", IDS_APP_MANAGEMENT_PRINTING},
{"appManagementSearchPrompt", IDS_APP_MANAGEMENT_SEARCH_PROMPT},
{"appManagementStoragePermissionLabel", IDS_APP_MANAGEMENT_STORAGE},
Expand Down
1 change: 1 addition & 0 deletions chrome/test/data/webui/settings/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ js_modulizer("modulize") {
"app_management/plugin_vm_detail_view_test.js",
"app_management/managed_apps_test.js",
"app_management/reducers_test.js",
"app_management/resize_lock_item_test.js",
"app_management/test_plugin_vm_browser_proxy.js",
"app_management/toggle_row_test.js",
"app_management/test_store.js",
Expand Down
Loading

0 comments on commit cac2822

Please sign in to comment.