Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: chrome/browser/ui/views/download/download_item_view.h

Issue 2346043002: Delete old (pre-MD) download shelf view code. (Closed)
Patch Set: gotta git add Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/download/download_item_view.h
diff --git a/chrome/browser/ui/views/download/download_item_view.h b/chrome/browser/ui/views/download/download_item_view.h
index 0dc42bfeba11365fc2adb874acd497ed3a39128a..b2a3fb686ca9daf38a3c17b137266355f1dd1c3d 100644
--- a/chrome/browser/ui/views/download/download_item_view.h
+++ b/chrome/browser/ui/views/download/download_item_view.h
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// A ChromeView that implements one download on the Download shelf.
+// A view that implements one download on the Download shelf.
// Each DownloadItemView contains an application icon, a text label
// indicating the download's file name, a text label indicating the
// download's status (such as the number of bytes downloaded so far)
@@ -13,8 +13,8 @@
// DownloadController that receives / writes data which lives in the
// Renderer.
-#ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__
-#define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__
+#ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_
+#define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_
#include <memory>
#include <string>
@@ -31,9 +31,9 @@
#include "content/public/browser/download_manager.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/font_list.h"
+#include "ui/views/animation/ink_drop_host_view.h"
#include "ui/views/context_menu_controller.h"
-#include "ui/views/controls/button/button.h"
-#include "ui/views/view.h"
+#include "ui/views/controls/button/vector_icon_button_delegate.h"
class DownloadShelfView;
class DownloadShelfContextMenuView;
@@ -48,13 +48,20 @@ class ImageSkia;
class SlideAnimation;
}
+namespace ui {
+class ThemeProvider;
+}
+
namespace views {
+class ImageButton;
class Label;
class LabelButton;
}
-class DownloadItemView : public views::ButtonListener,
- public views::View,
+// Represents a single download item on the download shelf. Encompasses an icon,
+// text, malicious download warnings, etc.
+class DownloadItemView : public views::InkDropHostView,
+ public views::VectorIconButtonDelegate,
public views::ContextMenuController,
public content::DownloadItem::Observer,
public gfx::AnimationDelegate {
@@ -67,6 +74,9 @@ class DownloadItemView : public views::ButtonListener,
void StartDownloadProgress();
void StopDownloadProgress();
+ // Returns the base color for text on this download item, based on |theme|.
+ static SkColor GetTextColorForThemeProvider(const ui::ThemeProvider* theme);
+
// IconManager::Client interface.
void OnExtractIconComplete(gfx::Image* icon);
@@ -85,14 +95,18 @@ class DownloadItemView : public views::ButtonListener,
bool OnMouseDragged(const ui::MouseEvent& event) override;
void OnMouseReleased(const ui::MouseEvent& event) override;
void OnMouseCaptureLost() override;
- void OnMouseMoved(const ui::MouseEvent& event) override;
- void OnMouseExited(const ui::MouseEvent& event) override;
bool OnKeyPressed(const ui::KeyEvent& event) override;
bool GetTooltipText(const gfx::Point& p,
base::string16* tooltip) const override;
void GetAccessibleState(ui::AXViewState* state) override;
void OnThemeChanged() override;
+ // Overridden from view::InkDropHostView:
+ void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
+ std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
+ std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
+ const override;
+
// Overridden from ui::EventHandler:
void OnGestureEvent(ui::GestureEvent* event) override;
@@ -101,8 +115,9 @@ class DownloadItemView : public views::ButtonListener,
const gfx::Point& point,
ui::MenuSourceType source_type) override;
- // ButtonListener implementation.
+ // VectorIconButtonDelegate implementation.
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+ SkColor GetVectorIconBaseColor() const override;
// gfx::AnimationDelegate implementation.
void AnimationProgressed(const gfx::Animation* animation) override;
@@ -110,41 +125,17 @@ class DownloadItemView : public views::ButtonListener,
protected:
// Overridden from views::View:
void OnPaint(gfx::Canvas* canvas) override;
- void OnPaintBackground(gfx::Canvas* canvas) override;
void OnFocus() override;
void OnBlur() override;
private:
- enum State {
- NORMAL = 0,
- HOT,
- PUSHED
- };
+ enum State { NORMAL = 0, HOT, PUSHED };
+ class DropDownButton;
enum Mode {
- NORMAL_MODE = 0, // Showing download item.
- DANGEROUS_MODE, // Displaying the dangerous download warning.
- MALICIOUS_MODE // Displaying the malicious download warning.
- };
-
- // The image set associated with the part containing the icon and text.
- struct BodyImageSet {
- gfx::ImageSkia* top_left;
- gfx::ImageSkia* left;
- gfx::ImageSkia* bottom_left;
- gfx::ImageSkia* top;
- gfx::ImageSkia* center;
- gfx::ImageSkia* bottom;
- gfx::ImageSkia* top_right;
- gfx::ImageSkia* right;
- gfx::ImageSkia* bottom_right;
- };
-
- // The image set associated with the drop-down button on the right.
- struct DropDownImageSet {
- gfx::ImageSkia* top;
- gfx::ImageSkia* center;
- gfx::ImageSkia* bottom;
+ NORMAL_MODE = 0, // Showing download item.
+ DANGEROUS_MODE, // Displaying the dangerous download warning.
+ MALICIOUS_MODE // Displaying the malicious download warning.
};
void OpenDownload();
@@ -158,6 +149,15 @@ class DownloadItemView : public views::ButtonListener,
// Otherwise, it simply removes the DownloadItem without uploading.
void PossiblySubmitDownloadToFeedbackService(bool enabled);
+ // This function calculates the vertical coordinate to draw the file name text
+ // relative to local bounds.
+ int GetYForFilenameText() const;
+
+ // Painting of various download item bits.
+ void DrawStatusText(gfx::Canvas* canvas);
+ void DrawFilename(gfx::Canvas* canvas);
+ void DrawIcon(gfx::Canvas* canvas);
+
void LoadIcon();
void LoadIconIfItemPathChanged();
@@ -166,26 +166,15 @@ class DownloadItemView : public views::ButtonListener,
// Shows the context menu at the specified location. |point| is in the view's
// coordinate system.
- void ShowContextMenuImpl(const gfx::Point& point,
+ void ShowContextMenuImpl(const gfx::Rect& rect,
ui::MenuSourceType source_type);
// Common code for handling pointer events (i.e. mouse or gesture).
void HandlePressEvent(const ui::LocatedEvent& event, bool active_event);
void HandleClickEvent(const ui::LocatedEvent& event, bool active_event);
- // Convenience method to paint the 3 vertical images (bottom, middle, top)
- // that form the background.
- void PaintImages(gfx::Canvas* canvas,
- const gfx::ImageSkia* top_image,
- const gfx::ImageSkia* center_image,
- const gfx::ImageSkia* bottom_image,
- int x,
- int y,
- int height,
- int width);
-
// Sets the state and triggers a repaint.
- void SetState(State body_state, State drop_down_state);
+ void SetDropdownState(State new_state);
// Whether we are in the dangerous mode.
bool IsShowingWarningDialog() const {
@@ -202,6 +191,10 @@ class DownloadItemView : public views::ButtonListener,
// warning.
void ShowWarningDialog();
+ // Returns the current warning icon (should only be called when the view is
+ // actually showing a warning).
+ gfx::ImageSkia GetWarningIcon();
+
// Sets |size| with the size of the Save and Discard buttons (they have the
// same size).
gfx::Size GetButtonSize() const;
@@ -216,40 +209,27 @@ class DownloadItemView : public views::ButtonListener,
void Reenable();
// Releases drop down button after showing a context menu.
- void ReleaseDropDown();
-
- // Given |x|, returns whether |x| is within the x coordinate range of
- // the drop-down button or not.
- bool InDropDownButtonXCoordinateRange(int x);
+ void ReleaseDropdown();
// Update the accessible name to reflect the current state of the control,
// so that screenreaders can access the filename, status text, and
// dangerous download warning message (if any).
void UpdateAccessibleName();
- // Update the location of the drop down button.
- void UpdateDropDownButtonPosition();
-
// Show/Hide/Reset |animation| based on the state transition specified by
// |from| and |to|.
- void AnimateStateTransition(State from, State to,
+ void AnimateStateTransition(State from,
+ State to,
gfx::SlideAnimation* animation);
// Callback for |progress_timer_|.
void ProgressTimerFired();
- // The different images used for the background.
- BodyImageSet normal_body_image_set_;
- BodyImageSet hot_body_image_set_;
- BodyImageSet pushed_body_image_set_;
- BodyImageSet dangerous_mode_body_image_set_;
- BodyImageSet malicious_mode_body_image_set_;
- DropDownImageSet normal_drop_down_image_set_;
- DropDownImageSet hot_drop_down_image_set_;
- DropDownImageSet pushed_drop_down_image_set_;
+ // Returns the base text color.
+ SkColor GetTextColor() const;
- // The warning icon showns for dangerous downloads.
- const gfx::ImageSkia* warning_icon_;
+ // Returns a slightly dimmed version of the base text color.
+ SkColor GetDimmedTextColor() const;
// The download shelf that owns us.
DownloadShelfView* shelf_;
@@ -257,15 +237,17 @@ class DownloadItemView : public views::ButtonListener,
// Elements of our particular download
base::string16 status_text_;
- // The font list used to print the file name and status.
+ // The font list used to print the file name and warning text.
gfx::FontList font_list_;
+ // The font list used to print the status text below the file name.
+ gfx::FontList status_font_list_;
+
// The tooltip. Only displayed when not showing a warning dialog.
base::string16 tooltip_text_;
// The current state (normal, hot or pushed) of the body and drop-down.
- State body_state_;
- State drop_down_state_;
+ State dropdown_state_;
// Mode of the download item view.
Mode mode_;
@@ -278,19 +260,6 @@ class DownloadItemView : public views::ButtonListener,
// total active time for downloads of unknown size.
base::TimeDelta previous_progress_elapsed_;
- // The left and right x coordinates of the drop-down button.
- int drop_down_x_left_;
- int drop_down_x_right_;
-
- // Used when we are showing the menu to show the drop-down as pressed.
- bool drop_down_pressed_;
-
- // The height of the box formed by the background images and its labels.
- int box_height_;
-
- // The y coordinate of the box formed by the background images and its labels.
- int box_y_;
-
// Whether we are dragging the download button.
bool dragging_;
@@ -306,10 +275,6 @@ class DownloadItemView : public views::ButtonListener,
// A model class to control the status text we display.
DownloadItemModel model_;
- // Hover animations for our body and drop buttons.
- std::unique_ptr<gfx::SlideAnimation> body_hover_animation_;
- std::unique_ptr<gfx::SlideAnimation> drop_hover_animation_;
-
// Animation for download complete.
std::unique_ptr<gfx::SlideAnimation> complete_animation_;
@@ -320,6 +285,9 @@ class DownloadItemView : public views::ButtonListener,
views::LabelButton* save_button_;
views::LabelButton* discard_button_;
+ // The drop down button.
+ DropDownButton* dropdown_button_;
+
// Dangerous mode label.
views::Label* dangerous_download_label_;
@@ -357,4 +325,4 @@ class DownloadItemView : public views::ButtonListener,
DISALLOW_COPY_AND_ASSIGN(DownloadItemView);
};
-#endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__
+#endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698