SmartCard: Custom text for the "always allow" button
Bug: 1503624 Change-Id: I9281adf0aa18011f21106826be9ff096f2484328 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5116644 Reviewed-by: Andy Paicu <andypaicu@chromium.org> Commit-Queue: Daniel d'Andrada <dandrader@google.com> Cr-Commit-Position: refs/heads/main@{#1238690}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
61b47c76a9
commit
b51fb9e2fd
@@ -39,6 +39,11 @@ std::u16string SmartCardPermissionRequest::GetMessageTextFragment() const {
|
|||||||
base::ASCIIToUTF16(reader_name_));
|
base::ASCIIToUTF16(reader_name_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::u16string> SmartCardPermissionRequest::GetAllowAlwaysText()
|
||||||
|
const {
|
||||||
|
return l10n_util::GetStringUTF16(IDS_SMART_CARD_PERMISSION_ALWAYS_ALLOW);
|
||||||
|
}
|
||||||
|
|
||||||
void SmartCardPermissionRequest::OnPermissionDecided(
|
void SmartCardPermissionRequest::OnPermissionDecided(
|
||||||
ContentSetting content_setting_result,
|
ContentSetting content_setting_result,
|
||||||
bool is_one_time,
|
bool is_one_time,
|
||||||
|
@@ -31,6 +31,7 @@ class SmartCardPermissionRequest : public permissions::PermissionRequest {
|
|||||||
bool IsDuplicateOf(
|
bool IsDuplicateOf(
|
||||||
permissions::PermissionRequest* other_request) const override;
|
permissions::PermissionRequest* other_request) const override;
|
||||||
std::u16string GetMessageTextFragment() const override;
|
std::u16string GetMessageTextFragment() const override;
|
||||||
|
std::optional<std::u16string> GetAllowAlwaysText() const override;
|
||||||
|
|
||||||
void OnPermissionDecided(ContentSetting result,
|
void OnPermissionDecided(ContentSetting result,
|
||||||
bool is_one_time,
|
bool is_one_time,
|
||||||
|
@@ -73,7 +73,8 @@ PermissionPromptBubbleBaseView::PermissionPromptBubbleBaseView(
|
|||||||
|
|
||||||
PermissionPromptBubbleBaseView::~PermissionPromptBubbleBaseView() = default;
|
PermissionPromptBubbleBaseView::~PermissionPromptBubbleBaseView() = default;
|
||||||
|
|
||||||
void PermissionPromptBubbleBaseView::CreatePermissionButtons() {
|
void PermissionPromptBubbleBaseView::CreatePermissionButtons(
|
||||||
|
const std::u16string& allow_always_text) {
|
||||||
if (is_one_time_permission_) {
|
if (is_one_time_permission_) {
|
||||||
SetButtons(ui::DIALOG_BUTTON_NONE);
|
SetButtons(ui::DIALOG_BUTTON_NONE);
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ void PermissionPromptBubbleBaseView::CreatePermissionButtons() {
|
|||||||
FilterUnintenedEventsAndRunCallbacks,
|
FilterUnintenedEventsAndRunCallbacks,
|
||||||
base::Unretained(this),
|
base::Unretained(this),
|
||||||
GetViewId(PermissionDialogButton::kAccept)),
|
GetViewId(PermissionDialogButton::kAccept)),
|
||||||
l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW_EVERY_VISIT));
|
allow_always_text);
|
||||||
allow_always_button->SetProperty(views::kElementIdentifierKey,
|
allow_always_button->SetProperty(views::kElementIdentifierKey,
|
||||||
kAllowButtonElementId);
|
kAllowButtonElementId);
|
||||||
allow_always_button->SetID(GetViewId(PermissionDialogButton::kAccept));
|
allow_always_button->SetID(GetViewId(PermissionDialogButton::kAccept));
|
||||||
@@ -299,6 +300,21 @@ bool PermissionPromptBubbleBaseView::IsOneTimePermission(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::u16string PermissionPromptBubbleBaseView::GetAllowAlwaysText(
|
||||||
|
const std::vector<permissions::PermissionRequest*>& visible_requests) {
|
||||||
|
CHECK_GT(visible_requests.size(), 0u);
|
||||||
|
|
||||||
|
if (visible_requests.size() == 1 &&
|
||||||
|
visible_requests[0]->GetAllowAlwaysText().has_value()) {
|
||||||
|
// A prompt for a single request can use an "allow always" text that is
|
||||||
|
// customized for it.
|
||||||
|
return visible_requests[0]->GetAllowAlwaysText().value();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the generic text.
|
||||||
|
return l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW_EVERY_VISIT);
|
||||||
|
}
|
||||||
|
|
||||||
void PermissionPromptBubbleBaseView::RecordDecision(
|
void PermissionPromptBubbleBaseView::RecordDecision(
|
||||||
permissions::PermissionAction action) {
|
permissions::PermissionAction action) {
|
||||||
const std::string uma_suffix =
|
const std::string uma_suffix =
|
||||||
|
@@ -82,7 +82,7 @@ class PermissionPromptBubbleBaseView : public PermissionPromptBaseView {
|
|||||||
std::u16string GetPermissionFragmentForTesting() const;
|
std::u16string GetPermissionFragmentForTesting() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreatePermissionButtons();
|
void CreatePermissionButtons(const std::u16string& allow_always_text);
|
||||||
void CreateExtraTextLabel(const std::u16string& extra_text);
|
void CreateExtraTextLabel(const std::u16string& extra_text);
|
||||||
|
|
||||||
void CreateWidget();
|
void CreateWidget();
|
||||||
@@ -97,6 +97,9 @@ class PermissionPromptBubbleBaseView : public PermissionPromptBaseView {
|
|||||||
static bool IsOneTimePermission(
|
static bool IsOneTimePermission(
|
||||||
permissions::PermissionPrompt::Delegate& delegate);
|
permissions::PermissionPrompt::Delegate& delegate);
|
||||||
|
|
||||||
|
static std::u16string GetAllowAlwaysText(
|
||||||
|
const std::vector<permissions::PermissionRequest*>& visible_requests);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetPromptStyle(PermissionPromptStyle prompt_style);
|
void SetPromptStyle(PermissionPromptStyle prompt_style);
|
||||||
|
|
||||||
|
@@ -172,7 +172,7 @@ PermissionPromptBubbleOneOriginView::PermissionPromptBubbleOneOriginView(
|
|||||||
CreateExtraTextLabel(extra_text.value());
|
CreateExtraTextLabel(extra_text.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatePermissionButtons();
|
CreatePermissionButtons(GetAllowAlwaysText(visible_requests));
|
||||||
|
|
||||||
bool has_camera_request = false;
|
bool has_camera_request = false;
|
||||||
bool has_mic_request = false;
|
bool has_mic_request = false;
|
||||||
|
@@ -67,7 +67,7 @@ PermissionPromptBubbleTwoOriginsView::PermissionPromptBubbleTwoOriginsView(
|
|||||||
CreateExtraTextLabel(extra_text.value());
|
CreateExtraTextLabel(extra_text.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatePermissionButtons();
|
CreatePermissionButtons(GetAllowAlwaysText(delegate->Requests()));
|
||||||
|
|
||||||
// Only requests for Storage Access should use this prompt.
|
// Only requests for Storage Access should use this prompt.
|
||||||
CHECK(delegate);
|
CHECK(delegate);
|
||||||
|
@@ -282,6 +282,10 @@ std::u16string PermissionRequest::GetMessageTextFragment() const {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::optional<std::u16string> PermissionRequest::GetAllowAlwaysText() const {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
bool PermissionRequest::ShouldUseTwoOriginPrompt() const {
|
bool PermissionRequest::ShouldUseTwoOriginPrompt() const {
|
||||||
return request_type() == RequestType::kStorageAccess &&
|
return request_type() == RequestType::kStorageAccess &&
|
||||||
base::FeatureList::IsEnabled(
|
base::FeatureList::IsEnabled(
|
||||||
|
@@ -116,6 +116,12 @@ class PermissionRequest {
|
|||||||
virtual std::u16string GetMessageTextFragment() const;
|
virtual std::u16string GetMessageTextFragment() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Returns the text to be used in the "allow always" button of the
|
||||||
|
// permission prompt.
|
||||||
|
// If not provided, the generic text for this button will be used instead.
|
||||||
|
// The default implementation returns std::nullopt (ie, use generic text).
|
||||||
|
virtual std::optional<std::u16string> GetAllowAlwaysText() const;
|
||||||
|
|
||||||
// Whether the request was initiated by the user clicking on the permission
|
// Whether the request was initiated by the user clicking on the permission
|
||||||
// element.
|
// element.
|
||||||
bool IsEmbeddedPermissionElementInitiated() const;
|
bool IsEmbeddedPermissionElementInitiated() const;
|
||||||
|
@@ -345,6 +345,9 @@ This will otherwise be blocked by your privacy settings. This will allow the con
|
|||||||
<message name="IDS_SMART_CARD_PERMISSION_PROMPT" desc="Text on dialog that asks the user for permission to access a smart card reader device and the card inserted in it (or presented to it, if contactless).">
|
<message name="IDS_SMART_CARD_PERMISSION_PROMPT" desc="Text on dialog that asks the user for permission to access a smart card reader device and the card inserted in it (or presented to it, if contactless).">
|
||||||
Control <ph name="ReaderName">$1<ex>HID Omnikey</ex></ph> and gain access to the smart card accessible to it?
|
Control <ph name="ReaderName">$1<ex>HID Omnikey</ex></ph> and gain access to the smart card accessible to it?
|
||||||
</message>
|
</message>
|
||||||
|
<message name="IDS_SMART_CARD_PERMISSION_ALWAYS_ALLOW" desc="Label on button to always allow access to this smart card reader and any card inserted in (or presented to) it.">
|
||||||
|
Always allow, with any card
|
||||||
|
</message>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<!-- Quota messages -->
|
<!-- Quota messages -->
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
3e0e67dcb269c255fe09bd916423511c60eb9d10
|
Reference in New Issue
Block a user