Commit db26f31b authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download later: Rename DownloadLocationDialog to DownloadDialog.

Download later needs to share the JNI bridge with download location
dialog. This CL renames the DownloadLocationDialog* to DownloadDialog*.

No logic is changed in this CL. Simply a rename.

Bug: 1078454
Change-Id: I91585b1280e9cf9f3899b9b6ce8b9c3676bb600c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227240
Commit-Queue: Xing Liu <xingliu@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarHesen Zhang <hesen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774512}
parent 1f2aa36c
......@@ -172,7 +172,7 @@ public class DownloadLocationChangeTest implements CustomMainActivityStart {
private void startDownload(boolean hasSDCard) {
TestThreadUtils.runOnUiThreadBlocking(() -> {
Assert.assertEquals(DownloadPromptStatus.SHOW_INITIAL,
DownloadLocationDialogBridge.getPromptForDownloadAndroid());
DownloadDialogBridge.getPromptForDownloadAndroid());
simulateDownloadDirectories(hasSDCard);
......@@ -211,6 +211,6 @@ public class DownloadLocationChangeTest implements CustomMainActivityStart {
private void promptDownloadLocationDialog(@DownloadPromptStatus int promptStatus) {
TestThreadUtils.runOnUiThreadBlocking(
() -> { DownloadLocationDialogBridge.setPromptForDownloadAndroid(promptStatus); });
() -> { DownloadDialogBridge.setPromptForDownloadAndroid(promptStatus); });
}
}
......@@ -243,8 +243,7 @@ public class DownloadTestRule extends ChromeActivityTestRule<ChromeActivity> {
mActivityStart.customMainActivityStart();
TestThreadUtils.runOnUiThreadBlocking(() -> {
DownloadLocationDialogBridge.setPromptForDownloadAndroid(
DownloadPromptStatus.DONT_SHOW);
DownloadDialogBridge.setPromptForDownloadAndroid(DownloadPromptStatus.DONT_SHOW);
});
cleanUpAllDownloads();
......
......@@ -2832,9 +2832,9 @@ static_library("browser") {
"download/android/download_controller.h",
"download/android/download_controller_base.cc",
"download/android/download_controller_base.h",
"download/android/download_location_dialog_bridge.h",
"download/android/download_location_dialog_bridge_impl.cc",
"download/android/download_location_dialog_bridge_impl.h",
"download/android/download_dialog_bridge.h",
"download/android/download_dialog_bridge_impl.cc",
"download/android/download_dialog_bridge_impl.h",
"download/android/download_manager_bridge.cc",
"download/android/download_manager_bridge.h",
"download/android/download_manager_service.cc",
......
......@@ -10,12 +10,12 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/download/DirectoryOption.java",
"java/src/org/chromium/chrome/browser/download/DownloadConstants.java",
"java/src/org/chromium/chrome/browser/download/DownloadDelegateImpl.java",
"java/src/org/chromium/chrome/browser/download/DownloadDialogBridge.java",
"java/src/org/chromium/chrome/browser/download/DownloadDirectoryProvider.java",
"java/src/org/chromium/chrome/browser/download/DownloadFileProvider.java",
"java/src/org/chromium/chrome/browser/download/DownloadFilter.java",
"java/src/org/chromium/chrome/browser/download/DownloadInfo.java",
"java/src/org/chromium/chrome/browser/download/DownloadLocationCustomView.java",
"java/src/org/chromium/chrome/browser/download/DownloadLocationDialogBridge.java",
"java/src/org/chromium/chrome/browser/download/DownloadManagerBridge.java",
"java/src/org/chromium/chrome/browser/download/DownloadStartupUtils.java",
"java/src/org/chromium/chrome/browser/download/DownloadStatus.java",
......@@ -73,8 +73,8 @@ android_library_factory("factory_java") {
generate_jni("jni_headers") {
sources = [
"java/src/org/chromium/chrome/browser/download/DownloadDialogBridge.java",
"java/src/org/chromium/chrome/browser/download/DownloadInfo.java",
"java/src/org/chromium/chrome/browser/download/DownloadLocationDialogBridge.java",
"java/src/org/chromium/chrome/browser/download/DownloadManagerBridge.java",
"java/src/org/chromium/chrome/browser/download/DownloadStartupUtils.java",
"java/src/org/chromium/chrome/browser/download/MimeUtils.java",
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_LOCATION_DIALOG_BRIDGE_H_
#define CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_LOCATION_DIALOG_BRIDGE_H_
#ifndef CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_BRIDGE_H_
#define CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_BRIDGE_H_
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
......@@ -15,12 +15,12 @@ namespace base {
class FilePath;
} // namespace base
class DownloadLocationDialogBridge {
class DownloadDialogBridge {
public:
using LocationCallback = base::OnceCallback<void(DownloadLocationDialogResult,
const base::FilePath&)>;
virtual ~DownloadLocationDialogBridge() = default;
virtual ~DownloadDialogBridge() = default;
// Show a download location picker dialog to determine the download path.
// The path selected by the user will be returned in |location_callback|.
......@@ -39,4 +39,4 @@ class DownloadLocationDialogBridge {
const base::android::JavaParamRef<jobject>& obj) = 0;
};
#endif // CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_LOCATION_DIALOG_BRIDGE_H_
#endif // CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_BRIDGE_H_
......@@ -2,33 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/download/android/download_location_dialog_bridge_impl.h"
#include "chrome/browser/download/android/download_dialog_bridge_impl.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/download/android/download_controller.h"
#include "chrome/browser/download/android/jni_headers/DownloadLocationDialogBridge_jni.h"
#include "chrome/browser/download/android/jni_headers/DownloadDialogBridge_jni.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "ui/android/window_android.h"
DownloadLocationDialogBridgeImpl::DownloadLocationDialogBridgeImpl()
DownloadDialogBridgeImpl::DownloadDialogBridgeImpl()
: is_dialog_showing_(false) {
JNIEnv* env = base::android::AttachCurrentThread();
java_obj_.Reset(env, Java_DownloadLocationDialogBridge_create(
java_obj_.Reset(env, Java_DownloadDialogBridge_create(
env, reinterpret_cast<intptr_t>(this))
.obj());
DCHECK(!java_obj_.is_null());
}
DownloadLocationDialogBridgeImpl::~DownloadLocationDialogBridgeImpl() {
DownloadDialogBridgeImpl::~DownloadDialogBridgeImpl() {
JNIEnv* env = base::android::AttachCurrentThread();
Java_DownloadLocationDialogBridge_destroy(env, java_obj_);
Java_DownloadDialogBridge_destroy(env, java_obj_);
}
void DownloadLocationDialogBridgeImpl::ShowDialog(
void DownloadDialogBridgeImpl::ShowDialog(
gfx::NativeWindow native_window,
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
......@@ -59,14 +59,14 @@ void DownloadLocationDialogBridgeImpl::ShowDialog(
is_dialog_showing_ = true;
JNIEnv* env = base::android::AttachCurrentThread();
Java_DownloadLocationDialogBridge_showDialog(
Java_DownloadDialogBridge_showDialog(
env, java_obj_, native_window->GetJavaObject(),
static_cast<long>(total_bytes), static_cast<int>(dialog_type),
base::android::ConvertUTF8ToJavaString(env,
suggested_path.AsUTF8Unsafe()));
}
void DownloadLocationDialogBridgeImpl::OnComplete(
void DownloadDialogBridgeImpl::OnComplete(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& returned_path) {
......@@ -78,7 +78,7 @@ void DownloadLocationDialogBridgeImpl::OnComplete(
is_dialog_showing_ = false;
}
void DownloadLocationDialogBridgeImpl::OnCanceled(
void DownloadDialogBridgeImpl::OnCanceled(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj) {
if (location_callback_) {
......@@ -89,7 +89,7 @@ void DownloadLocationDialogBridgeImpl::OnCanceled(
is_dialog_showing_ = false;
}
void DownloadLocationDialogBridgeImpl::CompleteLocationSelection(
void DownloadDialogBridgeImpl::CompleteLocationSelection(
DownloadLocationDialogResult result,
base::FilePath file_path) {
if (location_callback_) {
......@@ -99,7 +99,7 @@ void DownloadLocationDialogBridgeImpl::CompleteLocationSelection(
}
static base::android::ScopedJavaLocalRef<jstring>
JNI_DownloadLocationDialogBridge_GetDownloadDefaultDirectory(JNIEnv* env) {
JNI_DownloadDialogBridge_GetDownloadDefaultDirectory(JNIEnv* env) {
PrefService* pref_service =
ProfileManager::GetActiveUserProfile()->GetOriginalProfile()->GetPrefs();
......@@ -107,8 +107,7 @@ JNI_DownloadLocationDialogBridge_GetDownloadDefaultDirectory(JNIEnv* env) {
env, pref_service->GetString(prefs::kDownloadDefaultDirectory));
}
static void
JNI_DownloadLocationDialogBridge_SetDownloadAndSaveFileDefaultDirectory(
static void JNI_DownloadDialogBridge_SetDownloadAndSaveFileDefaultDirectory(
JNIEnv* env,
const base::android::JavaParamRef<jstring>& directory) {
PrefService* pref_service =
......
......@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_LOCATION_DIALOG_BRIDGE_IMPL_H_
#define CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_LOCATION_DIALOG_BRIDGE_IMPL_H_
#ifndef CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_BRIDGE_IMPL_H_
#define CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_BRIDGE_IMPL_H_
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/callback.h"
#include "chrome/browser/download/android/download_location_dialog_bridge.h"
#include "chrome/browser/download/android/download_dialog_bridge.h"
#include "chrome/browser/download/download_location_dialog_type.h"
#include "ui/gfx/native_widget_types.h"
class DownloadLocationDialogBridgeImpl : public DownloadLocationDialogBridge {
class DownloadDialogBridgeImpl : public DownloadDialogBridge {
public:
DownloadLocationDialogBridgeImpl();
~DownloadLocationDialogBridgeImpl() override;
DownloadDialogBridgeImpl();
~DownloadDialogBridgeImpl() override;
// DownloadLocationDialogBridge implementation.
// DownloadDialogBridge implementation.
void ShowDialog(gfx::NativeWindow native_window,
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
......@@ -41,7 +41,7 @@ class DownloadLocationDialogBridgeImpl : public DownloadLocationDialogBridge {
base::android::ScopedJavaGlobalRef<jobject> java_obj_;
LocationCallback location_callback_;
DISALLOW_COPY_AND_ASSIGN(DownloadLocationDialogBridgeImpl);
DISALLOW_COPY_AND_ASSIGN(DownloadDialogBridgeImpl);
};
#endif // CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_LOCATION_DIALOG_BRIDGE_IMPL_H_
#endif // CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_BRIDGE_IMPL_H_
......@@ -28,8 +28,8 @@ import java.util.ArrayList;
/**
* Helper class to handle communication between download location dialog and native.
*/
public class DownloadLocationDialogBridge implements ModalDialogProperties.Controller {
private long mNativeDownloadLocationDialogBridge;
public class DownloadDialogBridge implements ModalDialogProperties.Controller {
private long mNativeDownloadDialogBridge;
private PropertyModel mDialogModel;
private DownloadLocationCustomView mCustomView;
private ModalDialogManager mModalDialogManager;
......@@ -38,18 +38,18 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
private String mSuggestedPath;
private Context mContext;
private DownloadLocationDialogBridge(long nativeDownloadLocationDialogBridge) {
mNativeDownloadLocationDialogBridge = nativeDownloadLocationDialogBridge;
private DownloadDialogBridge(long nativeDownloadDialogBridge) {
mNativeDownloadDialogBridge = nativeDownloadDialogBridge;
}
@CalledByNative
public static DownloadLocationDialogBridge create(long nativeDownloadLocationDialogBridge) {
return new DownloadLocationDialogBridge(nativeDownloadLocationDialogBridge);
public static DownloadDialogBridge create(long nativeDownloadDialogBridge) {
return new DownloadDialogBridge(nativeDownloadDialogBridge);
}
@CalledByNative
private void destroy() {
mNativeDownloadLocationDialogBridge = 0;
mNativeDownloadDialogBridge = 0;
if (mModalDialogManager != null) {
mModalDialogManager.dismissDialog(
mDialogModel, DialogDismissalCause.DISMISSED_BY_NATIVE);
......@@ -119,9 +119,8 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
if (dir.type == DirectoryOption.DownloadLocationDirectoryType.DEFAULT) {
assert (!TextUtils.isEmpty(dir.location));
setDownloadAndSaveFileDefaultDirectory(dir.location);
DownloadLocationDialogBridgeJni.get().onComplete(
mNativeDownloadLocationDialogBridge, DownloadLocationDialogBridge.this,
mSuggestedPath);
DownloadDialogBridgeJni.get().onComplete(
mNativeDownloadDialogBridge, DownloadDialogBridge.this, mSuggestedPath);
}
return;
}
......@@ -195,7 +194,7 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
}
// Update native with new path.
if (mNativeDownloadLocationDialogBridge != 0) {
if (mNativeDownloadDialogBridge != 0) {
setDownloadAndSaveFileDefaultDirectory(directoryOption.location);
RecordHistogram.recordEnumeratedHistogram(
......@@ -203,8 +202,8 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
DirectoryOption.DownloadLocationDirectoryType.NUM_ENTRIES);
File file = new File(directoryOption.location, fileName);
DownloadLocationDialogBridgeJni.get().onComplete(mNativeDownloadLocationDialogBridge,
DownloadLocationDialogBridge.this, file.getAbsolutePath());
DownloadDialogBridgeJni.get().onComplete(
mNativeDownloadDialogBridge, DownloadDialogBridge.this, file.getAbsolutePath());
}
// Update preference to show prompt based on whether checkbox is checked only when the user
......@@ -217,9 +216,9 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
}
private void cancel() {
if (mNativeDownloadLocationDialogBridge != 0) {
DownloadLocationDialogBridgeJni.get().onCanceled(
mNativeDownloadLocationDialogBridge, DownloadLocationDialogBridge.this);
if (mNativeDownloadDialogBridge != 0) {
DownloadDialogBridgeJni.get().onCanceled(
mNativeDownloadDialogBridge, DownloadDialogBridge.this);
}
}
......@@ -227,14 +226,14 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
* @return The stored download default directory.
*/
public static String getDownloadDefaultDirectory() {
return DownloadLocationDialogBridgeJni.get().getDownloadDefaultDirectory();
return DownloadDialogBridgeJni.get().getDownloadDefaultDirectory();
}
/**
* @param directory New directory to set as the download default directory.
*/
public static void setDownloadAndSaveFileDefaultDirectory(String directory) {
DownloadLocationDialogBridgeJni.get().setDownloadAndSaveFileDefaultDirectory(directory);
DownloadDialogBridgeJni.get().setDownloadAndSaveFileDefaultDirectory(directory);
}
/**
......@@ -254,10 +253,9 @@ public class DownloadLocationDialogBridge implements ModalDialogProperties.Contr
@NativeMethods
interface Natives {
void onComplete(long nativeDownloadLocationDialogBridge,
DownloadLocationDialogBridge caller, String returnedPath);
void onCanceled(
long nativeDownloadLocationDialogBridge, DownloadLocationDialogBridge caller);
void onComplete(
long nativeDownloadDialogBridge, DownloadDialogBridge caller, String returnedPath);
void onCanceled(long nativeDownloadDialogBridge, DownloadDialogBridge caller);
String getDownloadDefaultDirectory();
void setDownloadAndSaveFileDefaultDirectory(String directory);
}
......
......@@ -55,7 +55,7 @@ public class DownloadLocationCustomView
mDialogType = dialogType;
// Automatically check "don't show again" the first time the user is seeing the dialog.
boolean isInitial = DownloadLocationDialogBridge.getPromptForDownloadAndroid()
boolean isInitial = DownloadDialogBridge.getPromptForDownloadAndroid()
== DownloadPromptStatus.SHOW_INITIAL;
mDontShowAgain.setChecked(isInitial);
mDontShowAgain.setOnCheckedChangeListener(this);
......@@ -87,12 +87,11 @@ public class DownloadLocationCustomView
// CompoundButton.OnCheckedChangeListener implementation.
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
DownloadLocationDialogBridge.setPromptForDownloadAndroid(
DownloadDialogBridge.setPromptForDownloadAndroid(
isChecked ? DownloadPromptStatus.DONT_SHOW : DownloadPromptStatus.SHOW_PREFERENCE);
}
// Helper methods available to DownloadLocationDialogBridge.
// Helper methods available to DownloadDialogBridge.
/**
* @return The text that the user inputted as the name of the file.
*/
......
......@@ -17,8 +17,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.chromium.chrome.browser.download.DirectoryOption;
import org.chromium.chrome.browser.download.DownloadDialogBridge;
import org.chromium.chrome.browser.download.DownloadDirectoryProvider;
import org.chromium.chrome.browser.download.DownloadLocationDialogBridge;
import org.chromium.chrome.browser.download.R;
import org.chromium.chrome.browser.download.StringUtils;
......@@ -169,7 +169,7 @@ public class DownloadDirectoryAdapter extends ArrayAdapter<Object> {
int selectedId = NO_SELECTED_ITEM_ID;
String defaultLocation = DownloadLocationDialogBridge.getDownloadDefaultDirectory();
String defaultLocation = DownloadDialogBridge.getDownloadDefaultDirectory();
for (int i = 0; i < getCount(); i++) {
DirectoryOption option = (DirectoryOption) getItem(i);
if (option == null) continue;
......@@ -193,8 +193,7 @@ public class DownloadDirectoryAdapter extends ArrayAdapter<Object> {
DirectoryOption option = (DirectoryOption) getItem(i);
if (option == null) continue;
if (option.availableSpace > 0) {
DownloadLocationDialogBridge.setDownloadAndSaveFileDefaultDirectory(
option.location);
DownloadDialogBridge.setDownloadAndSaveFileDefaultDirectory(option.location);
mSelectedPosition = i;
return i;
}
......
......@@ -17,7 +17,7 @@ import androidx.annotation.Nullable;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.download.DirectoryOption;
import org.chromium.chrome.browser.download.DownloadLocationDialogBridge;
import org.chromium.chrome.browser.download.DownloadDialogBridge;
import org.chromium.chrome.browser.download.R;
import org.chromium.chrome.browser.download.StringUtils;
......@@ -95,7 +95,7 @@ public class DownloadLocationPreferenceAdapter
if (option == null) return;
// Update the native pref, which persists the download directory selected by the user.
DownloadLocationDialogBridge.setDownloadAndSaveFileDefaultDirectory(option.location);
DownloadDialogBridge.setDownloadAndSaveFileDefaultDirectory(option.location);
mSelectedPosition = selectedId;
......
......@@ -10,7 +10,7 @@ import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import org.chromium.chrome.browser.download.DownloadLocationDialogBridge;
import org.chromium.chrome.browser.download.DownloadDialogBridge;
import org.chromium.chrome.browser.download.DownloadPromptStatus;
import org.chromium.chrome.browser.download.R;
import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchConfiguration;
......@@ -77,8 +77,7 @@ public class DownloadSettings
if (mLocationPromptEnabledPref != null) {
// Location prompt is marked enabled if the prompt status is not DONT_SHOW.
boolean isLocationPromptEnabled =
DownloadLocationDialogBridge.getPromptForDownloadAndroid()
boolean isLocationPromptEnabled = DownloadDialogBridge.getPromptForDownloadAndroid()
!= DownloadPromptStatus.DONT_SHOW;
mLocationPromptEnabledPref.setChecked(isLocationPromptEnabled);
}
......@@ -108,20 +107,18 @@ public class DownloadSettings
}
// Preference.OnPreferenceChangeListener implementation.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (PREF_LOCATION_PROMPT_ENABLED.equals(preference.getKey())) {
if ((boolean) newValue) {
// Only update if the interstitial has been shown before.
if (DownloadLocationDialogBridge.getPromptForDownloadAndroid()
if (DownloadDialogBridge.getPromptForDownloadAndroid()
!= DownloadPromptStatus.SHOW_INITIAL) {
DownloadLocationDialogBridge.setPromptForDownloadAndroid(
DownloadDialogBridge.setPromptForDownloadAndroid(
DownloadPromptStatus.SHOW_PREFERENCE);
}
} else {
DownloadLocationDialogBridge.setPromptForDownloadAndroid(
DownloadPromptStatus.DONT_SHOW);
DownloadDialogBridge.setPromptForDownloadAndroid(DownloadPromptStatus.DONT_SHOW);
}
} else if (PREF_PREFETCHING_ENABLED.equals(preference.getKey())) {
PrefetchConfiguration.setPrefetchingEnabledInSettings((boolean) newValue);
......
......@@ -86,7 +86,7 @@
#include "base/android/path_utils.h"
#include "chrome/browser/download/android/chrome_duplicate_download_infobar_delegate.h"
#include "chrome/browser/download/android/download_controller.h"
#include "chrome/browser/download/android/download_location_dialog_bridge_impl.h"
#include "chrome/browser/download/android/download_dialog_bridge_impl.h"
#include "chrome/browser/download/android/download_manager_service.h"
#include "chrome/browser/download/android/download_open_source.h"
#include "chrome/browser/download/android/download_utils.h"
......@@ -319,7 +319,7 @@ ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
download_prefs_(new DownloadPrefs(profile)),
is_file_picker_showing_(false) {
#if defined(OS_ANDROID)
location_dialog_bridge_.reset(new DownloadLocationDialogBridgeImpl);
download_dialog_bridge_.reset(new DownloadDialogBridgeImpl);
#endif
}
......@@ -345,15 +345,15 @@ void ChromeDownloadManagerDelegate::ChooseDownloadLocation(
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
const base::FilePath& suggested_path,
DownloadLocationDialogBridge::LocationCallback callback) {
DCHECK(location_dialog_bridge_);
location_dialog_bridge_->ShowDialog(native_window, total_bytes, dialog_type,
DownloadDialogBridge::LocationCallback callback) {
DCHECK(download_dialog_bridge_);
download_dialog_bridge_->ShowDialog(native_window, total_bytes, dialog_type,
suggested_path, std::move(callback));
}
void ChromeDownloadManagerDelegate::SetDownloadLocationDialogBridgeForTesting(
DownloadLocationDialogBridge* bridge) {
location_dialog_bridge_.reset(bridge);
void ChromeDownloadManagerDelegate::SetDownloadDialogBridgeForTesting(
DownloadDialogBridge* bridge) {
download_dialog_bridge_.reset(bridge);
}
#endif // defined(OS_ANDROID)
......
......@@ -34,7 +34,7 @@
#include "ui/gfx/native_widget_types.h"
#if defined(OS_ANDROID)
#include "chrome/browser/download/android/download_location_dialog_bridge.h"
#include "chrome/browser/download/android/download_dialog_bridge.h"
#endif
class DownloadPrefs;
......@@ -64,15 +64,13 @@ class ChromeDownloadManagerDelegate
void SetDownloadManager(content::DownloadManager* dm);
#if defined(OS_ANDROID)
void ChooseDownloadLocation(
gfx::NativeWindow native_window,
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
const base::FilePath& suggested_path,
DownloadLocationDialogBridge::LocationCallback callback);
void ChooseDownloadLocation(gfx::NativeWindow native_window,
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
const base::FilePath& suggested_path,
DownloadDialogBridge::LocationCallback callback);
void SetDownloadLocationDialogBridgeForTesting(
DownloadLocationDialogBridge* bridge);
void SetDownloadDialogBridgeForTesting(DownloadDialogBridge* bridge);
#endif
// Callbacks passed to GetNextId() will not be called until the returned
......@@ -280,7 +278,7 @@ class ChromeDownloadManagerDelegate
Profile* profile_;
#if defined(OS_ANDROID)
std::unique_ptr<DownloadLocationDialogBridge> location_dialog_bridge_;
std::unique_ptr<DownloadDialogBridge> download_dialog_bridge_;
#endif
// If history database fails to initialize, this will always be kInvalidId.
......
......@@ -1686,17 +1686,16 @@ class AndroidDownloadInfobarCounter
int infobar_count_ = 0;
};
class TestDownloadLocationDialogBridge : public DownloadLocationDialogBridge {
class TestDownloadDialogBridge : public DownloadDialogBridge {
public:
TestDownloadLocationDialogBridge() {}
// DownloadLocationDialogBridge implementation.
void ShowDialog(
gfx::NativeWindow native_window,
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
const base::FilePath& suggested_path,
DownloadLocationDialogBridge::LocationCallback callback) override {
TestDownloadDialogBridge() {}
// DownloadDialogBridge implementation.
void ShowDialog(gfx::NativeWindow native_window,
int64_t total_bytes,
DownloadLocationDialogType dialog_type,
const base::FilePath& suggested_path,
DownloadDialogBridge::LocationCallback callback) override {
dialog_shown_count_++;
dialog_type_ = dialog_type;
if (callback) {
......@@ -1731,7 +1730,7 @@ class TestDownloadLocationDialogBridge : public DownloadLocationDialogBridge {
DownloadTargetDeterminerDelegate::ConfirmationCallback
dialog_complete_callback_;
DISALLOW_COPY_AND_ASSIGN(TestDownloadLocationDialogBridge);
DISALLOW_COPY_AND_ASSIGN(TestDownloadDialogBridge);
};
} // namespace
......@@ -1909,10 +1908,10 @@ TEST_F(ChromeDownloadManagerDelegateTest,
&TestChromeDownloadManagerDelegate::RequestConfirmationConcrete));
base::FilePath fake_path = GetPathInDownloadDir(FILE_PATH_LITERAL("foo.txt"));
GURL url("http://example.com");
TestDownloadLocationDialogBridge* location_dialog_bridge =
new TestDownloadLocationDialogBridge();
delegate()->SetDownloadLocationDialogBridgeForTesting(
static_cast<DownloadLocationDialogBridge*>(location_dialog_bridge));
TestDownloadDialogBridge* location_dialog_bridge =
new TestDownloadDialogBridge();
delegate()->SetDownloadDialogBridgeForTesting(
static_cast<DownloadDialogBridge*>(location_dialog_bridge));
for (const auto& test_case : kTestCases) {
std::unique_ptr<download::MockDownloadItem> download_item =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment