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

Side by Side Diff: content/browser/download/download_item.cc

Issue 8414007: Rearrange Should*Download delegate calls to be more useful and intuitive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to TOT. Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/download/download_item.h ('k') | content/browser/download/download_manager.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/download/download_item.h" 5 #include "content/browser/download/download_item.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 download_stats::RecordOpen(end_time(), !opened()); 289 download_stats::RecordOpen(end_time(), !opened());
290 opened_ = true; 290 opened_ = true;
291 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this)); 291 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this));
292 download_manager_->MarkDownloadOpened(this); 292 download_manager_->MarkDownloadOpened(this);
293 293
294 // For testing: If download opening is disabled on this item, 294 // For testing: If download opening is disabled on this item,
295 // make the rest of the routine a no-op. 295 // make the rest of the routine a no-op.
296 if (!open_enabled_) 296 if (!open_enabled_)
297 return; 297 return;
298 298
299 if (download_manager_->delegate()->ShouldOpenDownload(this)) 299 content::GetContentClient()->browser()->OpenItem(full_path());
300 content::GetContentClient()->browser()->OpenItem(full_path());
301 } 300 }
302 301
303 void DownloadItem::ShowDownloadInShell() { 302 void DownloadItem::ShowDownloadInShell() {
304 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 303 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
305 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 304 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
306 305
307 content::GetContentClient()->browser()->ShowItemInFolder(full_path()); 306 content::GetContentClient()->browser()->ShowItemInFolder(full_path());
308 } 307 }
309 308
310 void DownloadItem::DangerousDownloadValidated() { 309 void DownloadItem::DangerousDownloadValidated() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 389
391 void DownloadItem::MarkAsComplete() { 390 void DownloadItem::MarkAsComplete() {
392 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 391 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
393 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 392 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
394 393
395 DCHECK(all_data_saved_); 394 DCHECK(all_data_saved_);
396 end_time_ = base::Time::Now(); 395 end_time_ = base::Time::Now();
397 TransitionTo(COMPLETE); 396 TransitionTo(COMPLETE);
398 } 397 }
399 398
400 void DownloadItem::CompleteDelayedDownload() { 399 void DownloadItem::DelayedDownloadOpened() {
401 auto_opened_ = true; 400 auto_opened_ = true;
402 Completed(); 401 Completed();
403 } 402 }
404 403
405 void DownloadItem::OnAllDataSaved(int64 size) { 404 void DownloadItem::OnAllDataSaved(int64 size) {
406 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 405 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
407 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 406 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
408 407
409 DCHECK(!all_data_saved_); 408 DCHECK(!all_data_saved_);
410 all_data_saved_ = true; 409 all_data_saved_ = true;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 611 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
613 612
614 VLOG(20) << __FUNCTION__ << "()" 613 VLOG(20) << __FUNCTION__ << "()"
615 << " full_path = \"" << full_path.value() << "\"" 614 << " full_path = \"" << full_path.value() << "\""
616 << " needed rename = " << NeedsRename() 615 << " needed rename = " << NeedsRename()
617 << " " << DebugString(false); 616 << " " << DebugString(false);
618 DCHECK(NeedsRename()); 617 DCHECK(NeedsRename());
619 618
620 Rename(full_path); 619 Rename(full_path);
621 620
622 if (download_manager_->delegate()->ShouldCompleteDownload(this)) { 621 if (download_manager_->delegate()->ShouldOpenDownload(this)) {
623 Completed(); 622 Completed();
624 } else { 623 } else {
625 delegate_delayed_complete_ = true; 624 delegate_delayed_complete_ = true;
626 } 625 }
627 } 626 }
628 627
629 bool DownloadItem::MatchesQuery(const string16& query) const { 628 bool DownloadItem::MatchesQuery(const string16& query) const {
630 if (query.empty()) 629 if (query.empty())
631 return true; 630 return true;
632 631
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 state_info_.target_name.value().c_str(), 810 state_info_.target_name.value().c_str(),
812 full_path().value().c_str()); 811 full_path().value().c_str());
813 } else { 812 } else {
814 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 813 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
815 } 814 }
816 815
817 description += " }"; 816 description += " }";
818 817
819 return description; 818 return description;
820 } 819 }
OLDNEW
« no previous file with comments | « content/browser/download/download_item.h ('k') | content/browser/download/download_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698