Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 weak_ptr_factory_.GetWeakPtr())); | 127 weak_ptr_factory_.GetWeakPtr())); |
| 128 web_ui()->RegisterMessageCallback("clearAll", | 128 web_ui()->RegisterMessageCallback("clearAll", |
| 129 base::Bind(&MdDownloadsDOMHandler::HandleClearAll, | 129 base::Bind(&MdDownloadsDOMHandler::HandleClearAll, |
| 130 weak_ptr_factory_.GetWeakPtr())); | 130 weak_ptr_factory_.GetWeakPtr())); |
| 131 web_ui()->RegisterMessageCallback("openDownloadsFolder", | 131 web_ui()->RegisterMessageCallback("openDownloadsFolder", |
| 132 base::Bind(&MdDownloadsDOMHandler::HandleOpenDownloadsFolder, | 132 base::Bind(&MdDownloadsDOMHandler::HandleOpenDownloadsFolder, |
| 133 weak_ptr_factory_.GetWeakPtr())); | 133 weak_ptr_factory_.GetWeakPtr())); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void MdDownloadsDOMHandler::OnJavascriptAllowed() { | 136 void MdDownloadsDOMHandler::OnJavascriptAllowed() { |
| 137 list_tracker_.StartAndSendChunk(); | 137 // The list tracker is started with the StartAndSendChunk method call |
| 138 // within the HandleGetDownloads handler. StartAndSendChunk should not be | |
| 139 // called here as it must be called each time the handler is called. | |
| 138 } | 140 } |
|
Dan Beam
2016/05/03 04:11:38
just remove this method, IMO
tommycli
2016/05/03 16:26:05
Done.
| |
| 139 | 141 |
| 140 void MdDownloadsDOMHandler::OnJavascriptDisallowed() { | 142 void MdDownloadsDOMHandler::OnJavascriptDisallowed() { |
| 141 list_tracker_.Stop(); | 143 list_tracker_.Stop(); |
| 142 list_tracker_.Reset(); | 144 list_tracker_.Reset(); |
| 143 CheckForRemovedFiles(); | 145 CheckForRemovedFiles(); |
| 144 } | 146 } |
| 145 | 147 |
| 146 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { | 148 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { |
| 149 AllowJavascript(); | |
| 150 | |
| 147 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); | 151 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); |
| 148 | 152 |
| 149 bool terms_changed = list_tracker_.SetSearchTerms(*args); | 153 bool terms_changed = list_tracker_.SetSearchTerms(*args); |
| 150 if (terms_changed) | 154 if (terms_changed) |
| 151 list_tracker_.Reset(); | 155 list_tracker_.Reset(); |
| 152 | 156 |
| 153 AllowJavascript(); | 157 list_tracker_.StartAndSendChunk(); |
| 154 } | 158 } |
| 155 | 159 |
| 156 void MdDownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) { | 160 void MdDownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) { |
| 157 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE); | 161 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE); |
| 158 content::DownloadItem* file = GetDownloadByValue(args); | 162 content::DownloadItem* file = GetDownloadByValue(args); |
| 159 if (file) | 163 if (file) |
| 160 file->OpenDownload(); | 164 file->OpenDownload(); |
| 161 } | 165 } |
| 162 | 166 |
| 163 void MdDownloadsDOMHandler::HandleDrag(const base::ListValue* args) { | 167 void MdDownloadsDOMHandler::HandleDrag(const base::ListValue* args) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { | 418 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { |
| 415 return web_ui()->GetWebContents(); | 419 return web_ui()->GetWebContents(); |
| 416 } | 420 } |
| 417 | 421 |
| 418 void MdDownloadsDOMHandler::CheckForRemovedFiles() { | 422 void MdDownloadsDOMHandler::CheckForRemovedFiles() { |
| 419 if (GetMainNotifierManager()) | 423 if (GetMainNotifierManager()) |
| 420 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); | 424 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); |
| 421 if (GetOriginalNotifierManager()) | 425 if (GetOriginalNotifierManager()) |
| 422 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); | 426 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); |
| 423 } | 427 } |
| OLD | NEW |