Commit 78588383 authored by Yann Dago's avatar Yann Dago Committed by Commit Bot

Add flash deprecation warning on permission prompt

Screenshot: http://screen/h5v2MCq2nzc
Bug: 1050721
Change-Id: If946fd0077aa1db012f44359753f7a01fc6ecb11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2085753
Commit-Queue: Yann Dago <ydago@chromium.org>
Reviewed-by: default avatarKamila Hasanbega <hkamila@google.com>
Reviewed-by: default avatarAndy Paicu <andypaicu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748729}
parent dc351adc
...@@ -10,14 +10,17 @@ ...@@ -10,14 +10,17 @@
#include "chrome/browser/platform_util.h" #include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/bubble_anchor_util_views.h" #include "chrome/browser/ui/views/bubble_anchor_util_views.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/title_origin_label.h" #include "chrome/browser/ui/views/title_origin_label.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/permissions/permission_request.h" #include "components/permissions/permission_request.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h" #include "components/url_formatter/elide_url.h"
#include "components/vector_icons/vector_icons.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
...@@ -25,6 +28,8 @@ ...@@ -25,6 +28,8 @@
#include "ui/gfx/text_constants.h" #include "ui/gfx/text_constants.h"
#include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme.h"
#include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -98,6 +103,40 @@ void PermissionPromptBubbleView::AddPermissionRequestLine( ...@@ -98,6 +103,40 @@ void PermissionPromptBubbleView::AddPermissionRequestLine(
std::make_unique<views::Label>(request->GetMessageTextFragment())); std::make_unique<views::Label>(request->GetMessageTextFragment()));
label->SetHorizontalAlignment(gfx::ALIGN_LEFT); label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetMultiLine(true); label->SetMultiLine(true);
// Text that warns the user that flash will be deprecated. This text is only
// shown for flash and should be empty for all other permissions.
// TODO (crbug.com/1058401): Remove the warning text once flash is deprecated.
const auto warning_text = request->GetMessageTextWarningFragment();
if (warning_text.empty())
return;
// Should only be reached if the permission required is for flash.
DCHECK(request->GetContentSettingsType() == ContentSettingsType::PLUGINS);
auto* warning_line_container = AddChildView(std::make_unique<views::View>());
warning_line_container->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal,
gfx::Insets(0, provider->GetDistanceMetric(
DISTANCE_SUBSECTION_HORIZONTAL_INDENT)),
provider->GetDistanceMetric(views::DISTANCE_RELATED_LABEL_HORIZONTAL)));
auto* warning_label = warning_line_container->AddChildView(
std::make_unique<views::Label>(std::move(warning_text)));
warning_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
warning_label->SetMultiLine(true);
auto learn_more_button = views::CreateVectorImageButton(this);
learn_more_button->SetFocusForPlatform();
learn_more_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_LEARN_MORE));
SkColor text_color = GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_LabelEnabledColor);
learn_more_button_ = learn_more_button.get();
views::SetImageFromVectorIcon(learn_more_button_,
vector_icons::kHelpOutlineIcon, text_color);
DialogDelegate::SetExtraView(std::move(learn_more_button));
} }
void PermissionPromptBubbleView::UpdateAnchorPosition() { void PermissionPromptBubbleView::UpdateAnchorPosition() {
...@@ -140,6 +179,14 @@ gfx::Size PermissionPromptBubbleView::CalculatePreferredSize() const { ...@@ -140,6 +179,14 @@ gfx::Size PermissionPromptBubbleView::CalculatePreferredSize() const {
return gfx::Size(width, GetHeightForWidth(width)); return gfx::Size(width, GetHeightForWidth(width));
} }
void PermissionPromptBubbleView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == learn_more_button_)
chrome::AddSelectedTabWithURL(browser_,
GURL(chrome::kFlashDeprecationLearnMoreURL),
ui::PAGE_TRANSITION_LINK);
}
void PermissionPromptBubbleView::Show() { void PermissionPromptBubbleView::Show() {
DCHECK(browser_->window()); DCHECK(browser_->window());
......
...@@ -9,12 +9,18 @@ ...@@ -9,12 +9,18 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/permissions/permission_prompt.h" #include "components/permissions/permission_prompt.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h" #include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/button/button.h"
class Browser; class Browser;
namespace views {
class ImageButton;
}
// Bubble that prompts the user to grant or deny a permission request from a // Bubble that prompts the user to grant or deny a permission request from a
// website. // website.
class PermissionPromptBubbleView : public views::BubbleDialogDelegateView { class PermissionPromptBubbleView : public views::ButtonListener,
public views::BubbleDialogDelegateView {
public: public:
PermissionPromptBubbleView(Browser* browser, PermissionPromptBubbleView(Browser* browser,
permissions::PermissionPrompt::Delegate* delegate); permissions::PermissionPrompt::Delegate* delegate);
...@@ -29,6 +35,9 @@ class PermissionPromptBubbleView : public views::BubbleDialogDelegateView { ...@@ -29,6 +35,9 @@ class PermissionPromptBubbleView : public views::BubbleDialogDelegateView {
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
// Button Listener
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
private: private:
// Holds the string to be displayed as the origin of the permission prompt, // Holds the string to be displayed as the origin of the permission prompt,
// and whether or not that string is an origin. // and whether or not that string is an origin.
...@@ -51,6 +60,8 @@ class PermissionPromptBubbleView : public views::BubbleDialogDelegateView { ...@@ -51,6 +60,8 @@ class PermissionPromptBubbleView : public views::BubbleDialogDelegateView {
// The requesting domain's name or origin. // The requesting domain's name or origin.
const DisplayNameOrOrigin name_or_origin_; const DisplayNameOrOrigin name_or_origin_;
views::ImageButton* learn_more_button_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(PermissionPromptBubbleView); DISALLOW_COPY_AND_ASSIGN(PermissionPromptBubbleView);
}; };
......
...@@ -155,6 +155,9 @@ const char kExtensionControlledSettingLearnMoreURL[] = ...@@ -155,6 +155,9 @@ const char kExtensionControlledSettingLearnMoreURL[] =
const char kExtensionInvalidRequestURL[] = "chrome-extension://invalid/"; const char kExtensionInvalidRequestURL[] = "chrome-extension://invalid/";
const char kFlashDeprecationLearnMoreURL[] =
"https://blog.chromium.org/2017/07/so-long-and-thanks-for-all-flash.html";
const char kGoogleAccountActivityControlsURL[] = const char kGoogleAccountActivityControlsURL[] =
"https://myaccount.google.com/activitycontrols/search"; "https://myaccount.google.com/activitycontrols/search";
......
...@@ -146,6 +146,9 @@ extern const char kExtensionControlledSettingLearnMoreURL[]; ...@@ -146,6 +146,9 @@ extern const char kExtensionControlledSettingLearnMoreURL[];
// URL used to indicate that an extension resource load request was invalid. // URL used to indicate that an extension resource load request was invalid.
extern const char kExtensionInvalidRequestURL[]; extern const char kExtensionInvalidRequestURL[];
// Url to a blogpost about Flash deprecation.
extern const char kFlashDeprecationLearnMoreURL[];
// URL of the 'Activity controls' section of the privacy settings page. // URL of the 'Activity controls' section of the privacy settings page.
extern const char kGoogleAccountActivityControlsURL[]; extern const char kGoogleAccountActivityControlsURL[];
......
...@@ -17,6 +17,10 @@ ContentSettingsType PermissionRequest::GetContentSettingsType() const { ...@@ -17,6 +17,10 @@ ContentSettingsType PermissionRequest::GetContentSettingsType() const {
return ContentSettingsType::DEFAULT; return ContentSettingsType::DEFAULT;
} }
base::string16 PermissionRequest::GetMessageTextWarningFragment() const {
return base::string16();
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
base::string16 PermissionRequest::GetQuietTitleText() const { base::string16 PermissionRequest::GetQuietTitleText() const {
return base::string16(); return base::string16();
......
...@@ -114,6 +114,9 @@ class PermissionRequest { ...@@ -114,6 +114,9 @@ class PermissionRequest {
// be displayed next to an image and indicate the user grants the permission. // be displayed next to an image and indicate the user grants the permission.
virtual base::string16 GetMessageTextFragment() const = 0; virtual base::string16 GetMessageTextFragment() const = 0;
// Returns a warning prompt text related to this permission.
virtual base::string16 GetMessageTextWarningFragment() const;
// Get the origin on whose behalf this permission request is being made. // Get the origin on whose behalf this permission request is being made.
virtual GURL GetOrigin() const = 0; virtual GURL GetOrigin() const = 0;
......
...@@ -244,6 +244,12 @@ base::string16 PermissionRequestImpl::GetMessageTextFragment() const { ...@@ -244,6 +244,12 @@ base::string16 PermissionRequestImpl::GetMessageTextFragment() const {
return l10n_util::GetStringUTF16(message_id); return l10n_util::GetStringUTF16(message_id);
} }
base::string16 PermissionRequestImpl::GetMessageTextWarningFragment() const {
if (content_settings_type_ == ContentSettingsType::PLUGINS)
return l10n_util::GetStringUTF16(IDS_FLASH_PERMISSION_WARNING_FRAGMENT);
return base::string16();
}
GURL PermissionRequestImpl::GetOrigin() const { GURL PermissionRequestImpl::GetOrigin() const {
return request_origin_; return request_origin_;
} }
......
...@@ -41,6 +41,7 @@ class PermissionRequestImpl : public PermissionRequest { ...@@ -41,6 +41,7 @@ class PermissionRequestImpl : public PermissionRequest {
base::string16 GetQuietMessageText() const override; base::string16 GetQuietMessageText() const override;
#endif #endif
base::string16 GetMessageTextFragment() const override; base::string16 GetMessageTextFragment() const override;
base::string16 GetMessageTextWarningFragment() const override;
GURL GetOrigin() const override; GURL GetOrigin() const override;
void PermissionGranted() override; void PermissionGranted() override;
void PermissionDenied() override; void PermissionDenied() override;
......
...@@ -75,6 +75,9 @@ ...@@ -75,6 +75,9 @@
<message name="IDS_FLASH_PERMISSION_FRAGMENT" desc="Permission asked in the permission bubble when a URL wants to use Flash Plugins on the page. Preceded by the prompt 'This site would like to:'. 'Flash' is the name of a plugin and should not be translated."> <message name="IDS_FLASH_PERMISSION_FRAGMENT" desc="Permission asked in the permission bubble when a URL wants to use Flash Plugins on the page. Preceded by the prompt 'This site would like to:'. 'Flash' is the name of a plugin and should not be translated.">
Run Flash Run Flash
</message> </message>
<message name="IDS_FLASH_PERMISSION_WARNING_FRAGMENT" desc="Warning in the permission bubble when a URL wants to use Flash Plugins on the page.">
Flash Player will no longer be supported after December 2020.
</message>
<message name="IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT" desc="Permission fragment shown in the permissions bubble when a web page requests access to the computer's microphone."> <message name="IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT" desc="Permission fragment shown in the permissions bubble when a web page requests access to the computer's microphone.">
Use your microphone Use your microphone
</message> </message>
......
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