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

Side by Side Diff: chrome/browser/dom_ui/downloads_ui.h

Issue 20110: Initial checkin of the HTML downloads UI. It's not yet complete (lacking... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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_DOM_UI_DOWNLOADS_UI_H_
6 #define CHROME_BROWSER_DOM_UI_DOWNLOADS_UI_H_
7
8 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
9 #include "chrome/browser/dom_ui/dom_ui.h"
10 #include "chrome/browser/dom_ui/dom_ui_contents.h"
11 #include "chrome/browser/download/download_manager.h"
12
13 class GURL;
14
15 class DownloadsUIHTMLSource : public ChromeURLDataManager::DataSource {
16 public:
17 DownloadsUIHTMLSource();
18
19 // Called when the network layer has requested a resource underneath
20 // the path we registered.
21 virtual void StartDataRequest(const std::string& path, int request_id);
22 virtual std::string GetMimeType(const std::string&) const {
23 return "text/html";
24 }
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(DownloadsUIHTMLSource);
28 };
29
30 // The handler for Javascript messages related to the "downloads" view,
31 // also observes changes to the download manager.
32 class DownloadsDOMHandler : public DOMMessageHandler,
33 public DownloadManager::Observer,
34 public DownloadItem::Observer {
35 public:
36 explicit DownloadsDOMHandler(DOMUI* dom_ui, DownloadManager* dlm);
37 virtual ~DownloadsDOMHandler();
38
39 void Init();
40
41 // DownloadItem::Observer interface
42 virtual void OnDownloadUpdated(DownloadItem* download);
43
44 // DownloadManager::Observer interface
45 virtual void ModelChanged();
46 virtual void SetDownloads(std::vector<DownloadItem*>& downloads);
47
48 // Callback for the "getDownloads" message.
49 void HandleGetDownloads(const Value* value);
50
51 // Callback for the "openFile" message - opens the file in the shell.
52 void HandleOpenFile(const Value* value);
53
54 // Callback for the "drag" message - initiates a file object drag.
55 void HandleDrag(const Value* value);
56
57 // Callback for the "saveDangerous" message - specifies that the user
58 // wishes to save a dangerous file.
59 void HandleSaveDangerous(const Value* value);
60
61 // Callback for the "discardDangerous" message - specifies that the user
62 // wishes to discard (remove) a dangerous file.
63 void HandleDiscardDangerous(const Value* value);
64
65 // Callback for the "show" message - shows the file in explorer.
66 void HandleShow(const Value* value);
67
68 // Callback for the "pause" message - pauses the file download.
69 void HandlePause(const Value* value);
70
71 // Callback for the "cancel" message - cancels the download.
72 void HandleCancel(const Value* value);
73
74 private:
75 // Send the current list of downloads to the page.
76 void SendCurrentDownloads();
77
78 // Creates a representation of a download in a format that the downloads
79 // HTML page can understand.
80 DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id);
81
82 // Clear all download items and their observers.
83 void ClearDownloadItems();
84
85 // Return the download that corresponds to a given id.
86 DownloadItem* GetDownloadById(int id);
87
88 // Current search text.
89 std::wstring search_text_;
90
91 // Our model
92 DownloadManager* download_manager_;
93
94 // The current set of visible DownloadItems for this view received from the
95 // DownloadManager. DownloadManager owns the DownloadItems. The vector is
96 // kept in order, sorted by ascending start time.
97 typedef std::vector<DownloadItem*> OrderedDownloads;
98 OrderedDownloads download_items_;
99
100 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler);
101 };
102
103 class DownloadsUI : public DOMUI {
104 public:
105 explicit DownloadsUI(DOMUIContents* contents);
106
107 // Return the URL for the front page of this UI.
108 static GURL GetBaseURL();
109
110 // DOMUI Implementation
111 virtual void Init();
112
113 private:
114 DOMUIContents* contents_;
115
116 DISALLOW_COPY_AND_ASSIGN(DownloadsUI);
117 };
118
119 #endif // CHROME_BROWSER_DOM_UI_DOWNLOADS_UI_H_
120
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698