Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc

Issue 1896463003: WebUI: Add JavaScript lifecycle-control to WebUIMessageHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::RenderViewReused() { 136 void MdDownloadsDOMHandler::OnJavascriptAllowed() {
137 list_tracker_.StartAndSendChunk();
138 }
139
140 void MdDownloadsDOMHandler::OnJavascriptDisallowed() {
137 list_tracker_.Stop(); 141 list_tracker_.Stop();
138 list_tracker_.Reset(); 142 list_tracker_.Reset();
139 CheckForRemovedFiles(); 143 CheckForRemovedFiles();
Dan Beam 2016/04/18 23:13:20 technically we want to check for removed files on
tommycli 2016/04/19 17:45:37 Hmm... I would imagine OnJavascriptDisallowed to b
140 } 144 }
141 145
142 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { 146 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) {
143 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); 147 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS);
144 148
145 bool terms_changed = list_tracker_.SetSearchTerms(*args); 149 bool terms_changed = list_tracker_.SetSearchTerms(*args);
146 if (terms_changed) 150 if (terms_changed)
147 list_tracker_.Reset(); 151 list_tracker_.Reset();
148 152
149 list_tracker_.StartAndSendChunk(); 153 AllowJavascript();
150 } 154 }
151 155
152 void MdDownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) { 156 void MdDownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) {
153 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE); 157 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE);
154 content::DownloadItem* file = GetDownloadByValue(args); 158 content::DownloadItem* file = GetDownloadByValue(args);
155 if (file) 159 if (file)
156 file->OpenDownload(); 160 file->OpenDownload();
157 } 161 }
158 162
159 void MdDownloadsDOMHandler::HandleDrag(const base::ListValue* args) { 163 void MdDownloadsDOMHandler::HandleDrag(const base::ListValue* args) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { 414 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() {
411 return web_ui()->GetWebContents(); 415 return web_ui()->GetWebContents();
412 } 416 }
413 417
414 void MdDownloadsDOMHandler::CheckForRemovedFiles() { 418 void MdDownloadsDOMHandler::CheckForRemovedFiles() {
415 if (GetMainNotifierManager()) 419 if (GetMainNotifierManager())
416 GetMainNotifierManager()->CheckForHistoryFilesRemoval(); 420 GetMainNotifierManager()->CheckForHistoryFilesRemoval();
417 if (GetOriginalNotifierManager()) 421 if (GetOriginalNotifierManager())
418 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval(); 422 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval();
419 } 423 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698