| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 base::Bind(&MdDownloadsDOMHandler::HandleCancel, | 126 base::Bind(&MdDownloadsDOMHandler::HandleCancel, |
| 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() { | |
| 137 list_tracker_.StartAndSendChunk(); | |
| 138 } | |
| 139 | |
| 140 void MdDownloadsDOMHandler::OnJavascriptDisallowed() { | 136 void MdDownloadsDOMHandler::OnJavascriptDisallowed() { |
| 141 list_tracker_.Stop(); | 137 list_tracker_.Stop(); |
| 142 list_tracker_.Reset(); | 138 list_tracker_.Reset(); |
| 143 CheckForRemovedFiles(); | 139 CheckForRemovedFiles(); |
| 144 } | 140 } |
| 145 | 141 |
| 146 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { | 142 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { |
| 143 AllowJavascript(); |
| 144 |
| 147 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); | 145 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); |
| 148 | 146 |
| 149 bool terms_changed = list_tracker_.SetSearchTerms(*args); | 147 bool terms_changed = list_tracker_.SetSearchTerms(*args); |
| 150 if (terms_changed) | 148 if (terms_changed) |
| 151 list_tracker_.Reset(); | 149 list_tracker_.Reset(); |
| 152 | 150 |
| 153 AllowJavascript(); | 151 list_tracker_.StartAndSendChunk(); |
| 154 } | 152 } |
| 155 | 153 |
| 156 void MdDownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) { | 154 void MdDownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) { |
| 157 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE); | 155 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE); |
| 158 content::DownloadItem* file = GetDownloadByValue(args); | 156 content::DownloadItem* file = GetDownloadByValue(args); |
| 159 if (file) | 157 if (file) |
| 160 file->OpenDownload(); | 158 file->OpenDownload(); |
| 161 } | 159 } |
| 162 | 160 |
| 163 void MdDownloadsDOMHandler::HandleDrag(const base::ListValue* args) { | 161 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() { | 412 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { |
| 415 return web_ui()->GetWebContents(); | 413 return web_ui()->GetWebContents(); |
| 416 } | 414 } |
| 417 | 415 |
| 418 void MdDownloadsDOMHandler::CheckForRemovedFiles() { | 416 void MdDownloadsDOMHandler::CheckForRemovedFiles() { |
| 419 if (GetMainNotifierManager()) | 417 if (GetMainNotifierManager()) |
| 420 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); | 418 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); |
| 421 if (GetOriginalNotifierManager()) | 419 if (GetOriginalNotifierManager()) |
| 422 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); | 420 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); |
| 423 } | 421 } |
| OLD | NEW |