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

Side by Side Diff: chrome/browser/download/download_item_model.h

Issue 10169025: Show download interrupt reason in a tooltip (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move logic to DownloadItemModel Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 14 matching lines...) Expand all
25 // This class is an abstraction for common UI tasks associated with a download. 25 // This class is an abstraction for common UI tasks associated with a download.
26 class BaseDownloadItemModel { 26 class BaseDownloadItemModel {
27 public: 27 public:
28 explicit BaseDownloadItemModel(content::DownloadItem* download) 28 explicit BaseDownloadItemModel(content::DownloadItem* download)
29 : download_(download) { } 29 : download_(download) { }
30 virtual ~BaseDownloadItemModel() { } 30 virtual ~BaseDownloadItemModel() { }
31 31
32 // Cancel the task corresponding to the item. 32 // Cancel the task corresponding to the item.
33 virtual void CancelTask() = 0; 33 virtual void CancelTask() = 0;
34 34
35 // Get the status text to display. 35 // Returns a short one-line status string for the download.
36 virtual string16 GetStatusText() = 0; 36 virtual string16 GetStatusText() = 0;
37 37
38 // Returns a string suitable for use as a tooltip. For a regular download, the
39 // tooltip is the filename. For an interrupted download, the string states the
40 // filename and a short description of the reason for interruption. For
41 // example:
42 // Report.pdf
43 // Network disconnected
44 // |font| and |max_width| are used to elide the filename and/or interrupt
45 // reason as necessary to keep the width of the tooltip text under
46 // |max_width|. The tooltip will be at most 2 lines.
47 virtual string16 GetTooltipText(const gfx::Font& font,
48 int max_width) const = 0;
49
38 // Rough percent complete. Returns -1 if the progress is unknown. 50 // Rough percent complete. Returns -1 if the progress is unknown.
39 virtual int PercentComplete() const = 0; 51 virtual int PercentComplete() const = 0;
40 52
41 // Get the warning text to display for a dangerous download. The |base_width| 53 // Get the warning text to display for a dangerous download. The |base_width|
42 // is the maximum width of an embedded filename (if there is one). The metrics 54 // is the maximum width of an embedded filename (if there is one). The metrics
43 // for the filename will be based on |font|. Should only be called if 55 // for the filename will be based on |font|. Should only be called if
44 // IsDangerous() is true. 56 // IsDangerous() is true.
45 virtual string16 GetWarningText(const gfx::Font& font, int base_width) = 0; 57 virtual string16 GetWarningText(const gfx::Font& font, int base_width) = 0;
46 58
47 // Get the caption text for a button for confirming a dangerous download 59 // Get the caption text for a button for confirming a dangerous download
(...skipping 20 matching lines...) Expand all
68 80
69 // Concrete implementation of BaseDownloadItemModel. 81 // Concrete implementation of BaseDownloadItemModel.
70 class DownloadItemModel : public BaseDownloadItemModel { 82 class DownloadItemModel : public BaseDownloadItemModel {
71 public: 83 public:
72 explicit DownloadItemModel(content::DownloadItem* download); 84 explicit DownloadItemModel(content::DownloadItem* download);
73 virtual ~DownloadItemModel() { } 85 virtual ~DownloadItemModel() { }
74 86
75 // BaseDownloadItemModel 87 // BaseDownloadItemModel
76 virtual void CancelTask() OVERRIDE; 88 virtual void CancelTask() OVERRIDE;
77 virtual string16 GetStatusText() OVERRIDE; 89 virtual string16 GetStatusText() OVERRIDE;
90 virtual string16 GetTooltipText(const gfx::Font& font,
91 int max_width) const OVERRIDE;
78 virtual int PercentComplete() const OVERRIDE; 92 virtual int PercentComplete() const OVERRIDE;
79 virtual string16 GetWarningText(const gfx::Font& font, 93 virtual string16 GetWarningText(const gfx::Font& font,
80 int base_width) OVERRIDE; 94 int base_width) OVERRIDE;
81 virtual string16 GetWarningConfirmButtonText() OVERRIDE; 95 virtual string16 GetWarningConfirmButtonText() OVERRIDE;
82 virtual bool IsMalicious() OVERRIDE; 96 virtual bool IsMalicious() OVERRIDE;
83 virtual bool IsDangerous() OVERRIDE; 97 virtual bool IsDangerous() OVERRIDE;
84 98
85 private: 99 private:
86 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); 100 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel);
87 }; 101 };
88 102
89 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 103 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698