Commit e54c88e7 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

[NativeFS] Change permission prompts to "until you close all ... tabs".

Also enabled the new permission model by default, as that is what we want
to ship in M82.

Bug: 984769
Change-Id: Iaa73376cdf893a2bb7c7f3e42336f8a2675c3609
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090600Reviewed-by: default avatarOlivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747531}
parent e438ece0
......@@ -10011,6 +10011,17 @@ Please help our engineers fix this problem. Tell us what happened right before y
Save changes
</message>
<!-- New Native File System permission dialog -->
<message name="IDS_NATIVE_FILE_SYSTEM_ORIGIN_SCOPED_WRITE_PERMISSION_FILE_TEXT" desc="Text of the dialog for confirming origin scoped write access to files using the Native File System API">
<ph name="ORIGIN">$1<ex>example.com</ex></ph> will be able to edit <ph name="FILENAME">$2<ex>README.md</ex></ph> until you close all <ph name="ORIGIN">$1</ph> tabs
</message>
<message name="IDS_NATIVE_FILE_SYSTEM_ORIGIN_SCOPED_WRITE_PERMISSION_DIRECTORY_TEXT" desc="Text of the dialog for confirming origin scoped write access to a directory using the Native File System API">
<ph name="ORIGIN">$1<ex>example.com</ex></ph> will be able to edit files in <ph name="FOLDERNAME">$2<ex>My Project</ex></ph> until you close all <ph name="ORIGIN">$1</ph> tabs
</message>
<message name="IDS_NATIVE_FILE_SYSTEM_ORIGIN_SCOPED_READ_PERMISSION_DIRECTORY_TEXT" desc="Text of dialog asking user if they intended to share a particular directory">
<ph name="ORIGIN">$1<ex>example.com</ex></ph> will be able to view files in <ph name="FOLDERNAME">$2<ex>My Project</ex></ph> until you close all <ph name="ORIGIN">$1</ph> tabs
</message>
<!-- Native File System usage indicator -->
<message name="IDS_NATIVE_FILE_SYSTEM_WRITE_USAGE_TOOLTIP" desc="Tooltip for the omnibox Native File System API file write access usage indicator.">
This page is allowed to edit files
......
......@@ -105,8 +105,9 @@ class NativeFileSystemBrowserTest : public testing::WithParamInterface<bool>,
features::kNativeFileSystemOriginScopedPermissions},
{});
} else {
scoped_feature_list_.InitAndEnableFeature(
blink::features::kNativeFileSystemAPI);
scoped_feature_list_.InitWithFeatures(
{blink::features::kNativeFileSystemAPI},
{features::kNativeFileSystemOriginScopedPermissions});
}
InProcessBrowserTest::SetUp();
......
......@@ -10,6 +10,7 @@
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/native_file_system/native_file_system_ui_helpers.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/url_formatter/elide_url.h"
......@@ -104,9 +105,16 @@ NativeFileSystemDirectoryAccessConfirmationView::
base::BindOnce(run_callback, base::Unretained(this),
permissions::PermissionAction::DISMISSED));
AddChildView(native_file_system_ui_helper::CreateOriginPathLabel(
IDS_NATIVE_FILE_SYSTEM_DIRECTORY_ACCESS_CONFIRMATION_TEXT, origin, path,
CONTEXT_BODY_TEXT_SMALL, /*show_emphasis=*/true));
if (base::FeatureList::IsEnabled(
features::kNativeFileSystemOriginScopedPermissions)) {
AddChildView(native_file_system_ui_helper::CreateOriginPathLabel(
IDS_NATIVE_FILE_SYSTEM_ORIGIN_SCOPED_READ_PERMISSION_DIRECTORY_TEXT,
origin, path, CONTEXT_BODY_TEXT_SMALL, /*show_emphasis=*/true));
} else {
AddChildView(native_file_system_ui_helper::CreateOriginPathLabel(
IDS_NATIVE_FILE_SYSTEM_DIRECTORY_ACCESS_CONFIRMATION_TEXT, origin, path,
CONTEXT_BODY_TEXT_SMALL, /*show_emphasis=*/true));
}
}
void ShowNativeFileSystemDirectoryAccessConfirmationDialog(
......
......@@ -9,6 +9,7 @@
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/native_file_system/native_file_system_ui_helpers.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/permissions/permission_util.h"
......@@ -51,10 +52,19 @@ NativeFileSystemPermissionView::NativeFileSystemPermissionView(
provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT),
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
AddChildView(native_file_system_ui_helper::CreateOriginPathLabel(
is_directory ? IDS_NATIVE_FILE_SYSTEM_WRITE_PERMISSION_DIRECTORY_TEXT
: IDS_NATIVE_FILE_SYSTEM_WRITE_PERMISSION_FILE_TEXT,
origin, path, CONTEXT_BODY_TEXT_SMALL, /*show_emphasis=*/true));
if (base::FeatureList::IsEnabled(
features::kNativeFileSystemOriginScopedPermissions)) {
AddChildView(native_file_system_ui_helper::CreateOriginPathLabel(
is_directory
? IDS_NATIVE_FILE_SYSTEM_ORIGIN_SCOPED_WRITE_PERMISSION_DIRECTORY_TEXT
: IDS_NATIVE_FILE_SYSTEM_ORIGIN_SCOPED_WRITE_PERMISSION_FILE_TEXT,
origin, path, CONTEXT_BODY_TEXT_SMALL, /*show_emphasis=*/true));
} else {
AddChildView(native_file_system_ui_helper::CreateOriginPathLabel(
is_directory ? IDS_NATIVE_FILE_SYSTEM_WRITE_PERMISSION_DIRECTORY_TEXT
: IDS_NATIVE_FILE_SYSTEM_WRITE_PERMISSION_FILE_TEXT,
origin, path, CONTEXT_BODY_TEXT_SMALL, /*show_emphasis=*/true));
}
}
NativeFileSystemPermissionView::~NativeFileSystemPermissionView() {
......
......@@ -51,7 +51,7 @@ std::unique_ptr<views::View> CreateOriginPathLabel(int message_id,
l10n_util::GetStringFUTF16(message_id, formatted_origin, formatted_path,
&offsets),
nullptr);
DCHECK_EQ(2U, offsets.size());
DCHECK_GE(offsets.size(), 2u);
label->SetTextContext(text_context);
label->SetDefaultTextStyle(show_emphasis ? views::style::STYLE_SECONDARY
......@@ -61,9 +61,12 @@ std::unique_ptr<views::View> CreateOriginPathLabel(int message_id,
if (show_emphasis) {
views::StyledLabel::RangeStyleInfo origin_style;
origin_style.text_style = STYLE_EMPHASIZED_SECONDARY;
label->AddStyleRange(
gfx::Range(offsets[0], offsets[0] + formatted_origin.length()),
origin_style);
// All but the last offset should be the origin.
for (size_t i = 0; i < offsets.size() - 1; ++i) {
label->AddStyleRange(
gfx::Range(offsets[i], offsets[i] + formatted_origin.length()),
origin_style);
}
}
views::StyledLabel::RangeStyleInfo path_style;
......@@ -71,7 +74,8 @@ std::unique_ptr<views::View> CreateOriginPathLabel(int message_id,
path_style.text_style = STYLE_EMPHASIZED_SECONDARY;
path_style.tooltip = path.LossyDisplayName();
label->AddStyleRange(
gfx::Range(offsets[1], offsets[1] + formatted_path.length()), path_style);
gfx::Range(offsets.back(), offsets.back() + formatted_path.length()),
path_style);
return label;
}
......
......@@ -508,7 +508,7 @@ const base::Feature kOnConnectNative{"OnConnectNative",
// permissions are no longer scoped to tabs.
const base::Feature kNativeFileSystemOriginScopedPermissions{
"NativeFileSystemOriginScopedPermissions",
base::FEATURE_DISABLED_BY_DEFAULT};
base::FEATURE_ENABLED_BY_DEFAULT};
// Enables the use of native notification centers instead of using the Message
// Center for displaying the toasts. The feature is hardcoded to enabled for
......
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