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

Side by Side Diff: chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h

Issue 2100443003: MD Downloads: "Clear All" should remove dangerous downloads for good (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.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_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 protected: 90 protected:
91 // These methods are for mocking so that most of this class does not actually 91 // These methods are for mocking so that most of this class does not actually
92 // depend on WebUI. The other methods that depend on WebUI are 92 // depend on WebUI. The other methods that depend on WebUI are
93 // RegisterMessages() and HandleDrag(). 93 // RegisterMessages() and HandleDrag().
94 virtual content::WebContents* GetWebUIWebContents(); 94 virtual content::WebContents* GetWebUIWebContents();
95 95
96 // Actually remove downloads with an ID in |removals_|. This cannot be undone. 96 // Actually remove downloads with an ID in |removals_|. This cannot be undone.
97 void FinalizeRemovals(); 97 void FinalizeRemovals();
98 98
99 using DownloadVector = std::vector<content::DownloadItem*>;
100
101 // Remove all downloads in |to_remove|. Safe downloads can be revived,
102 // dangerous ones are immediately removed. Protected for testing.
103 void RemoveDownloads(const DownloadVector& to_remove);
104
99 private: 105 private:
100 using IdSet = std::set<uint32_t>; 106 using IdSet = std::set<uint32_t>;
101 using DownloadVector = std::vector<content::DownloadItem*>;
102 107
103 // Convenience method to call |main_notifier_->GetManager()| while 108 // Convenience method to call |main_notifier_->GetManager()| while
104 // null-checking |main_notifier_|. 109 // null-checking |main_notifier_|.
105 content::DownloadManager* GetMainNotifierManager() const; 110 content::DownloadManager* GetMainNotifierManager() const;
106 111
107 // Convenience method to call |original_notifier_->GetManager()| while 112 // Convenience method to call |original_notifier_->GetManager()| while
108 // null-checking |original_notifier_|. 113 // null-checking |original_notifier_|.
109 content::DownloadManager* GetOriginalNotifierManager() const; 114 content::DownloadManager* GetOriginalNotifierManager() const;
110 115
111 // Displays a native prompt asking the user for confirmation after accepting 116 // Displays a native prompt asking the user for confirmation after accepting
(...skipping 11 matching lines...) Expand all
123 // Returns true if the records of any downloaded items are allowed (and able) 128 // Returns true if the records of any downloaded items are allowed (and able)
124 // to be deleted. 129 // to be deleted.
125 bool IsDeletingHistoryAllowed(); 130 bool IsDeletingHistoryAllowed();
126 131
127 // Returns the download that is referred to in a given value. 132 // Returns the download that is referred to in a given value.
128 content::DownloadItem* GetDownloadByValue(const base::ListValue* args); 133 content::DownloadItem* GetDownloadByValue(const base::ListValue* args);
129 134
130 // Returns the download with |id| or NULL if it doesn't exist. 135 // Returns the download with |id| or NULL if it doesn't exist.
131 content::DownloadItem* GetDownloadById(uint32_t id); 136 content::DownloadItem* GetDownloadById(uint32_t id);
132 137
133 // Remove all downloads in |to_remove| with the ability to undo removal later. 138 // Removes the download specified by an ID from JavaScript in |args|.
134 void RemoveDownloads(const DownloadVector& to_remove); 139 void RemoveDownloadInArgs(const base::ListValue* args);
135 140
136 // Checks whether a download's file was removed from its original location. 141 // Checks whether a download's file was removed from its original location.
137 void CheckForRemovedFiles(); 142 void CheckForRemovedFiles();
138 143
139 DownloadsListTracker list_tracker_; 144 DownloadsListTracker list_tracker_;
140 145
141 // IDs of downloads to remove when this handler gets deleted. 146 // IDs of downloads to remove when this handler gets deleted.
142 std::vector<IdSet> removals_; 147 std::vector<IdSet> removals_;
143 148
144 base::WeakPtrFactory<MdDownloadsDOMHandler> weak_ptr_factory_; 149 base::WeakPtrFactory<MdDownloadsDOMHandler> weak_ptr_factory_;
145 150
146 DISALLOW_COPY_AND_ASSIGN(MdDownloadsDOMHandler); 151 DISALLOW_COPY_AND_ASSIGN(MdDownloadsDOMHandler);
147 }; 152 };
148 153
149 #endif // CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ 154 #endif // CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698