Commit 75458c57 authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Update Deep Scanning upload UI text

Add code to use the appropriate drag-data, drag-file and paste strings
instead of just defaulting to the upload strings. Removes the optional
part of the access point since it's used to determine the appropriate
string now.

Bug: 999145
Change-Id: I115cd567f94d9c4ca7a4befdff386ba76163ae20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2016965
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735943}
parent f60dbbf9
...@@ -103,8 +103,9 @@ class BaseTest : public testing::Test { ...@@ -103,8 +103,9 @@ class BaseTest : public testing::Test {
void ScanUpload(content::WebContents* web_contents, void ScanUpload(content::WebContents* web_contents,
DeepScanningDialogDelegate::Data data, DeepScanningDialogDelegate::Data data,
DeepScanningDialogDelegate::CompletionCallback callback) { DeepScanningDialogDelegate::CompletionCallback callback) {
// The access point is only used for metrics, so its value doesn't affect // The access point is only used for metrics and choosing the dialog text if
// the rest of the tests and can always be the same. // one is shown, so its value doesn't affect the tests in this file and can
// always be the same.
DeepScanningDialogDelegate::ShowForWebContents( DeepScanningDialogDelegate::ShowForWebContents(
web_contents, std::move(data), std::move(callback), web_contents, std::move(data), std::move(callback),
DeepScanAccessPoint::UPLOAD); DeepScanAccessPoint::UPLOAD);
......
...@@ -102,7 +102,7 @@ class DeepScanningTopImageView : public views::ImageView { ...@@ -102,7 +102,7 @@ class DeepScanningTopImageView : public views::ImageView {
DeepScanningDialogViews::DeepScanningDialogViews( DeepScanningDialogViews::DeepScanningDialogViews(
std::unique_ptr<DeepScanningDialogDelegate> delegate, std::unique_ptr<DeepScanningDialogDelegate> delegate,
content::WebContents* web_contents, content::WebContents* web_contents,
base::Optional<DeepScanAccessPoint> access_point, DeepScanAccessPoint access_point,
bool is_file_scan) bool is_file_scan)
: delegate_(std::move(delegate)), : delegate_(std::move(delegate)),
web_contents_(web_contents), web_contents_(web_contents),
...@@ -274,13 +274,19 @@ void DeepScanningDialogViews::SetupButtons() { ...@@ -274,13 +274,19 @@ void DeepScanningDialogViews::SetupButtons() {
} }
base::string16 DeepScanningDialogViews::GetDialogMessage() const { base::string16 DeepScanningDialogViews::GetDialogMessage() const {
if (is_pending()) { int text_id;
return l10n_util::GetStringUTF16( switch (dialog_status_) {
IDS_DEEP_SCANNING_DIALOG_UPLOAD_PENDING_MESSAGE); case DeepScanningDialogStatus::PENDING:
text_id = GetPendingMessageId();
break;
case DeepScanningDialogStatus::FAILURE:
text_id = GetFailureMessageId();
break;
case DeepScanningDialogStatus::SUCCESS:
text_id = IDS_DEEP_SCANNING_DIALOG_SUCCESS_MESSAGE;
break;
} }
return l10n_util::GetStringUTF16( return l10n_util::GetStringUTF16(text_id);
is_success() ? IDS_DEEP_SCANNING_DIALOG_SUCCESS_MESSAGE
: IDS_DEEP_SCANNING_DIALOG_UPLOAD_FAILURE_MESSAGE);
} }
base::string16 DeepScanningDialogViews::GetCancelButtonText() const { base::string16 DeepScanningDialogViews::GetCancelButtonText() const {
...@@ -402,14 +408,48 @@ int DeepScanningDialogViews::GetUploadImageId(bool use_dark) const { ...@@ -402,14 +408,48 @@ int DeepScanningDialogViews::GetUploadImageId(bool use_dark) const {
return use_dark ? IDR_UPLOAD_VIOLATION_DARK : IDR_UPLOAD_VIOLATION; return use_dark ? IDR_UPLOAD_VIOLATION_DARK : IDR_UPLOAD_VIOLATION;
} }
int DeepScanningDialogViews::GetPendingMessageId() const {
DCHECK(is_pending());
switch (access_point_) {
case DeepScanAccessPoint::DOWNLOAD:
// This dialog should not appear on the download path. If it somehow does,
// treat it as an upload.
NOTREACHED();
FALLTHROUGH;
case DeepScanAccessPoint::UPLOAD:
return IDS_DEEP_SCANNING_DIALOG_UPLOAD_PENDING_MESSAGE;
case DeepScanAccessPoint::PASTE:
return IDS_DEEP_SCANNING_DIALOG_PASTE_PENDING_MESSAGE;
case DeepScanAccessPoint::DRAG_AND_DROP:
return is_file_scan_ ? IDS_DEEP_SCANNING_DIALOG_DRAG_FILES_PENDING_MESSAGE
: IDS_DEEP_SCANNING_DIALOG_DRAG_DATA_PENDING_MESSAGE;
}
}
int DeepScanningDialogViews::GetFailureMessageId() const {
DCHECK(is_failure());
switch (access_point_) {
case DeepScanAccessPoint::DOWNLOAD:
// This dialog should not appear on the download path. If it somehow does,
// treat it as an upload.
NOTREACHED();
FALLTHROUGH;
case DeepScanAccessPoint::UPLOAD:
return IDS_DEEP_SCANNING_DIALOG_UPLOAD_FAILURE_MESSAGE;
case DeepScanAccessPoint::PASTE:
return IDS_DEEP_SCANNING_DIALOG_PASTE_FAILURE_MESSAGE;
case DeepScanAccessPoint::DRAG_AND_DROP:
return is_file_scan_ ? IDS_DEEP_SCANNING_DIALOG_DRAG_FILES_FAILURE_MESSAGE
: IDS_DEEP_SCANNING_DIALOG_DRAG_DATA_FAILURE_MESSAGE;
}
}
const gfx::ImageSkia* DeepScanningDialogViews::GetTopImage() const { const gfx::ImageSkia* DeepScanningDialogViews::GetTopImage() const {
const bool use_dark = const bool use_dark =
color_utils::IsDark(GetBubbleFrameView()->GetBackgroundColor()); color_utils::IsDark(GetBubbleFrameView()->GetBackgroundColor());
const bool treat_as_text_paste = const bool treat_as_text_paste =
access_point_.has_value() && access_point_ == DeepScanAccessPoint::PASTE ||
(access_point_.value() == DeepScanAccessPoint::PASTE || (access_point_ == DeepScanAccessPoint::DRAG_AND_DROP && !is_file_scan_);
(access_point_.value() == DeepScanAccessPoint::DRAG_AND_DROP &&
!is_file_scan_));
int image_id = treat_as_text_paste ? GetPasteImageId(use_dark) int image_id = treat_as_text_paste ? GetPasteImageId(use_dark)
: GetUploadImageId(use_dark); : GetUploadImageId(use_dark);
......
...@@ -54,7 +54,7 @@ class DeepScanningDialogViews : public views::DialogDelegate { ...@@ -54,7 +54,7 @@ class DeepScanningDialogViews : public views::DialogDelegate {
}; };
DeepScanningDialogViews(std::unique_ptr<DeepScanningDialogDelegate> delegate, DeepScanningDialogViews(std::unique_ptr<DeepScanningDialogDelegate> delegate,
content::WebContents* web_contents, content::WebContents* web_contents,
base::Optional<DeepScanAccessPoint> access_point, DeepScanAccessPoint access_point,
bool is_file_scan); bool is_file_scan);
// views::DialogDelegate: // views::DialogDelegate:
...@@ -120,6 +120,14 @@ class DeepScanningDialogViews : public views::DialogDelegate { ...@@ -120,6 +120,14 @@ class DeepScanningDialogViews : public views::DialogDelegate {
// Returns the appropriate upload top image ID depending on |dialog_status_|. // Returns the appropriate upload top image ID depending on |dialog_status_|.
int GetUploadImageId(bool use_dark) const; int GetUploadImageId(bool use_dark) const;
// Returns the appropriate pending message ID depending on |access_point_| and
// |is_file_scan_|.
int GetPendingMessageId() const;
// Returns the appropriate failure message ID depending on |access_point_| and
// |is_file_scan_|.
int GetFailureMessageId() const;
// Show the dialog. Sets |shown_| to true. // Show the dialog. Sets |shown_| to true.
void Show(); void Show();
...@@ -148,7 +156,7 @@ class DeepScanningDialogViews : public views::DialogDelegate { ...@@ -148,7 +156,7 @@ class DeepScanningDialogViews : public views::DialogDelegate {
// The access point that caused this dialog to open. This changes what text // The access point that caused this dialog to open. This changes what text
// and top image are shown to the user. // and top image are shown to the user.
base::Optional<DeepScanAccessPoint> access_point_; DeepScanAccessPoint access_point_;
// Indicates whether the scan being done is for files or for text. This // Indicates whether the scan being done is for files or for text. This
// changes what text and top image are shown to the user. // changes what text and top image are shown to the user.
......
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