Rename GetIconID to GetIconId
[chromium-blink-merge.git] / chrome / browser / android / download / android_download_manager_overwrite_infobar_delegate.cc
blob734002449ff96e0082ed35dbc8d39edf23054c1e
1 // Copyright 2015 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.
5 #include "chrome/browser/android/download/android_download_manager_overwrite_infobar_delegate.h"
7 #include "base/android/jni_string.h"
8 #include "base/files/file_util.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h"
11 #include "chrome/browser/android/download/chrome_download_delegate.h"
12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
14 #include "components/infobars/core/infobar.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_contents.h"
18 using base::android::ScopedJavaLocalRef;
20 namespace chrome {
21 namespace android {
23 AndroidDownloadManagerOverwriteInfoBarDelegate::
24 ~AndroidDownloadManagerOverwriteInfoBarDelegate() {
27 // static
28 void AndroidDownloadManagerOverwriteInfoBarDelegate::Create(
29 InfoBarService* infobar_service,
30 const std::string& file_name,
31 const std::string& dir_name,
32 const std::string& dir_full_path,
33 jobject chrome_download_delegate,
34 jobject download_info) {
35 infobar_service->AddInfoBar(DownloadOverwriteInfoBar::CreateInfoBar(
36 make_scoped_ptr(new AndroidDownloadManagerOverwriteInfoBarDelegate(
37 file_name, dir_name, dir_full_path, chrome_download_delegate,
38 download_info))));
41 AndroidDownloadManagerOverwriteInfoBarDelegate::
42 AndroidDownloadManagerOverwriteInfoBarDelegate(
43 const std::string& file_name,
44 const std::string& dir_name,
45 const std::string& dir_full_path,
46 jobject chrome_download_delegate,
47 jobject download_info)
48 : file_name_(file_name),
49 dir_name_(dir_name),
50 dir_full_path_(dir_full_path) {
51 JNIEnv* env = base::android::AttachCurrentThread();
52 chrome_download_delegate_.Reset(env, chrome_download_delegate);
53 download_info_.Reset(env, download_info);
56 void AndroidDownloadManagerOverwriteInfoBarDelegate::OverwriteExistingFile() {
57 ChromeDownloadDelegate::EnqueueDownloadManagerRequest(
58 chrome_download_delegate_.obj(), true, download_info_.obj());
61 void AndroidDownloadManagerOverwriteInfoBarDelegate::CreateNewFile() {
62 ChromeDownloadDelegate::EnqueueDownloadManagerRequest(
63 chrome_download_delegate_.obj(), false, download_info_.obj());
66 std::string AndroidDownloadManagerOverwriteInfoBarDelegate::GetFileName()
67 const {
68 return file_name_;
71 std::string AndroidDownloadManagerOverwriteInfoBarDelegate::GetDirName() const {
72 return dir_name_;
75 std::string AndroidDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath()
76 const {
77 return dir_full_path_;
80 } // namespace android
81 } // namespace chrome