Home | History | Annotate | Download | only in browser
      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
      3 // found in the LICENSE file.
      4 
      5 #include "android_webview/browser/aw_download_manager_delegate.h"
      6 
      7 #include "base/files/file_path.h"
      8 #include "content/public/browser/download_danger_type.h"
      9 #include "content/public/browser/download_item.h"
     10 
     11 
     12 namespace android_webview {
     13 
     14 AwDownloadManagerDelegate::~AwDownloadManagerDelegate() {}
     15 
     16 bool AwDownloadManagerDelegate::DetermineDownloadTarget(
     17     content::DownloadItem* item,
     18     const content::DownloadTargetCallback& callback) {
     19   // Note this cancel is independent of the URLRequest cancel in
     20   // AwResourceDispatcherHostDelegate::DownloadStarting. The request
     21   // could have already finished by the time DownloadStarting is called.
     22   callback.Run(base::FilePath() /* Empty file path for cancel */,
     23                content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
     24                content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
     25                base::FilePath());
     26   return true;
     27 }
     28 
     29 bool AwDownloadManagerDelegate::ShouldCompleteDownload(
     30     content::DownloadItem* item,
     31     const base::Closure& complete_callback) {
     32   NOTREACHED();
     33   return true;
     34 }
     35 
     36 bool AwDownloadManagerDelegate::ShouldOpenDownload(
     37     content::DownloadItem* item,
     38     const content::DownloadOpenDelayedCallback& callback) {
     39   NOTREACHED();
     40   return true;
     41 }
     42 
     43 void AwDownloadManagerDelegate::GetNextId(
     44     const content::DownloadIdCallback& callback) {
     45   static uint32 next_id = content::DownloadItem::kInvalidId + 1;
     46   callback.Run(next_id++);
     47 }
     48 
     49 }  // namespace android_webview
     50