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

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

Issue 1610483003: MD Downloads: check for removed files on page load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } // namespace 75 } // namespace
76 76
77 MdDownloadsDOMHandler::MdDownloadsDOMHandler( 77 MdDownloadsDOMHandler::MdDownloadsDOMHandler(
78 content::DownloadManager* download_manager, content::WebUI* web_ui) 78 content::DownloadManager* download_manager, content::WebUI* web_ui)
79 : list_tracker_(download_manager, web_ui), 79 : list_tracker_(download_manager, web_ui),
80 weak_ptr_factory_(this) { 80 weak_ptr_factory_(this) {
81 // Create our fileicon data source. 81 // Create our fileicon data source.
82 Profile* profile = Profile::FromBrowserContext( 82 Profile* profile = Profile::FromBrowserContext(
83 download_manager->GetBrowserContext()); 83 download_manager->GetBrowserContext());
84 content::URLDataSource::Add(profile, new FileIconSource()); 84 content::URLDataSource::Add(profile, new FileIconSource());
85 CheckForRemovedFiles();
85 } 86 }
86 87
87 MdDownloadsDOMHandler::~MdDownloadsDOMHandler() { 88 MdDownloadsDOMHandler::~MdDownloadsDOMHandler() {
88 FinalizeRemovals(); 89 FinalizeRemovals();
89 } 90 }
90 91
91 // MdDownloadsDOMHandler, public: --------------------------------------------- 92 // MdDownloadsDOMHandler, public: ---------------------------------------------
92 93
93 void MdDownloadsDOMHandler::RegisterMessages() { 94 void MdDownloadsDOMHandler::RegisterMessages() {
94 web_ui()->RegisterMessageCallback("getDownloads", 95 web_ui()->RegisterMessageCallback("getDownloads",
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 weak_ptr_factory_.GetWeakPtr())); 130 weak_ptr_factory_.GetWeakPtr()));
130 web_ui()->RegisterMessageCallback("openDownloadsFolder", 131 web_ui()->RegisterMessageCallback("openDownloadsFolder",
131 base::Bind(&MdDownloadsDOMHandler::HandleOpenDownloadsFolder, 132 base::Bind(&MdDownloadsDOMHandler::HandleOpenDownloadsFolder,
132 weak_ptr_factory_.GetWeakPtr())); 133 weak_ptr_factory_.GetWeakPtr()));
133 } 134 }
134 135
135 void MdDownloadsDOMHandler::RenderViewReused( 136 void MdDownloadsDOMHandler::RenderViewReused(
136 content::RenderViewHost* render_view_host) { 137 content::RenderViewHost* render_view_host) {
137 list_tracker_.Stop(); 138 list_tracker_.Stop();
138 list_tracker_.Reset(); 139 list_tracker_.Reset();
140 CheckForRemovedFiles();
139 } 141 }
140 142
141 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) { 143 void MdDownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) {
142 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS); 144 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS);
143 145
144 bool terms_changed = list_tracker_.SetSearchTerms(*args); 146 bool terms_changed = list_tracker_.SetSearchTerms(*args);
145 if (terms_changed) 147 if (terms_changed)
146 list_tracker_.Reset(); 148 list_tracker_.Reset();
147 149
148 list_tracker_.StartAndSendChunk(); 150 list_tracker_.StartAndSendChunk();
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (GetMainNotifierManager()) 404 if (GetMainNotifierManager())
403 item = GetMainNotifierManager()->GetDownload(id); 405 item = GetMainNotifierManager()->GetDownload(id);
404 if (!item && GetOriginalNotifierManager()) 406 if (!item && GetOriginalNotifierManager())
405 item = GetOriginalNotifierManager()->GetDownload(id); 407 item = GetOriginalNotifierManager()->GetDownload(id);
406 return item; 408 return item;
407 } 409 }
408 410
409 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() { 411 content::WebContents* MdDownloadsDOMHandler::GetWebUIWebContents() {
410 return web_ui()->GetWebContents(); 412 return web_ui()->GetWebContents();
411 } 413 }
414
415 void MdDownloadsDOMHandler::CheckForRemovedFiles() {
416 if (GetMainNotifierManager())
417 GetMainNotifierManager()->CheckForHistoryFilesRemoval();
418 if (GetOriginalNotifierManager())
419 GetOriginalNotifierManager()->CheckForHistoryFilesRemoval();
420 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698