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

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

Issue 9569011: Refactor dangerous download warning text generation into DownloadItemModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ui::ElideText() Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 14
15 class SavePackage; 15 class SavePackage;
16 16
17 namespace content { 17 namespace content {
18 class DownloadItem; 18 class DownloadItem;
19 } 19 }
20 20
21 // This class provides an interface for functions which have different behaviors 21 namespace gfx {
22 // depending on the type of download. 22 class Font;
23 }
24
25 // This class is an abstraction for common UI tasks associated with a download.
23 class BaseDownloadItemModel { 26 class BaseDownloadItemModel {
24 public: 27 public:
25 explicit BaseDownloadItemModel(content::DownloadItem* download) 28 explicit BaseDownloadItemModel(content::DownloadItem* download)
26 : download_(download) { } 29 : download_(download) { }
27 virtual ~BaseDownloadItemModel() { } 30 virtual ~BaseDownloadItemModel() { }
28 31
29 // Cancel the task corresponding to the item. 32 // Cancel the task corresponding to the item.
30 virtual void CancelTask() = 0; 33 virtual void CancelTask() = 0;
31 34
32 // Get the status text to display. 35 // Get the status text to display.
33 virtual string16 GetStatusText() = 0; 36 virtual string16 GetStatusText() = 0;
34 37
38 // Get the warning text to display for a dangerous download. The |base_width|
39 // is the maximum width of an embedded filename (if there is one). The metrics
40 // for the filename will be based on |font|.
41 virtual string16 GetWarningText(const gfx::Font& font, int base_width) = 0;
Randy Smith (Not in Mondays) 2012/03/01 21:34:45 When is this valid to call, in terms of IsDangerou
asanka 2012/03/01 21:55:33 It's only valid to call when IsDangerous() is true
42
43 // Is this considered a malicious download?
44 virtual bool IsMalicious() = 0;
45
46 // Is this considered a dangerous download?
47 virtual bool IsDangerous() = 0;
48
35 content::DownloadItem* download() { return download_; } 49 content::DownloadItem* download() { return download_; }
36 50
37 protected: 51 protected:
38 content::DownloadItem* download_; 52 content::DownloadItem* download_;
39 }; 53 };
40 54
41 // This class is a model class for DownloadItemView. It provides functionality 55 // This class is a model class for DownloadItemView. It provides functionality
42 // for canceling the downloading, and also the text for displaying downloading 56 // for canceling the downloading, and also the text for displaying downloading
43 // status. 57 // status.
44 class DownloadItemModel : public BaseDownloadItemModel { 58 class DownloadItemModel : public BaseDownloadItemModel {
Randy Smith (Not in Mondays) 2012/03/01 21:34:45 Not really part of this CL, but remind me of the i
asanka 2012/03/01 21:55:33 BaseDownloadItemModel and DownloadItemModel are bo
Randy Smith (Not in Mondays) 2012/03/01 22:02:32 That would make sense to me; at a minimum we shoul
asanka 2012/03/02 17:45:16 Done.
45 public: 59 public:
46 explicit DownloadItemModel(content::DownloadItem* download); 60 explicit DownloadItemModel(content::DownloadItem* download);
47 virtual ~DownloadItemModel() { } 61 virtual ~DownloadItemModel() { }
48 62
49 // Cancel the downloading. 63 // BaseDownloadItemModel
50 virtual void CancelTask() OVERRIDE; 64 virtual void CancelTask() OVERRIDE;
51
52 // Get downloading status text.
53 virtual string16 GetStatusText() OVERRIDE; 65 virtual string16 GetStatusText() OVERRIDE;
66 virtual string16 GetWarningText(const gfx::Font& font,
67 int base_width) OVERRIDE;
68 virtual bool IsMalicious() OVERRIDE;
69 virtual bool IsDangerous() OVERRIDE;
54 70
55 private: 71 private:
56 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); 72 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel);
57 }; 73 };
58 74
59 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 75 #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