| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 weak_ptr_factory_.GetWeakPtr())); | 124 weak_ptr_factory_.GetWeakPtr())); |
| 125 web_ui()->RegisterMessageCallback("cancel", | 125 web_ui()->RegisterMessageCallback("cancel", |
| 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 |
| 135 Observe(GetWebUIWebContents()); |
| 134 } | 136 } |
| 135 | 137 |
| 136 void MdDownloadsDOMHandler::OnJavascriptDisallowed() { | 138 void MdDownloadsDOMHandler::OnJavascriptDisallowed() { |
| 137 list_tracker_.Stop(); | 139 list_tracker_.Stop(); |
| 138 list_tracker_.Reset(); | 140 list_tracker_.Reset(); |
| 139 CheckForRemovedFiles(); | 141 CheckForRemovedFiles(); |
| 140 } | 142 } |
| 141 | 143 |
| 144 void MdDownloadsDOMHandler::RenderProcessGone(base::TerminationStatus status) { |
| 145 // TODO(dbeam): WebUI + WebUIMessageHandler should do this automatically. |
| 146 // http://crbug.com/610450 |
| 147 DisallowJavascript(); |
| 148 } |
| 149 |
| 142 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { | 150 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { |
| 143 AllowJavascript(); | 151 AllowJavascript(); |
| 144 | 152 |
| 145 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); | 153 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); |
| 146 | 154 |
| 147 bool terms_changed = list_tracker_.SetSearchTerms(*args); | 155 bool terms_changed = list_tracker_.SetSearchTerms(*args); |
| 148 if (terms_changed) | 156 if (terms_changed) |
| 149 list_tracker_.Reset(); | 157 list_tracker_.Reset(); |
| 150 | 158 |
| 151 list_tracker_.StartAndSendChunk(); | 159 list_tracker_.StartAndSendChunk(); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { | 420 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { |
| 413 return web_ui()->GetWebContents(); | 421 return web_ui()->GetWebContents(); |
| 414 } | 422 } |
| 415 | 423 |
| 416 void MdDownloadsDOMHandler::CheckForRemovedFiles() { | 424 void MdDownloadsDOMHandler::CheckForRemovedFiles() { |
| 417 if (GetMainNotifierManager()) | 425 if (GetMainNotifierManager()) |
| 418 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); | 426 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); |
| 419 if (GetOriginalNotifierManager()) | 427 if (GetOriginalNotifierManager()) |
| 420 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); | 428 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); |
| 421 } | 429 } |
| OLD | NEW |