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

Side by Side Diff: chrome/browser/ui/webui/downloads_dom_handler.cc

Issue 722953002: downloads: add the ability to undo download removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fixes Created 6 years 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/downloads_dom_handler.h" 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/i18n/time_formatting.h" 14 #include "base/i18n/time_formatting.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
19 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/supports_user_data.h"
21 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
22 #include "base/value_conversions.h" 24 #include "base/value_conversions.h"
23 #include "base/values.h" 25 #include "base/values.h"
24 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/download/download_crx_util.h" 27 #include "chrome/browser/download/download_crx_util.h"
26 #include "chrome/browser/download/download_danger_prompt.h" 28 #include "chrome/browser/download/download_danger_prompt.h"
27 #include "chrome/browser/download/download_history.h" 29 #include "chrome/browser/download/download_history.h"
28 #include "chrome/browser/download/download_item_model.h" 30 #include "chrome/browser/download/download_item_model.h"
29 #include "chrome/browser/download/download_prefs.h" 31 #include "chrome/browser/download/download_prefs.h"
30 #include "chrome/browser/download/download_query.h" 32 #include "chrome/browser/download/download_query.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 DOWNLOADS_DOM_EVENT_SHOW = 5, 70 DOWNLOADS_DOM_EVENT_SHOW = 5,
69 DOWNLOADS_DOM_EVENT_PAUSE = 6, 71 DOWNLOADS_DOM_EVENT_PAUSE = 6,
70 DOWNLOADS_DOM_EVENT_REMOVE = 7, 72 DOWNLOADS_DOM_EVENT_REMOVE = 7,
71 DOWNLOADS_DOM_EVENT_CANCEL = 8, 73 DOWNLOADS_DOM_EVENT_CANCEL = 8,
72 DOWNLOADS_DOM_EVENT_CLEAR_ALL = 9, 74 DOWNLOADS_DOM_EVENT_CLEAR_ALL = 9,
73 DOWNLOADS_DOM_EVENT_OPEN_FOLDER = 10, 75 DOWNLOADS_DOM_EVENT_OPEN_FOLDER = 10,
74 DOWNLOADS_DOM_EVENT_RESUME = 11, 76 DOWNLOADS_DOM_EVENT_RESUME = 11,
75 DOWNLOADS_DOM_EVENT_MAX 77 DOWNLOADS_DOM_EVENT_MAX
76 }; 78 };
77 79
80 static const char kKey[] = "DownloadsDOMHandlerData";
81
82 class DownloadsDOMHandlerData : public base::SupportsUserData::Data {
83 public:
84 static DownloadsDOMHandlerData* Get(content::DownloadItem* item) {
85 return static_cast<DownloadsDOMHandlerData*>(item->GetUserData(kKey));
86 }
87
88 static const DownloadsDOMHandlerData* Get(const content::DownloadItem* item) {
89 return static_cast<DownloadsDOMHandlerData*>(item->GetUserData(kKey));
90 }
91
92 static void Set(content::DownloadItem* item, DownloadsDOMHandlerData* data) {
93 item->SetUserData(kKey, data);
94 }
95
96 static DownloadsDOMHandlerData* Create(content::DownloadItem* item) {
97 DownloadsDOMHandlerData* data = new DownloadsDOMHandlerData;
98 item->SetUserData(kKey, data);
99 return data;
100 }
101
102 void set_is_removed(bool is_removed) { is_removed_ = is_removed; }
103 bool is_removed() const { return is_removed_; }
104
105 private:
106 bool is_removed_;
107 };
108
78 void CountDownloadsDOMEvents(DownloadsDOMEvent event) { 109 void CountDownloadsDOMEvents(DownloadsDOMEvent event) {
79 UMA_HISTOGRAM_ENUMERATION("Download.DOMEvent", 110 UMA_HISTOGRAM_ENUMERATION("Download.DOMEvent",
80 event, 111 event,
81 DOWNLOADS_DOM_EVENT_MAX); 112 DOWNLOADS_DOM_EVENT_MAX);
82 } 113 }
83 114
84 // Returns a string constant to be used as the |danger_type| value in 115 // Returns a string constant to be used as the |danger_type| value in
85 // CreateDownloadItemValue(). Only return strings for DANGEROUS_FILE, 116 // CreateDownloadItemValue(). Only return strings for DANGEROUS_FILE,
86 // DANGEROUS_URL, DANGEROUS_CONTENT, and UNCOMMON_CONTENT because the 117 // DANGEROUS_URL, DANGEROUS_CONTENT, and UNCOMMON_CONTENT because the
87 // |danger_type| value is only defined if the value of |state| is |DANGEROUS|. 118 // |danger_type| value is only defined if the value of |state| is |DANGEROUS|.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // any keys in file_value. 155 // any keys in file_value.
125 base::DictionaryValue* file_value = new base::DictionaryValue(); 156 base::DictionaryValue* file_value = new base::DictionaryValue();
126 157
127 file_value->SetInteger( 158 file_value->SetInteger(
128 "started", static_cast<int>(download_item->GetStartTime().ToTimeT())); 159 "started", static_cast<int>(download_item->GetStartTime().ToTimeT()));
129 file_value->SetString( 160 file_value->SetString(
130 "since_string", ui::TimeFormat::RelativeDate( 161 "since_string", ui::TimeFormat::RelativeDate(
131 download_item->GetStartTime(), NULL)); 162 download_item->GetStartTime(), NULL));
132 file_value->SetString( 163 file_value->SetString(
133 "date_string", base::TimeFormatShortDate(download_item->GetStartTime())); 164 "date_string", base::TimeFormatShortDate(download_item->GetStartTime()));
134 file_value->SetInteger("id", download_item->GetId()); 165 file_value->SetString("id", base::Uint64ToString(download_item->GetId()));
135 166
136 base::FilePath download_path(download_item->GetTargetFilePath()); 167 base::FilePath download_path(download_item->GetTargetFilePath());
137 file_value->Set("file_path", base::CreateFilePathValue(download_path)); 168 file_value->Set("file_path", base::CreateFilePathValue(download_path));
138 file_value->SetString("file_url", 169 file_value->SetString("file_url",
139 net::FilePathToFileURL(download_path).spec()); 170 net::FilePathToFileURL(download_path).spec());
140 171
141 extensions::DownloadedByExtension* by_ext = 172 extensions::DownloadedByExtension* by_ext =
142 extensions::DownloadedByExtension::Get(download_item); 173 extensions::DownloadedByExtension::Get(download_item);
143 if (by_ext) { 174 if (by_ext) {
144 file_value->SetString("by_ext_id", by_ext->id()); 175 file_value->SetString("by_ext_id", by_ext->id());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 file_value->SetString("state", "CANCELLED"); 254 file_value->SetString("state", "CANCELLED");
224 file_value->SetBoolean("retry", true); 255 file_value->SetBoolean("retry", true);
225 break; 256 break;
226 257
227 case content::DownloadItem::COMPLETE: 258 case content::DownloadItem::COMPLETE:
228 DCHECK(!download_item->IsDangerous()); 259 DCHECK(!download_item->IsDangerous());
229 file_value->SetString("state", "COMPLETE"); 260 file_value->SetString("state", "COMPLETE");
230 break; 261 break;
231 262
232 case content::DownloadItem::MAX_DOWNLOAD_STATE: 263 case content::DownloadItem::MAX_DOWNLOAD_STATE:
233 NOTREACHED() << "state undefined"; 264 NOTREACHED();
234 } 265 }
235 266
236 return file_value; 267 return file_value;
237 } 268 }
238 269
239 // Filters out extension downloads and downloads that don't have a filename yet. 270 // Filters out extension downloads and downloads that don't have a filename yet.
240 bool IsDownloadDisplayable(const content::DownloadItem& item) { 271 bool IsDownloadDisplayable(const content::DownloadItem& item) {
241 return (!download_crx_util::IsExtensionDownload(item) && 272 const DownloadsDOMHandlerData* data = DownloadsDOMHandlerData::Get(&item);
242 !item.IsTemporary() && 273 return !download_crx_util::IsExtensionDownload(item) &&
243 !item.GetFileNameToReportUser().empty() && 274 !item.IsTemporary() &&
244 !item.GetTargetFilePath().empty()); 275 !item.GetFileNameToReportUser().empty() &&
276 !item.GetTargetFilePath().empty() &&
277 (!data || !data->is_removed());
245 } 278 }
246 279
247 } // namespace 280 } // namespace
248 281
249 DownloadsDOMHandler::DownloadsDOMHandler(content::DownloadManager* dlm) 282 DownloadsDOMHandler::DownloadsDOMHandler(content::DownloadManager* dlm)
250 : main_notifier_(dlm, this), 283 : main_notifier_(dlm, this),
251 update_scheduled_(false), 284 update_scheduled_(false),
252 weak_ptr_factory_(this) { 285 weak_ptr_factory_(this) {
253 // Create our fileicon data source. 286 // Create our fileicon data source.
254 Profile* profile = Profile::FromBrowserContext(dlm->GetBrowserContext()); 287 Profile* profile = Profile::FromBrowserContext(dlm->GetBrowserContext());
255 content::URLDataSource::Add(profile, new FileIconSource()); 288 content::URLDataSource::Add(profile, new FileIconSource());
256 289
257 if (profile->IsOffTheRecord()) { 290 if (profile->IsOffTheRecord()) {
258 original_notifier_.reset(new AllDownloadItemNotifier( 291 original_notifier_.reset(new AllDownloadItemNotifier(
259 BrowserContext::GetDownloadManager(profile->GetOriginalProfile()), 292 BrowserContext::GetDownloadManager(profile->GetOriginalProfile()),
260 this)); 293 this));
261 } 294 }
262 } 295 }
263 296
264 DownloadsDOMHandler::~DownloadsDOMHandler() { 297 DownloadsDOMHandler::~DownloadsDOMHandler() {
298 while (!removed_ids_.empty()) {
299 content::DownloadItem* download = GetDownloadById(removed_ids_.back());
300 removed_ids_.pop_back();
301 if (download)
302 download->Remove();
303 }
265 } 304 }
266 305
267 // DownloadsDOMHandler, public: ----------------------------------------------- 306 // DownloadsDOMHandler, public: -----------------------------------------------
268 307
269 void DownloadsDOMHandler::OnPageLoaded(const base::ListValue* args) { 308 void DownloadsDOMHandler::OnPageLoaded(const base::ListValue* args) {
270 SendCurrentDownloads(); 309 SendCurrentDownloads();
271 } 310 }
272 311
273 void DownloadsDOMHandler::RegisterMessages() { 312 void DownloadsDOMHandler::RegisterMessages() {
274 web_ui()->RegisterMessageCallback("onPageLoaded", 313 web_ui()->RegisterMessageCallback("onPageLoaded",
(...skipping 19 matching lines...) Expand all
294 weak_ptr_factory_.GetWeakPtr())); 333 weak_ptr_factory_.GetWeakPtr()));
295 web_ui()->RegisterMessageCallback("pause", 334 web_ui()->RegisterMessageCallback("pause",
296 base::Bind(&DownloadsDOMHandler::HandlePause, 335 base::Bind(&DownloadsDOMHandler::HandlePause,
297 weak_ptr_factory_.GetWeakPtr())); 336 weak_ptr_factory_.GetWeakPtr()));
298 web_ui()->RegisterMessageCallback("resume", 337 web_ui()->RegisterMessageCallback("resume",
299 base::Bind(&DownloadsDOMHandler::HandleResume, 338 base::Bind(&DownloadsDOMHandler::HandleResume,
300 weak_ptr_factory_.GetWeakPtr())); 339 weak_ptr_factory_.GetWeakPtr()));
301 web_ui()->RegisterMessageCallback("remove", 340 web_ui()->RegisterMessageCallback("remove",
302 base::Bind(&DownloadsDOMHandler::HandleRemove, 341 base::Bind(&DownloadsDOMHandler::HandleRemove,
303 weak_ptr_factory_.GetWeakPtr())); 342 weak_ptr_factory_.GetWeakPtr()));
343 web_ui()->RegisterMessageCallback("undo",
344 base::Bind(&DownloadsDOMHandler::HandleUndo,
345 weak_ptr_factory_.GetWeakPtr()));
304 web_ui()->RegisterMessageCallback("cancel", 346 web_ui()->RegisterMessageCallback("cancel",
305 base::Bind(&DownloadsDOMHandler::HandleCancel, 347 base::Bind(&DownloadsDOMHandler::HandleCancel,
306 weak_ptr_factory_.GetWeakPtr())); 348 weak_ptr_factory_.GetWeakPtr()));
307 web_ui()->RegisterMessageCallback("clearAll", 349 web_ui()->RegisterMessageCallback("clearAll",
308 base::Bind(&DownloadsDOMHandler::HandleClearAll, 350 base::Bind(&DownloadsDOMHandler::HandleClearAll,
309 weak_ptr_factory_.GetWeakPtr())); 351 weak_ptr_factory_.GetWeakPtr()));
310 web_ui()->RegisterMessageCallback("openDownloadsFolder", 352 web_ui()->RegisterMessageCallback("openDownloadsFolder",
311 base::Bind(&DownloadsDOMHandler::HandleOpenDownloadsFolder, 353 base::Bind(&DownloadsDOMHandler::HandleOpenDownloadsFolder,
312 weak_ptr_factory_.GetWeakPtr())); 354 weak_ptr_factory_.GetWeakPtr()));
313 } 355 }
(...skipping 19 matching lines...) Expand all
333 query.Search(all_items.begin(), all_items.end(), &filtered_items); 375 query.Search(all_items.begin(), all_items.end(), &filtered_items);
334 if (filtered_items.empty()) 376 if (filtered_items.empty())
335 return; 377 return;
336 } 378 }
337 base::ListValue results_value; 379 base::ListValue results_value;
338 results_value.Append(CreateDownloadItemValue( 380 results_value.Append(CreateDownloadItemValue(
339 download_item, 381 download_item,
340 (original_notifier_.get() && 382 (original_notifier_.get() &&
341 (manager == main_notifier_.GetManager())))); 383 (manager == main_notifier_.GetManager()))));
342 CallDownloadUpdated(results_value); 384 CallDownloadUpdated(results_value);
385 } else {
386 ScheduleSendCurrentDownloads();
343 } 387 }
344 } 388 }
345 389
346 void DownloadsDOMHandler::OnDownloadRemoved( 390 void DownloadsDOMHandler::OnDownloadRemoved(
347 content::DownloadManager* manager, 391 content::DownloadManager* manager,
348 content::DownloadItem* download_item) { 392 content::DownloadItem* download_item) {
393 DownloadsDOMHandlerData* data = DownloadsDOMHandlerData::Get(download_item);
394 if (data && data->is_removed())
395 return;
396
349 // This relies on |download_item| being removed from DownloadManager in this 397 // This relies on |download_item| being removed from DownloadManager in this
350 // MessageLoop iteration. |download_item| may not have been removed from 398 // MessageLoop iteration. |download_item| may not have been removed from
351 // DownloadManager when OnDownloadRemoved() is fired, so bounce off the 399 // DownloadManager when OnDownloadRemoved() is fired, so bounce off the
352 // MessageLoop to give it a chance to be removed. SendCurrentDownloads() looks 400 // MessageLoop to give it a chance to be removed. SendCurrentDownloads() looks
353 // at all downloads, and we do not tell it that |download_item| is being 401 // at all downloads, and we do not tell it that |download_item| is being
354 // removed. If DownloadManager is ever changed to not immediately remove 402 // removed. If DownloadManager is ever changed to not immediately remove
355 // |download_item| from its map when OnDownloadRemoved is sent, then 403 // |download_item| from its map when OnDownloadRemoved is sent, then
356 // DownloadsDOMHandler::OnDownloadRemoved() will need to explicitly tell 404 // DownloadsDOMHandler::OnDownloadRemoved() will need to explicitly tell
357 // SendCurrentDownloads() that |download_item| was removed. A 405 // SendCurrentDownloads() that |download_item| was removed. A
358 // SupportsUserData::Data would be the correct way to do this. 406 // SupportsUserData::Data would be the correct way to do this.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if (file) 479 if (file)
432 file->Resume(); 480 file->Resume();
433 } 481 }
434 482
435 void DownloadsDOMHandler::HandleRemove(const base::ListValue* args) { 483 void DownloadsDOMHandler::HandleRemove(const base::ListValue* args) {
436 if (!IsDeletingHistoryAllowed()) 484 if (!IsDeletingHistoryAllowed())
437 return; 485 return;
438 486
439 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_REMOVE); 487 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_REMOVE);
440 content::DownloadItem* file = GetDownloadByValue(args); 488 content::DownloadItem* file = GetDownloadByValue(args);
441 if (file) 489 if (!file)
442 file->Remove(); 490 return;
491
492 removed_ids_.push_back(file->GetId());
493 DownloadsDOMHandlerData::Create(file)->set_is_removed(true);
494 file->UpdateObservers();
495 }
496
497 void DownloadsDOMHandler::HandleUndo(const base::ListValue* args) {
498 // TODO(dbeam): handle more than removed downloads someday?
499 if (removed_ids_.empty())
500 return;
501
502 uint32 last_removed_id = removed_ids_.back();
503 removed_ids_.pop_back();
504
505 content::DownloadItem* download = GetDownloadById(last_removed_id);
506 if (!download)
507 return;
508
509 DownloadsDOMHandlerData::Set(download, nullptr);
510 download->UpdateObservers();
443 } 511 }
444 512
445 void DownloadsDOMHandler::HandleCancel(const base::ListValue* args) { 513 void DownloadsDOMHandler::HandleCancel(const base::ListValue* args) {
446 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CANCEL); 514 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CANCEL);
447 content::DownloadItem* file = GetDownloadByValue(args); 515 content::DownloadItem* file = GetDownloadByValue(args);
448 if (file) 516 if (file)
449 file->Cancel(true); 517 file->Cancel(true);
450 } 518 }
451 519
452 void DownloadsDOMHandler::HandleClearAll(const base::ListValue* args) { 520 void DownloadsDOMHandler::HandleClearAll(const base::ListValue* args) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 576 }
509 DownloadQuery query; 577 DownloadQuery query;
510 if (search_terms_ && !search_terms_->empty()) { 578 if (search_terms_ && !search_terms_->empty()) {
511 query.AddFilter(DownloadQuery::FILTER_QUERY, *search_terms_.get()); 579 query.AddFilter(DownloadQuery::FILTER_QUERY, *search_terms_.get());
512 } 580 }
513 query.AddFilter(base::Bind(&IsDownloadDisplayable)); 581 query.AddFilter(base::Bind(&IsDownloadDisplayable));
514 query.AddSorter(DownloadQuery::SORT_START_TIME, DownloadQuery::DESCENDING); 582 query.AddSorter(DownloadQuery::SORT_START_TIME, DownloadQuery::DESCENDING);
515 query.Limit(kMaxDownloads); 583 query.Limit(kMaxDownloads);
516 query.Search(all_items.begin(), all_items.end(), &filtered_items); 584 query.Search(all_items.begin(), all_items.end(), &filtered_items);
517 base::ListValue results_value; 585 base::ListValue results_value;
518 for (content::DownloadManager::DownloadVector::const_iterator 586 for (content::DownloadManager::DownloadVector::iterator
519 iter = filtered_items.begin(); iter != filtered_items.end(); ++iter) { 587 iter = filtered_items.begin(); iter != filtered_items.end(); ++iter) {
520 results_value.Append(CreateDownloadItemValue( 588 results_value.Append(CreateDownloadItemValue(
521 *iter, 589 *iter,
522 (original_notifier_.get() && 590 (original_notifier_.get() &&
523 main_notifier_.GetManager() && 591 main_notifier_.GetManager() &&
524 (main_notifier_.GetManager()->GetDownload((*iter)->GetId()) == 592 (main_notifier_.GetManager()->GetDownload((*iter)->GetId()) ==
525 *iter)))); 593 *iter))));
526 } 594 }
527 CallDownloadsList(results_value); 595 CallDownloadsList(results_value);
528 } 596 }
(...skipping 27 matching lines...) Expand all
556 624
557 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() { 625 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() {
558 content::DownloadManager* manager = main_notifier_.GetManager(); 626 content::DownloadManager* manager = main_notifier_.GetManager();
559 return (manager && 627 return (manager &&
560 Profile::FromBrowserContext(manager->GetBrowserContext())-> 628 Profile::FromBrowserContext(manager->GetBrowserContext())->
561 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)); 629 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory));
562 } 630 }
563 631
564 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( 632 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue(
565 const base::ListValue* args) { 633 const base::ListValue* args) {
566 int download_id = -1; 634 std::string download_id;
567 if (!ExtractIntegerValue(args, &download_id)) 635 if (!args->GetString(0, &download_id)) {
568 return NULL; 636 NOTREACHED();
637 return nullptr;
638 }
639
640 uint64 id;
641 if (!base::StringToUint64(download_id, &id)) {
642 NOTREACHED();
643 return nullptr;
644 }
645
646 return GetDownloadById(static_cast<uint32>(id));
647 }
648
649 content::DownloadItem* DownloadsDOMHandler::GetDownloadById(uint32 id) {
569 content::DownloadItem* item = NULL; 650 content::DownloadItem* item = NULL;
570 if (main_notifier_.GetManager()) 651 if (main_notifier_.GetManager())
571 item = main_notifier_.GetManager()->GetDownload(download_id); 652 item = main_notifier_.GetManager()->GetDownload(id);
572 if (!item && original_notifier_.get() && original_notifier_->GetManager()) 653 if (!item && original_notifier_.get() && original_notifier_->GetManager())
573 item = original_notifier_->GetManager()->GetDownload(download_id); 654 item = original_notifier_->GetManager()->GetDownload(id);
574 return item; 655 return item;
575 } 656 }
576 657
577 content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() { 658 content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() {
578 return web_ui()->GetWebContents(); 659 return web_ui()->GetWebContents();
579 } 660 }
580 661
581 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { 662 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) {
582 web_ui()->CallJavascriptFunction("downloadsList", downloads); 663 web_ui()->CallJavascriptFunction("downloadsList", downloads);
583 } 664 }
584 665
585 void DownloadsDOMHandler::CallDownloadUpdated( 666 void DownloadsDOMHandler::CallDownloadUpdated(
586 const base::ListValue& download_item) { 667 const base::ListValue& download_item) {
587 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); 668 web_ui()->CallJavascriptFunction("downloadUpdated", download_item);
588 } 669 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler.h ('k') | chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698