-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PEPC] Add view that informs user they previously denied permission
Let the user know that they previously denied permission to the site. Additionally give them the option to grant permission or not. Bug: 1462930 Change-Id: I99b51740345e72acaefcc1090d13ff5521624da8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4876674 Reviewed-by: Thomas Nguyen <tungnh@chromium.org> Commit-Queue: Thomas Nguyen <tungnh@chromium.org> Auto-Submit: Kamila Hasanbega <hkamila@google.com> Cr-Commit-Position: refs/heads/main@{#1210767}
- Loading branch information
Showing
13 changed files
with
171 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
chrome/browser/ui/views/permissions/embedded_permission_prompt_previously_denied_view.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// 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. | ||
|
||
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_previously_denied_view.h" | ||
|
||
#include "base/memory/weak_ptr.h" | ||
|
||
#include "chrome/browser/ui/url_identity.h" | ||
#include "components/permissions/features.h" | ||
#include "components/strings/grit/components_strings.h" | ||
#include "components/vector_icons/vector_icons.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
EmbeddedPermissionPromptPreviouslyDeniedView:: | ||
EmbeddedPermissionPromptPreviouslyDeniedView( | ||
Browser* browser, | ||
base::WeakPtr<permissions::PermissionPrompt::Delegate> delegate) | ||
: EmbeddedPermissionPromptBaseView(browser, delegate) {} | ||
|
||
EmbeddedPermissionPromptPreviouslyDeniedView:: | ||
~EmbeddedPermissionPromptPreviouslyDeniedView() = default; | ||
|
||
std::u16string | ||
EmbeddedPermissionPromptPreviouslyDeniedView::GetAccessibleWindowTitle() const { | ||
return GetMessageText(); | ||
} | ||
|
||
std::u16string EmbeddedPermissionPromptPreviouslyDeniedView::GetWindowTitle() | ||
const { | ||
return std::u16string(); | ||
} | ||
|
||
void EmbeddedPermissionPromptPreviouslyDeniedView::RunButtonCallback( | ||
int button_id) { | ||
if (!delegate()) { | ||
return; | ||
} | ||
|
||
ButtonType button = GetButtonType(button_id); | ||
|
||
if (button == ButtonType::kContinueNotAllowing) { | ||
// The permission is already denied. | ||
return; | ||
} | ||
|
||
if (button == ButtonType::kAllowThisTime) { | ||
delegate()->AcceptThisTime(); | ||
} | ||
|
||
if (button == ButtonType::kAllow) { | ||
delegate()->Accept(); | ||
} | ||
} | ||
|
||
std::vector< | ||
EmbeddedPermissionPromptPreviouslyDeniedView::RequestLineConfiguration> | ||
EmbeddedPermissionPromptPreviouslyDeniedView::GetRequestLinesConfiguration() | ||
const { | ||
return {{/*icon=*/nullptr, GetMessageText()}}; | ||
} | ||
|
||
std::vector<EmbeddedPermissionPromptPreviouslyDeniedView::ButtonConfiguration> | ||
EmbeddedPermissionPromptPreviouslyDeniedView::GetButtonsConfiguration() const { | ||
std::vector<ButtonConfiguration> buttons; | ||
buttons.emplace_back( | ||
l10n_util::GetStringUTF16(IDS_EMBEDDED_PROMPT_CONTINUE_NOT_ALLOWING), | ||
ButtonType::kContinueNotAllowing, ui::ButtonStyle::kTonal); | ||
|
||
if (base::FeatureList::IsEnabled(permissions::features::kOneTimePermission)) { | ||
buttons.emplace_back( | ||
l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW_THIS_TIME), | ||
ButtonType::kAllowThisTime, ui::ButtonStyle::kTonal); | ||
} else { | ||
buttons.emplace_back( | ||
l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW_THIS_TIME), | ||
ButtonType::kAllow, ui::ButtonStyle::kTonal); | ||
} | ||
return buttons; | ||
} | ||
|
||
std::u16string EmbeddedPermissionPromptPreviouslyDeniedView::GetMessageText() | ||
const { | ||
const auto& requests = delegate()->Requests(); | ||
CHECK_GT(requests.size(), 0U); | ||
|
||
std::u16string permission_name; | ||
if (requests.size() == 2) { | ||
permission_name = l10n_util::GetStringUTF16( | ||
IDS_CAMERA_AND_MICROPHONE_PERMISSION_NAME_FRAGMENT); | ||
} else { | ||
permission_name = requests[0]->GetPermissionNameTextFragment(); | ||
} | ||
|
||
return l10n_util::GetStringFUTF16(IDS_EMBEDDED_PROMPT_PREVIOUSLY_NOT_ALLOWED, | ||
permission_name, | ||
GetUrlIdentityObject().name); | ||
} |
43 changes: 43 additions & 0 deletions
43
chrome/browser/ui/views/permissions/embedded_permission_prompt_previously_denied_view.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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. | ||
|
||
#ifndef CHROME_BROWSER_UI_VIEWS_PERMISSIONS_EMBEDDED_PERMISSION_PROMPT_PREVIOUSLY_DENIED_VIEW_H_ | ||
#define CHROME_BROWSER_UI_VIEWS_PERMISSIONS_EMBEDDED_PERMISSION_PROMPT_PREVIOUSLY_DENIED_VIEW_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/browser/ui/views/permissions/embedded_permission_prompt_base_view.h" | ||
|
||
class Browser; | ||
|
||
// A view used to display information to the user that they previously denied | ||
// permission to a site. | ||
class EmbeddedPermissionPromptPreviouslyDeniedView | ||
: public EmbeddedPermissionPromptBaseView { | ||
public: | ||
EmbeddedPermissionPromptPreviouslyDeniedView( | ||
Browser* browser, | ||
base::WeakPtr<permissions::PermissionPrompt::Delegate> delegate); | ||
EmbeddedPermissionPromptPreviouslyDeniedView( | ||
const EmbeddedPermissionPromptPreviouslyDeniedView&) = delete; | ||
EmbeddedPermissionPromptPreviouslyDeniedView& operator=( | ||
const EmbeddedPermissionPromptPreviouslyDeniedView&) = delete; | ||
~EmbeddedPermissionPromptPreviouslyDeniedView() override; | ||
|
||
std::u16string GetAccessibleWindowTitle() const override; | ||
std::u16string GetWindowTitle() const override; | ||
void RunButtonCallback(int type) override; | ||
|
||
protected: | ||
std::vector<RequestLineConfiguration> GetRequestLinesConfiguration() | ||
const override; | ||
std::vector<ButtonConfiguration> GetButtonsConfiguration() const override; | ||
|
||
private: | ||
std::u16string GetMessageText() const; | ||
}; | ||
|
||
#endif // CHROME_BROWSER_UI_VIEWS_PERMISSIONS_EMBEDDED_PERMISSION_PROMPT_PREVIOUSLY_DENIED_VIEW_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
components/permissions_strings_grdp/IDS_EMBEDDED_PROMPT_CONTINUE_NOT_ALLOWING.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
23ba382603c7c838ba78dd1216a067593c1df229 |
1 change: 1 addition & 0 deletions
1
components/permissions_strings_grdp/IDS_EMBEDDED_PROMPT_PREVIOUSLY_NOT_ALLOWED.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
23ba382603c7c838ba78dd1216a067593c1df229 |