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

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

Issue 16994004: Remove DownloadItem::Is*() in favor of DI::GetState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@di-getstate-2
Patch Set: Rebased to fix new test, applied suggestions from bauerb and benjhayden Created 7 years, 6 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
« no previous file with comments | « no previous file | content/browser/android/download_controller_android_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void DownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) { 349 void DownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) {
350 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE); 350 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE);
351 content::DownloadItem* file = GetDownloadByValue(args); 351 content::DownloadItem* file = GetDownloadByValue(args);
352 if (file) 352 if (file)
353 file->OpenDownload(); 353 file->OpenDownload();
354 } 354 }
355 355
356 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { 356 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) {
357 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); 357 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG);
358 content::DownloadItem* file = GetDownloadByValue(args); 358 content::DownloadItem* file = GetDownloadByValue(args);
359 if (!file)
360 return;
361
359 content::WebContents* web_contents = GetWebUIWebContents(); 362 content::WebContents* web_contents = GetWebUIWebContents();
360 // |web_contents| is only NULL in the test. 363 // |web_contents| is only NULL in the test.
361 if (!file || !web_contents || !file->IsComplete()) 364 if (!web_contents)
362 return; 365 return;
366
367 if (file->GetState() != content::DownloadItem::COMPLETE)
368 return;
369
363 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( 370 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath(
364 file->GetTargetFilePath(), IconLoader::NORMAL); 371 file->GetTargetFilePath(), IconLoader::NORMAL);
365 gfx::NativeView view = web_contents->GetView()->GetNativeView(); 372 gfx::NativeView view = web_contents->GetView()->GetNativeView();
366 { 373 {
367 // Enable nested tasks during DnD, while |DragDownload()| blocks. 374 // Enable nested tasks during DnD, while |DragDownload()| blocks.
368 base::MessageLoop::ScopedNestableTaskAllower allow( 375 base::MessageLoop::ScopedNestableTaskAllower allow(
369 base::MessageLoop::current()); 376 base::MessageLoop::current());
370 download_util::DragDownload(file, icon, view); 377 download_util::DragDownload(file, icon, view);
371 } 378 }
372 } 379 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 558 }
552 559
553 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { 560 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) {
554 web_ui()->CallJavascriptFunction("downloadsList", downloads); 561 web_ui()->CallJavascriptFunction("downloadsList", downloads);
555 } 562 }
556 563
557 void DownloadsDOMHandler::CallDownloadUpdated( 564 void DownloadsDOMHandler::CallDownloadUpdated(
558 const base::ListValue& download_item) { 565 const base::ListValue& download_item) {
559 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); 566 web_ui()->CallJavascriptFunction("downloadUpdated", download_item);
560 } 567 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/android/download_controller_android_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698