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

Side by Side Diff: chrome/browser/ui/webui/downloads_dom_handler.h

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
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_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/scoped_callback_factory.h" 11 #include "base/memory/scoped_callback_factory.h"
12 #include "chrome/browser/download/download_item.h" 12 #include "chrome/browser/download/download_item.h"
13 #include "chrome/browser/download/download_manager.h" 13 #include "chrome/browser/download/download_manager.h"
14 #include "content/browser/webui/web_ui.h" 14 #include "content/browser/webui/web_ui.h"
15 15
16 namespace base {
16 class ListValue; 17 class ListValue;
18 }
17 19
18 // The handler for Javascript messages related to the "downloads" view, 20 // The handler for Javascript messages related to the "downloads" view,
19 // also observes changes to the download manager. 21 // also observes changes to the download manager.
20 class DownloadsDOMHandler : public WebUIMessageHandler, 22 class DownloadsDOMHandler : public WebUIMessageHandler,
21 public DownloadManager::Observer, 23 public DownloadManager::Observer,
22 public DownloadItem::Observer { 24 public DownloadItem::Observer {
23 public: 25 public:
24 explicit DownloadsDOMHandler(DownloadManager* dlm); 26 explicit DownloadsDOMHandler(DownloadManager* dlm);
25 virtual ~DownloadsDOMHandler(); 27 virtual ~DownloadsDOMHandler();
26 28
27 void Init(); 29 void Init();
28 30
29 // WebUIMessageHandler implementation. 31 // WebUIMessageHandler implementation.
30 virtual void RegisterMessages(); 32 virtual void RegisterMessages();
31 33
32 // DownloadItem::Observer interface 34 // DownloadItem::Observer interface
33 virtual void OnDownloadUpdated(DownloadItem* download); 35 virtual void OnDownloadUpdated(DownloadItem* download);
34 virtual void OnDownloadOpened(DownloadItem* download) { } 36 virtual void OnDownloadOpened(DownloadItem* download) { }
35 37
36 // DownloadManager::Observer interface 38 // DownloadManager::Observer interface
37 virtual void ModelChanged(); 39 virtual void ModelChanged();
38 40
39 // Callback for the "getDownloads" message. 41 // Callback for the "getDownloads" message.
40 void HandleGetDownloads(const ListValue* args); 42 void HandleGetDownloads(const base::ListValue* args);
41 43
42 // Callback for the "openFile" message - opens the file in the shell. 44 // Callback for the "openFile" message - opens the file in the shell.
43 void HandleOpenFile(const ListValue* args); 45 void HandleOpenFile(const base::ListValue* args);
44 46
45 // Callback for the "drag" message - initiates a file object drag. 47 // Callback for the "drag" message - initiates a file object drag.
46 void HandleDrag(const ListValue* args); 48 void HandleDrag(const base::ListValue* args);
47 49
48 // Callback for the "saveDangerous" message - specifies that the user 50 // Callback for the "saveDangerous" message - specifies that the user
49 // wishes to save a dangerous file. 51 // wishes to save a dangerous file.
50 void HandleSaveDangerous(const ListValue* args); 52 void HandleSaveDangerous(const base::ListValue* args);
51 53
52 // Callback for the "discardDangerous" message - specifies that the user 54 // Callback for the "discardDangerous" message - specifies that the user
53 // wishes to discard (remove) a dangerous file. 55 // wishes to discard (remove) a dangerous file.
54 void HandleDiscardDangerous(const ListValue* args); 56 void HandleDiscardDangerous(const base::ListValue* args);
55 57
56 // Callback for the "show" message - shows the file in explorer. 58 // Callback for the "show" message - shows the file in explorer.
57 void HandleShow(const ListValue* args); 59 void HandleShow(const base::ListValue* args);
58 60
59 // Callback for the "pause" message - pauses the file download. 61 // Callback for the "pause" message - pauses the file download.
60 void HandlePause(const ListValue* args); 62 void HandlePause(const base::ListValue* args);
61 63
62 // Callback for the "remove" message - removes the file download from shelf 64 // Callback for the "remove" message - removes the file download from shelf
63 // and list. 65 // and list.
64 void HandleRemove(const ListValue* args); 66 void HandleRemove(const base::ListValue* args);
65 67
66 // Callback for the "cancel" message - cancels the download. 68 // Callback for the "cancel" message - cancels the download.
67 void HandleCancel(const ListValue* args); 69 void HandleCancel(const base::ListValue* args);
68 70
69 // Callback for the "clearAll" message - clears all the downloads. 71 // Callback for the "clearAll" message - clears all the downloads.
70 void HandleClearAll(const ListValue* args); 72 void HandleClearAll(const base::ListValue* args);
71 73
72 private: 74 private:
73 // Send the current list of downloads to the page. 75 // Send the current list of downloads to the page.
74 void SendCurrentDownloads(); 76 void SendCurrentDownloads();
75 77
76 // Clear all download items and their observers. 78 // Clear all download items and their observers.
77 void ClearDownloadItems(); 79 void ClearDownloadItems();
78 80
79 // Return the download that corresponds to a given id. 81 // Return the download that corresponds to a given id.
80 DownloadItem* GetDownloadById(int id); 82 DownloadItem* GetDownloadById(int id);
81 83
82 // Return the download that is referred to in a given value. 84 // Return the download that is referred to in a given value.
83 DownloadItem* GetDownloadByValue(const ListValue* args); 85 DownloadItem* GetDownloadByValue(const base::ListValue* args);
84 86
85 // Current search text. 87 // Current search text.
86 std::wstring search_text_; 88 std::wstring search_text_;
87 89
88 // Our model 90 // Our model
89 DownloadManager* download_manager_; 91 DownloadManager* download_manager_;
90 92
91 // The current set of visible DownloadItems for this view received from the 93 // The current set of visible DownloadItems for this view received from the
92 // DownloadManager. DownloadManager owns the DownloadItems. The vector is 94 // DownloadManager. DownloadManager owns the DownloadItems. The vector is
93 // kept in order, sorted by ascending start time. 95 // kept in order, sorted by ascending start time.
94 // Note that when a download item is removed, the entry in the vector becomes 96 // Note that when a download item is removed, the entry in the vector becomes
95 // null. This should only be a transient state, as a ModelChanged() 97 // null. This should only be a transient state, as a ModelChanged()
96 // notification should follow close on the heels of such a change. 98 // notification should follow close on the heels of such a change.
97 typedef std::vector<DownloadItem*> OrderedDownloads; 99 typedef std::vector<DownloadItem*> OrderedDownloads;
98 OrderedDownloads download_items_; 100 OrderedDownloads download_items_;
99 101
100 base::ScopedCallbackFactory<DownloadsDOMHandler> callback_factory_; 102 base::ScopedCallbackFactory<DownloadsDOMHandler> callback_factory_;
101 103
102 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler); 104 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler);
103 }; 105 };
104 106
105 #endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ 107 #endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/cookies_tree_model_util.h ('k') | chrome/browser/ui/webui/history2_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698