| OLD | NEW |
| 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 #include "chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 MdDownloadsDOMHandler::MdDownloadsDOMHandler( | 77 MdDownloadsDOMHandler::MdDownloadsDOMHandler( |
| 78 content::DownloadManager* download_manager, content::WebUI* web_ui) | 78 content::DownloadManager* download_manager, content::WebUI* web_ui) |
| 79 : list_tracker_(download_manager, web_ui), | 79 : list_tracker_(download_manager, web_ui), |
| 80 weak_ptr_factory_(this) { | 80 weak_ptr_factory_(this) { |
| 81 // Create our fileicon data source. | 81 // Create our fileicon data source. |
| 82 Profile* profile = Profile::FromBrowserContext( | 82 Profile* profile = Profile::FromBrowserContext( |
| 83 download_manager->GetBrowserContext()); | 83 download_manager->GetBrowserContext()); |
| 84 content::URLDataSource::Add(profile, new FileIconSource()); | 84 content::URLDataSource::Add(profile, new FileIconSource()); |
| 85 CheckForRemovedFiles(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 MdDownloadsDOMHandler::~MdDownloadsDOMHandler() { | 88 MdDownloadsDOMHandler::~MdDownloadsDOMHandler() { |
| 88 FinalizeRemovals(); | 89 FinalizeRemovals(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 // MdDownloadsDOMHandler, public: --------------------------------------------- | 92 // MdDownloadsDOMHandler, public: --------------------------------------------- |
| 92 | 93 |
| 93 void MdDownloadsDOMHandler::RegisterMessages() { | 94 void MdDownloadsDOMHandler::RegisterMessages() { |
| 94 web_ui()->RegisterMessageCallback("getDownloads", | 95 web_ui()->RegisterMessageCallback("getDownloads", |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 weak_ptr_factory_.GetWeakPtr())); | 130 weak_ptr_factory_.GetWeakPtr())); |
| 130 web_ui()->RegisterMessageCallback("openDownloadsFolder", | 131 web_ui()->RegisterMessageCallback("openDownloadsFolder", |
| 131 base::Bind(&MdDownloadsDOMHandler::HandleOpenDownloadsFolder, | 132 base::Bind(&MdDownloadsDOMHandler::HandleOpenDownloadsFolder, |
| 132 weak_ptr_factory_.GetWeakPtr())); | 133 weak_ptr_factory_.GetWeakPtr())); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void MdDownloadsDOMHandler::RenderViewReused( | 136 void MdDownloadsDOMHandler::RenderViewReused( |
| 136 content::RenderViewHost* render_view_host) { | 137 content::RenderViewHost* render_view_host) { |
| 137 list_tracker_.Stop(); | 138 list_tracker_.Stop(); |
| 138 list_tracker_.Reset(); | 139 list_tracker_.Reset(); |
| 140 CheckForRemovedFiles(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { | 143 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { |
| 142 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); | 144 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); |
| 143 | 145 |
| 144 bool terms_changed = list_tracker_.SetSearchTerms(*args); | 146 bool terms_changed = list_tracker_.SetSearchTerms(*args); |
| 145 if (terms_changed) | 147 if (terms_changed) |
| 146 list_tracker_.Reset(); | 148 list_tracker_.Reset(); |
| 147 | 149 |
| 148 list_tracker_.StartAndSendChunk(); | 150 list_tracker_.StartAndSendChunk(); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 if (GetMainNotifierManager()) | 404 if (GetMainNotifierManager()) |
| 403 item = GetMainNotifierManager()->GetDownload(id); | 405 item = GetMainNotifierManager()->GetDownload(id); |
| 404 if (!item && GetOriginalNotifierManager()) | 406 if (!item && GetOriginalNotifierManager()) |
| 405 item = GetOriginalNotifierManager()->GetDownload(id); | 407 item = GetOriginalNotifierManager()->GetDownload(id); |
| 406 return item; | 408 return item; |
| 407 } | 409 } |
| 408 | 410 |
| 409 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { | 411 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { |
| 410 return web_ui()->GetWebContents(); | 412 return web_ui()->GetWebContents(); |
| 411 } | 413 } |
| 414 |
| 415 void MdDownloadsDOMHandler::CheckForRemovedFiles() { |
| 416 if (GetMainNotifierManager()) |
| 417 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); |
| 418 if (GetOriginalNotifierManager()) |
| 419 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); |
| 420 } |
| OLD | NEW |