Skip to content

Commit

Permalink
Revert "[IncDW] Show Warning when downloading file in Incognito"
Browse files Browse the repository at this point in the history
This reverts commit 6a8051b.

Reason for revert: The project scope is changed.

Original change's description:
> [IncDW] Show Warning when downloading file in Incognito
>
> This CL adds in-context educational warning that files says files downloaded in incognito stays on the device even when incognito session finishes.
>
> Project Proposal: go/incognito-downloads-proposal
> Design Doc: go/incognito-downloads-design-doc
>
> Screenshot on download shelf:
> https://screenshot.googleplex.com/9TPjTDkCWtyQw7Z
>
> Screenshot on downloads page:
> https://screenshot.googleplex.com/9Lq23JAdpgbFHHg
>
> Bug: 1248016
> Change-Id: I9da90ce6d2b622d61d960e2df908b82ad9c28112
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3162278
> Reviewed-by: Side YILMAZ <sideyilmaz@chromium.org>
> Reviewed-by: Min Qin <qinmin@chromium.org>
> Reviewed-by: Greg Kerr <kerrnel@chromium.org>
> Reviewed-by: Denis Kuznetsov [CET] <antrim@chromium.org>
> Reviewed-by: David Trainor <dtrainor@chromium.org>
> Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
> Auto-Submit: Saba Khukhunashvili <khukhunashvili@google.com>
> Cr-Commit-Position: refs/heads/main@{#929072}

Bug: 1248016, 1308397
Change-Id: I828e8bdff92c28b33222e47d1a990e94e6b5267d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3627574
Reviewed-by: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Min Qin <qinmin@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Reviewed-by: Yuheng Huang <yuhengh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1002091}
  • Loading branch information
Side YILMAZ authored and Chromium LUCI CQ committed May 11, 2022
1 parent 210fdc2 commit 5b0e0af
Show file tree
Hide file tree
Showing 34 changed files with 34 additions and 222 deletions.
14 changes: 1 addition & 13 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1953,14 +1953,10 @@ are declared in tools/grit/grit_rule.gni.
desc="Message shown in the download shelf when Chrome recommends uploading the file for additional scanning">
<ph name="FILE_NAME">$1<ex>bla.exe</ex></ph> may be dangerous. Send to Google Advanced Protection for scanning?
</message>
<message name="IDS_PROMPT_DEEP_SCANNING"
<message name="IDS_PROMPT_DEEP_SCANNING"
desc="Message shown in the download shelf for all Advanced Protection and Enhanced Safe Browsing users when Chrome recommends uploading the file for additional scanning.">
<ph name="FILE_NAME">$1<ex>bla.exe</ex></ph> may be dangerous. Send to Google for scanning?
</message>
<message name="IDS_PROMPT_INCOGNITO_WARNING"
desc="Message shown in the download shelf when Incognito Download warning is displayed">
Download <ph name="FILE_NAME">$1<ex>bla.exe</ex></ph>? Anyone using the device can see it.
</message>
<message name="IDS_BLOCK_REASON_UNCOMMON_DOWNLOAD"
desc="Message shown to the user on chrome://downloads page to explain that this download is blocked because it is uncommon.">
This file is not commonly downloaded and may be dangerous.
Expand All @@ -1977,10 +1973,6 @@ are declared in tools/grit/grit_rule.gni.
desc="Message shown to the user on chrome://downloads page to explain that this download is blocked because it is mixed-content.">
This file can't be downloaded securely
</message>
<message name="IDS_INCOGNITO_DOWNLOAD_WARNING"
desc="Message shown to the user on chrome://downloads page to explain that downloaded file will stay after incognito session will end">
This file will be stored on the device and everyone will be able to see it.
</message>
<message name="IDS_BLOCK_REASON_DEEP_SCANNING"
desc="Message shown on chrome://downloads when a download is being scanned">
This file is being scanned.
Expand Down Expand Up @@ -2079,10 +2071,6 @@ are declared in tools/grit/grit_rule.gni.
desc="Text for the button used to validate the installation of an extension.">
Continue
</message>
<message name="IDS_DOWNLOAD_ANYWAY"
desc="Text for the button used to acknowledge incognito download warning">
Download Anyway
</message>
<message name="IDS_DISCARD_DOWNLOAD"
desc="Text for the button used to stop a dangerous download.">
Discard
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7349,7 +7349,7 @@ const FeatureEntry kFeatureEntries[] = {
{"incognito-downloads-warning",
flag_descriptions::kIncognitoDownloadsWarningName,
flag_descriptions::kIncognitoDownloadsWarningDescription, kOsAll,
FEATURE_VALUE_TYPE(download::features::kIncognitoDownloadsWarning)},
FEATURE_VALUE_TYPE(features::kIncognitoDownloadsWarning)},

{"incognito-ntp-revamp", flag_descriptions::kIncognitoNtpRevampName,
flag_descriptions::kIncognitoNtpRevampDescription, kOsAll,
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/download/download_item_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ bool DownloadItemModel::IsMixedContent() const {
return download_->IsMixedContent();
}

bool DownloadItemModel::ShouldShowIncognitoWarning() const {
return download_->ShouldShowIncognitoWarning();
}

bool DownloadItemModel::ShouldAllowDownloadFeedback() const {
#if BUILDFLAG(FULL_SAFE_BROWSING)
if (!IsDangerous())
Expand Down Expand Up @@ -739,12 +735,6 @@ void DownloadItemModel::ExecuteCommand(DownloadCommands* download_commands,
#endif
[[fallthrough]];
case DownloadCommands::KEEP:
// Order of these warning validations should be same as the order that
// GetDesiredDownloadItemMode() method follows.
if (ShouldShowIncognitoWarning()) {
download_->AcceptIncognitoWarning();
break;
}
if (IsMixedContent()) {
download_->ValidateMixedContentDownload();
break;
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/download/download_item_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class DownloadItemModel : public DownloadUIModel,
bool MightBeMalicious() const override;
bool IsMalicious() const override;
bool IsMixedContent() const override;
bool ShouldShowIncognitoWarning() const override;
bool ShouldAllowDownloadFeedback() const override;
bool ShouldRemoveFromShelfWhenComplete() const override;
bool ShouldShowDownloadStartedAnimation() const override;
Expand Down
53 changes: 18 additions & 35 deletions chrome/browser/download/download_ui_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,31 +242,9 @@ std::u16string DownloadUIModel::GetTooltipText() const {
return tooltip;
}

// Ordering of the warning texts should be the same as order in the
// GetDesiredDownloadItemMode() method.
std::u16string DownloadUIModel::GetWarningText(const std::u16string& filename,
size_t* offset) const {
*offset = std::string::npos;

if (ShouldShowIncognitoWarning()) {
return l10n_util::GetStringFUTF16(IDS_PROMPT_INCOGNITO_WARNING, filename,
offset);
}

switch (GetMixedContentStatus()) {
case download::DownloadItem::MixedContentStatus::BLOCK:
return l10n_util::GetStringFUTF16(
IDS_PROMPT_DOWNLOAD_MIXED_CONTENT_BLOCKED, filename, offset);
case download::DownloadItem::MixedContentStatus::WARN:
return l10n_util::GetStringFUTF16(
IDS_PROMPT_DOWNLOAD_MIXED_CONTENT_WARNING, filename, offset);
case download::DownloadItem::MixedContentStatus::UNKNOWN:
case download::DownloadItem::MixedContentStatus::SAFE:
case download::DownloadItem::MixedContentStatus::VALIDATED:
case download::DownloadItem::MixedContentStatus::SILENT_BLOCK:
break;
}

switch (GetDangerType()) {
case download::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
return l10n_util::GetStringUTF16(IDS_PROMPT_MALICIOUS_DOWNLOAD_URL);
Expand Down Expand Up @@ -325,20 +303,29 @@ std::u16string DownloadUIModel::GetWarningText(const std::u16string& filename,
break;
}

switch (GetMixedContentStatus()) {
case download::DownloadItem::MixedContentStatus::BLOCK:
return l10n_util::GetStringFUTF16(
IDS_PROMPT_DOWNLOAD_MIXED_CONTENT_BLOCKED, filename, offset);
case download::DownloadItem::MixedContentStatus::WARN:
return l10n_util::GetStringFUTF16(
IDS_PROMPT_DOWNLOAD_MIXED_CONTENT_WARNING, filename, offset);
case download::DownloadItem::MixedContentStatus::UNKNOWN:
case download::DownloadItem::MixedContentStatus::SAFE:
case download::DownloadItem::MixedContentStatus::VALIDATED:
case download::DownloadItem::MixedContentStatus::SILENT_BLOCK:
break;
}

return std::u16string();
}

std::u16string DownloadUIModel::GetWarningConfirmButtonText() const {
const auto kDangerousFile = download::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;

int warningConfirmButtonTextId = IDS_CONFIRM_DOWNLOAD;
if (ShouldShowIncognitoWarning()) {
warningConfirmButtonTextId = IDS_DOWNLOAD_ANYWAY;
} else if (GetDangerType() == kDangerousFile && IsExtensionDownload()) {
warningConfirmButtonTextId = IDS_CONTINUE_EXTENSION_DOWNLOAD;
}

return l10n_util::GetStringUTF16(warningConfirmButtonTextId);
return l10n_util::GetStringUTF16(
(GetDangerType() == kDangerousFile && IsExtensionDownload())
? IDS_CONTINUE_EXTENSION_DOWNLOAD
: IDS_CONFIRM_DOWNLOAD);
}

std::u16string DownloadUIModel::GetShowInFolderText() const {
Expand Down Expand Up @@ -393,10 +380,6 @@ bool DownloadUIModel::IsMixedContent() const {
return false;
}

bool DownloadUIModel::ShouldShowIncognitoWarning() const {
return false;
}

bool DownloadUIModel::ShouldAllowDownloadFeedback() const {
return false;
}
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/download/download_ui_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ class DownloadUIModel {
// Implies IsDangerous() and !IsMalicious().
virtual bool IsMixedContent() const;

// Returns true if the item is downloaded in incognito and user has not
// accepted the warning yet. Return false if the item is downloaded in regular
// mode or user has accepted the warning.
virtual bool ShouldShowIncognitoWarning() const;

// Is safe browsing download feedback feature available for this download?
virtual bool ShouldAllowDownloadFeedback() const;

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/flags/android/chrome_feature_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const base::Feature* const kFeaturesExposedToJava[] = {
&content_settings::kDarkenWebsitesCheckboxInThemesSetting,
&download::features::kDownloadAutoResumptionNative,
&download::features::kDownloadLater,
&download::features::kIncognitoDownloadsWarning,
&download::features::kSmartSuggestionForLargeDownloads,
&download::features::kUseDownloadOfflineContentProvider,
&embedder_support::kShowTrustedPublisherURL,
Expand All @@ -127,6 +126,7 @@ const base::Feature* const kFeaturesExposedToJava[] = {
&features::kRequestDesktopSiteForTablets,
&features::kToolbarUseHardwareBitmapDraw,
&features::kWebNfc,
&features::kIncognitoDownloadsWarning,
&features::kIncognitoNtpRevamp,
&feature_engagement::kEnableIPH,
&feature_engagement::kEnableAutomaticSnooze,
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/resources/downloads/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ export enum States {
DANGEROUS = 'DANGEROUS',
INTERRUPTED = 'INTERRUPTED',
MIXED_CONTENT = 'MIXED_CONTENT',
INCOGNITO_WARNING = 'INCOGNITO_WARNING',
ASYNC_SCANNING = 'ASYNC_SCANNING',
}
18 changes: 1 addition & 17 deletions chrome/browser/resources/downloads/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@

#pauseOrResume,
#dangerous .action-button,
#incognito-warning .action-button,
#openNow {
margin-inline-end: 8px;
}
Expand Down Expand Up @@ -341,7 +340,7 @@
</div>
</template>

<div id="safe" class="controls" hidden="[[!isDownloadItemSafe_]]">
<div id="safe" class="controls" hidden="[[isDangerous_]]">
<span role="gridcell" hidden="[[!hasShowInFolderLink_]]">
<a is="action-link" id="show" on-click="onShowTap_"
focus-row-control
Expand Down Expand Up @@ -415,21 +414,6 @@
</template>
</div>
</template>

<template is="dom-if" if="[[shouldShowIncognitoWarning_]]">
<div id="incognito-warning" class="controls">
<span role="gridcell">
<cr-button on-click="onIncognitoWarningAccepted_"
class="action-button" focus-row-control
focus-type="save">$i18n{downloadAnyway}</cr-button>
</span>
<span role="gridcell">
<cr-button on-click="onCancelTap_" focus-row-control
focus-type="cancel">
$i18n{controlCancel}</cr-button>
</span>
</div>
</template>
</div>
<div class="more-options">
<div role="gridcell">
Expand Down
39 changes: 2 additions & 37 deletions chrome/browser/resources/downloads/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,12 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
value: true,
},

isDownloadItemSafe_: {
computed: 'computeIsDownloadItemSafe_(data.state)',
type: Boolean,
value: false
},

isDangerous_: {
computed: 'computeIsDangerous_(data.state)',
type: Boolean,
value: false,
},

shouldShowIncognitoWarning_: {
computed: 'computeShouldShowIncognitoWarning_(data.state)',
type: Boolean,
value: false,
},

isMalware_: {
computed: 'computeIsMalware_(isDangerous_, data.dangerType)',
type: Boolean,
Expand Down Expand Up @@ -163,8 +151,6 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
private controlledBy_: string;
private isActive_: boolean;
private isDangerous_: boolean;
private isDownloadItemSafe_: boolean;
private shouldShowIncognitoWarning_: boolean;
private isInProgress_: boolean;
private pauseOrResumeText_: string;
private showCancel_: boolean;
Expand Down Expand Up @@ -282,9 +268,6 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
}
break;

case States.INCOGNITO_WARNING:
return loadTimeData.getString('incognitoDownloadsWarningDesc');

case States.MIXED_CONTENT:
return loadTimeData.getString('mixedContentDownloadDesc');

Expand Down Expand Up @@ -338,8 +321,7 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
const dangerType = this.data.dangerType as DangerType;
if ((loadTimeData.getBoolean('requestsApVerdicts') &&
dangerType === DangerType.UNCOMMON_CONTENT) ||
dangerType === DangerType.SENSITIVE_CONTENT_WARNING ||
this.data.state === States.INCOGNITO_WARNING) {
dangerType === DangerType.SENSITIVE_CONTENT_WARNING) {
return 'cr:warning';
}

Expand Down Expand Up @@ -370,8 +352,7 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
const dangerType = this.data.dangerType as DangerType;
if ((loadTimeData.getBoolean('requestsApVerdicts') &&
dangerType === DangerType.UNCOMMON_CONTENT) ||
dangerType === DangerType.SENSITIVE_CONTENT_WARNING ||
this.data.state === States.INCOGNITO_WARNING) {
dangerType === DangerType.SENSITIVE_CONTENT_WARNING) {
return 'yellow';
}

Expand Down Expand Up @@ -522,8 +503,6 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
this.useFileIcon_ = false;
} else if (this.data.state === States.ASYNC_SCANNING) {
this.useFileIcon_ = false;
} else if (this.data.state === States.INCOGNITO_WARNING) {
this.useFileIcon_ = false;
} else {
this.$.url.href = this.data.url;
const path = this.data.filePath;
Expand All @@ -538,16 +517,6 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
}
}

private computeShouldShowIncognitoWarning_(): boolean {
return this.data.state === States.INCOGNITO_WARNING &&
this.data.shouldShowIncognitoWarning;
}

private computeIsDownloadItemSafe_(): boolean {
return !this.computeIsDangerous_() &&
!this.computeShouldShowIncognitoWarning_();
}

private onCancelTap_() {
this.restoreFocusAfterCancel_ = true;
this.mojoHandler_!.cancel(this.data.id);
Expand Down Expand Up @@ -611,10 +580,6 @@ export class DownloadsItemElement extends DownloadsItemElementBase {
this.mojoHandler_!.saveDangerousRequiringGesture(this.data.id);
}

private onIncognitoWarningAccepted_() {
this.mojoHandler_!.acceptIncognitoWarning(this.data.id);
}

private onShowTap_() {
this.mojoHandler_!.show(this.data.id);
}
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/ui/download/download_item_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
namespace download {

DownloadItemMode GetDesiredDownloadItemMode(DownloadUIModel* download) {
if (download->ShouldShowIncognitoWarning() &&
(download->GetState() != download::DownloadItem::CANCELLED)) {
return DownloadItemMode::kIncognitoWarning;
}

if (download->IsMixedContent()) {
const bool warn = download->GetMixedContentStatus() ==
download::DownloadItem::MixedContentStatus::WARN;
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/ui/download/download_item_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ enum class DownloadItemMode {
kMixedContentWarn, // Displaying the mixed-content download warning.
kMixedContentBlock, // Displaying the mixed-content download block error.
kDeepScanning, // Displaying in-progress deep scanning information.
kIncognitoWarning, // Displaying warning about files saved on the device even
// in Incognito.
};

// Returns the mode that best reflects the current model state.
Expand Down
10 changes: 2 additions & 8 deletions chrome/browser/ui/views/download/download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ bool is_mixed_content(download::DownloadItemMode mode) {

// Whether a warning label is visible.
bool has_warning_label(download::DownloadItemMode mode) {
return is_download_warning(mode) || is_mixed_content(mode) ||
mode == download::DownloadItemMode::kIncognitoWarning;
return is_download_warning(mode) || is_mixed_content(mode);
}

float GetDPIScaleForView(views::View* view) {
Expand Down Expand Up @@ -898,8 +897,7 @@ void DownloadItemView::UpdateButtons() {

save_button_->SetVisible(
(mode_ == download::DownloadItemMode::kDangerous) ||
(mode_ == download::DownloadItemMode::kMixedContentWarn) ||
(mode_ == download::DownloadItemMode::kIncognitoWarning));
(mode_ == download::DownloadItemMode::kMixedContentWarn));
save_button_->SetText(model_->GetWarningConfirmButtonText());

discard_button_->SetVisible(
Expand Down Expand Up @@ -1094,10 +1092,6 @@ ui::ImageModel DownloadItemView::GetIcon() const {
vector_icons::kErrorIcon, ui::kColorAlertHighSeverity,
UseNewWarnings() ? 20 : 24);

if (model_->ShouldShowIncognitoWarning()) {
return kWarning;
}

const auto danger_type = model_->GetDangerType();
const auto kInfo = ui::ImageModel::FromVectorIcon(
(danger_type == download::DOWNLOAD_DANGER_TYPE_ASYNC_SCANNING)
Expand Down

0 comments on commit 5b0e0af

Please sign in to comment.