| Index: chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h
|
| diff --git a/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h b/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h
|
| index a724d6db75b9c62faede384484eb4cfdc3f70e72..0aee5da13199ab83d3003d64c4f80e547e7e62dd 100644
|
| --- a/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h
|
| +++ b/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h
|
| @@ -8,10 +8,13 @@
|
| #include <set>
|
| #include <vector>
|
|
|
| +#include "base/compiler_specific.h"
|
| #include "base/macros.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "chrome/browser/download/all_download_item_notifier.h"
|
| #include "chrome/browser/download/download_danger_prompt.h"
|
| -#include "chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h"
|
| +#include "content/public/browser/download_item.h"
|
| +#include "content/public/browser/download_manager.h"
|
| #include "content/public/browser/web_ui_message_handler.h"
|
|
|
| namespace base {
|
| @@ -19,25 +22,29 @@
|
| }
|
|
|
| namespace content {
|
| -class DownloadItem;
|
| -class DownloadManager;
|
| -class RenderViewHost;
|
| class WebContents;
|
| -class WebUI;
|
| }
|
|
|
| // The handler for Javascript messages related to the "downloads" view,
|
| // also observes changes to the download manager.
|
| -class MdDownloadsDOMHandler : public content::WebUIMessageHandler {
|
| +class MdDownloadsDOMHandler : public content::WebUIMessageHandler,
|
| + public AllDownloadItemNotifier::Observer {
|
| public:
|
| - MdDownloadsDOMHandler(content::DownloadManager* download_manager,
|
| - content::WebUI* web_ui);
|
| + explicit MdDownloadsDOMHandler(content::DownloadManager* download_manager);
|
| ~MdDownloadsDOMHandler() override;
|
| +
|
| + void Init();
|
|
|
| // WebUIMessageHandler implementation.
|
| void RegisterMessages() override;
|
|
|
| - void RenderViewReused(content::RenderViewHost* render_view_host);
|
| + // AllDownloadItemNotifier::Observer interface
|
| + void OnDownloadCreated(content::DownloadManager* manager,
|
| + content::DownloadItem* download_item) override;
|
| + void OnDownloadUpdated(content::DownloadManager* manager,
|
| + content::DownloadItem* download_item) override;
|
| + void OnDownloadRemoved(content::DownloadManager* manager,
|
| + content::DownloadItem* download_item) override;
|
|
|
| // Callback for the "getDownloads" message.
|
| void HandleGetDownloads(const base::ListValue* args);
|
| @@ -87,6 +94,12 @@
|
| // depend on WebUI. The other methods that depend on WebUI are
|
| // RegisterMessages() and HandleDrag().
|
| virtual content::WebContents* GetWebUIWebContents();
|
| + virtual void CallUpdateAll(const base::ListValue& list);
|
| + virtual void CallUpdateItem(const base::DictionaryValue& item);
|
| +
|
| + // Schedules a call to SendCurrentDownloads() in the next message loop
|
| + // iteration. Protected rather than private for use in tests.
|
| + void ScheduleSendCurrentDownloads();
|
|
|
| // Actually remove downloads with an ID in |removals_|. This cannot be undone.
|
| void FinalizeRemovals();
|
| @@ -102,6 +115,9 @@
|
| // Convenience method to call |original_notifier_->GetManager()| while
|
| // null-checking |original_notifier_|.
|
| content::DownloadManager* GetOriginalNotifierManager() const;
|
| +
|
| + // Sends the current list of downloads to the page.
|
| + void SendCurrentDownloads();
|
|
|
| // Displays a native prompt asking the user for confirmation after accepting
|
| // the dangerous download specified by |dangerous|. The function returns
|
| @@ -128,10 +144,28 @@
|
| // Remove all downloads in |to_remove| with the ability to undo removal later.
|
| void RemoveDownloads(const DownloadVector& to_remove);
|
|
|
| - DownloadsListTracker list_tracker_;
|
| + // Weak reference to the DownloadManager this class was constructed with. You
|
| + // should probably be using use Get{Main,Original}NotifierManager() instead.
|
| + content::DownloadManager* download_manager_;
|
| +
|
| + // Current search terms.
|
| + scoped_ptr<base::ListValue> search_terms_;
|
| +
|
| + // Notifies OnDownload*() and provides safe access to the DownloadManager.
|
| + scoped_ptr<AllDownloadItemNotifier> main_notifier_;
|
| +
|
| + // If |main_notifier_| observes an incognito profile, then this observes the
|
| + // DownloadManager for the original profile; otherwise, this is NULL.
|
| + scoped_ptr<AllDownloadItemNotifier> original_notifier_;
|
|
|
| // IDs of downloads to remove when this handler gets deleted.
|
| std::vector<IdSet> removals_;
|
| +
|
| + // Whether a call to SendCurrentDownloads() is currently scheduled.
|
| + bool update_scheduled_;
|
| +
|
| + // IDs of new downloads that the page doesn't know about yet.
|
| + IdSet new_downloads_;
|
|
|
| base::WeakPtrFactory<MdDownloadsDOMHandler> weak_ptr_factory_;
|
|
|
|
|