• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/basictypes.h"
12 #include "base/string16.h"
13 
14 class DownloadItem;
15 class SavePackage;
16 
17 // This class provides an interface for functions which have different behaviors
18 // depending on the type of download.
19 class BaseDownloadItemModel {
20  public:
BaseDownloadItemModel(DownloadItem * download)21   explicit BaseDownloadItemModel(DownloadItem* download)
22       : download_(download) { }
~BaseDownloadItemModel()23   virtual ~BaseDownloadItemModel() { }
24 
25   // Cancel the task corresponding to the item.
26   virtual void CancelTask() = 0;
27 
28   // Get the status text to display.
29   virtual string16 GetStatusText() = 0;
30 
download()31   DownloadItem* download() { return download_; }
32 
33  protected:
34   DownloadItem* download_;
35 };
36 
37 // This class is a model class for DownloadItemView. It provides functionality
38 // for canceling the downloading, and also the text for displaying downloading
39 // status.
40 class DownloadItemModel : public BaseDownloadItemModel {
41  public:
42   explicit DownloadItemModel(DownloadItem* download);
~DownloadItemModel()43   virtual ~DownloadItemModel() { }
44 
45   // Cancel the downloading.
46   virtual void CancelTask();
47 
48   // Get downloading status text.
49   virtual string16 GetStatusText();
50 
51  private:
52   DISALLOW_COPY_AND_ASSIGN(DownloadItemModel);
53 };
54 
55 // This class is a model class for DownloadItemView. It provides cancel
56 // functionality for saving page, and also the text for displaying saving
57 // status.
58 class SavePageModel : public BaseDownloadItemModel {
59  public:
60   SavePageModel(SavePackage* save, DownloadItem* download);
~SavePageModel()61   virtual ~SavePageModel() { }
62 
63   // Cancel the page saving.
64   virtual void CancelTask();
65 
66   // Get page saving status text.
67   virtual string16 GetStatusText();
68 
69  private:
70   // Saving page management.
71   SavePackage* save_;
72 
73   DISALLOW_COPY_AND_ASSIGN(SavePageModel);
74 };
75 
76 #endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
77