Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed download item filename overlap #9759

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions browser/ui/views/download/brave_download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/auto_reset.h"
#include "brave/app/vector_icons/vector_icons.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/download/download_item_mode.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
Expand Down Expand Up @@ -99,7 +100,6 @@ void BraveDownloadItemView::OnPaint(gfx::Canvas* canvas) {
DownloadItemView::OnPaint(canvas);
if (is_origin_url_visible_)
DrawOriginURL(canvas);
file_name_label_->SetVisible(!is_origin_url_visible_);
}

// download::DownloadItem::Observer overrides.
Expand Down Expand Up @@ -236,18 +236,31 @@ void BraveDownloadItemView::SetMode(download::DownloadItemMode mode) {
}
}

void BraveDownloadItemView::UpdateLabels() {
DownloadItemView::UpdateLabels();
// Update visibility to avoid artifacts to be shown from upstream
file_name_label_->SetVisible(
nullhook marked this conversation as resolved.
Show resolved Hide resolved
!is_origin_url_visible_ &&
(GetMode() == download::DownloadItemMode::kNormal));
}

void BraveDownloadItemView::SetOriginUrlVisible(bool visible) {
is_origin_url_visible_ = visible;
UpdateLabels();
}

void BraveDownloadItemView::OnMouseEntered(const ui::MouseEvent& event) {
is_origin_url_visible_ = true;
SetOriginUrlVisible(true);
}

void BraveDownloadItemView::OnMouseExited(const ui::MouseEvent& event) {
is_origin_url_visible_ = false;
SetOriginUrlVisible(false);
}

void BraveDownloadItemView::OnViewFocused(View* observed_view) {
is_origin_url_visible_ = true;
SetOriginUrlVisible(true);
}

void BraveDownloadItemView::OnViewBlurred(View* observed_view) {
is_origin_url_visible_ = false;
SetOriginUrlVisible(false);
}
3 changes: 3 additions & 0 deletions browser/ui/views/download/brave_download_item_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ class BraveDownloadItemView : public DownloadItemView {

// Overrides the accessible name construction to reflect the origin URL.
void SetMode(download::DownloadItemMode mode) override;
void UpdateLabels() override;
void OnMouseEntered(const ui::MouseEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override;
void OnViewFocused(View* observed_view) override;
void OnViewBlurred(View* observed_view) override;

void SetOriginUrlVisible(bool visible);

// Brave download item model.
BraveDownloadItemModel brave_model_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
protected: \
bool IsShowingWarningDialog() const;

#define UpdateLabels virtual UpdateLabels
#define SetMode virtual SetMode
#include "../../../../../../../chrome/browser/ui/views/download/download_item_view.h"
#undef SetMode
#undef UpdateLabels
#undef BRAVE_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_

#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_