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 if (status != base::TERMINATION_STATUS_NORMAL_TERMINATION && | |
tommycli
2016/05/09 17:54:35
Does using WebContents::IsCrashed() work here inst
Dan Beam
2016/05/09 18:29:32
Done.
| |
146 status != base::TERMINATION_STATUS_STILL_RUNNING) { | |
147 // TODO(dbeam): WebUI + WebUIMessageHandler should do this automatically. | |
148 DisallowJavascript(); | |
149 } | |
150 } | |
151 | |
142 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { | 152 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { |
143 AllowJavascript(); | 153 AllowJavascript(); |
144 | 154 |
145 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); | 155 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); |
146 | 156 |
147 bool terms_changed = list_tracker_.SetSearchTerms(*args); | 157 bool terms_changed = list_tracker_.SetSearchTerms(*args); |
148 if (terms_changed) | 158 if (terms_changed) |
149 list_tracker_.Reset(); | 159 list_tracker_.Reset(); |
150 | 160 |
151 list_tracker_.StartAndSendChunk(); | 161 list_tracker_.StartAndSendChunk(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { | 422 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { |
413 return web_ui()->GetWebContents(); | 423 return web_ui()->GetWebContents(); |
414 } | 424 } |
415 | 425 |
416 void MdDownloadsDOMHandler::CheckForRemovedFiles() { | 426 void MdDownloadsDOMHandler::CheckForRemovedFiles() { |
417 if (GetMainNotifierManager()) | 427 if (GetMainNotifierManager()) |
418 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); | 428 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); |
419 if (GetOriginalNotifierManager()) | 429 if (GetOriginalNotifierManager()) |
420 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); | 430 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); |
421 } | 431 } |
OLD | NEW |