Commit 5231c96c authored by Sky Malice's avatar Sky Malice Committed by Commit Bot

Migrate PermissionUpdatedCallback to OnceCallback.

Bug: 714018
Change-Id: Icf820390ed7ae7dd66219d9473dedae3e90e382a
Reviewed-on: https://chromium-review.googlesource.com/1117569
Commit-Queue: Sky Malice <skym@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571913}
parent cdff37ea
......@@ -4,7 +4,6 @@
#include "chrome/browser/android/vr/arcore_device/arcore_device.h"
#include <jni.h>
#include "base/bind.h"
#include "base/numerics/math_constants.h"
#include "base/optional.h"
......@@ -368,9 +367,8 @@ void ARCoreDevice::OnRequestCameraPermissionResult(
// Show the Android camera permission info bar.
PermissionUpdateInfoBarDelegate::Create(
web_contents, content_settings_types,
base::BindRepeating(
&ARCoreDevice::OnRequestAndroidCameraPermissionResult,
GetWeakPtr(), base::Passed(&callback)));
base::BindOnce(&ARCoreDevice::OnRequestAndroidCameraPermissionResult,
GetWeakPtr(), base::Passed(&callback)));
return;
case ShowPermissionInfoBarState::CANNOT_SHOW_PERMISSION_INFOBAR:
std::move(callback).Run(false);
......
......@@ -6,6 +6,10 @@
#define CHROME_BROWSER_ANDROID_VR_ARCORE_DEVICE_ARCORE_DEVICE_H_
#include <jni.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/android/jni_android.h"
#include "base/macros.h"
#include "base/optional.h"
......
......@@ -133,10 +133,10 @@ void GeolocationPermissionContextAndroid::RequestPermission(
ShowPermissionInfoBarState::SHOW_PERMISSION_INFOBAR) {
PermissionUpdateInfoBarDelegate::Create(
web_contents, content_settings_types,
base::Bind(&GeolocationPermissionContextAndroid ::
HandleUpdateAndroidPermissions,
weak_factory_.GetWeakPtr(), id, requesting_frame_origin,
embedding_origin, callback));
base::BindOnce(&GeolocationPermissionContextAndroid ::
HandleUpdateAndroidPermissions,
weak_factory_.GetWeakPtr(), id, requesting_frame_origin,
embedding_origin, callback));
return;
}
......
......@@ -214,9 +214,8 @@ void MediaStreamDevicesController::RequestAndroidPermissionsIfNeeded(
case ShowPermissionInfoBarState::SHOW_PERMISSION_INFOBAR:
PermissionUpdateInfoBarDelegate::Create(
web_contents, content_settings_types,
base::BindRepeating(
&MediaStreamDevicesController::AndroidOSPromptAnswered,
base::Passed(&controller), responses));
base::BindOnce(&MediaStreamDevicesController::AndroidOSPromptAnswered,
base::Passed(&controller), responses));
return;
case ShowPermissionInfoBarState::CANNOT_SHOW_PERMISSION_INFOBAR: {
std::vector<ContentSetting> blocked_responses(responses.size(),
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
#include <memory>
#include <utility>
#include "base/android/jni_array.h"
#include "base/callback_helpers.h"
......@@ -25,7 +26,7 @@ using base::android::JavaParamRef;
infobars::InfoBar* PermissionUpdateInfoBarDelegate::Create(
content::WebContents* web_contents,
const std::vector<ContentSettingsType>& content_settings_types,
const PermissionUpdatedCallback& callback) {
PermissionUpdatedCallback callback) {
DCHECK(ShouldShowPermissionInfoBar(web_contents, content_settings_types) ==
ShowPermissionInfoBarState::SHOW_PERMISSION_INFOBAR)
<< "Caller should check ShouldShowPermissionInfobar before creating the "
......@@ -74,7 +75,7 @@ infobars::InfoBar* PermissionUpdateInfoBarDelegate::Create(
}
return PermissionUpdateInfoBarDelegate::Create(
web_contents, permissions, message_id, callback);
web_contents, permissions, message_id, std::move(callback));
}
// static
......@@ -82,18 +83,19 @@ infobars::InfoBar* PermissionUpdateInfoBarDelegate::Create(
content::WebContents* web_contents,
const std::vector<std::string>& android_permissions,
int permission_msg_id,
const PermissionUpdatedCallback& callback) {
PermissionUpdatedCallback callback) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
if (!infobar_service) {
callback.Run(false);
std::move(callback).Run(false);
return nullptr;
}
return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
std::unique_ptr<ConfirmInfoBarDelegate>(
new PermissionUpdateInfoBarDelegate(web_contents, android_permissions,
permission_msg_id, callback))));
permission_msg_id,
std::move(callback)))));
}
// static
......@@ -126,7 +128,7 @@ void PermissionUpdateInfoBarDelegate::OnPermissionResult(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
jboolean all_permissions_granted) {
base::ResetAndReturn(&callback_).Run(all_permissions_granted);
std::move(callback_).Run(all_permissions_granted);
infobar()->RemoveSelf();
}
......@@ -134,11 +136,11 @@ PermissionUpdateInfoBarDelegate::PermissionUpdateInfoBarDelegate(
content::WebContents* web_contents,
const std::vector<std::string>& android_permissions,
int permission_msg_id,
const PermissionUpdatedCallback& callback)
PermissionUpdatedCallback callback)
: ConfirmInfoBarDelegate(),
android_permissions_(android_permissions),
permission_msg_id_(permission_msg_id),
callback_(callback) {
callback_(std::move(callback)) {
JNIEnv* env = base::android::AttachCurrentThread();
java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create(
env, reinterpret_cast<intptr_t>(this), web_contents->GetJavaWebContents(),
......
......@@ -35,7 +35,7 @@ enum class ShowPermissionInfoBarState {
// permissions for previously allowed ContentSettingsTypes.
class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
using PermissionUpdatedCallback = base::Callback<void(bool)>;
using PermissionUpdatedCallback = base::OnceCallback<void(bool)>;
// Creates an infobar to resolve conflicts in Android runtime permissions.
// The necessary runtime permissions are generated based on the list of
......@@ -53,7 +53,7 @@ class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate {
static infobars::InfoBar* Create(
content::WebContents* web_contents,
const std::vector<ContentSettingsType>& content_settings_types,
const PermissionUpdatedCallback& callback);
PermissionUpdatedCallback callback);
// Creates an infobar to resolve conflicts in Android runtime permissions.
// Returns the infobar if it was successfully added.
......@@ -63,7 +63,7 @@ class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate {
content::WebContents* web_contents,
const std::vector<std::string>& android_permissions,
int permission_msg_id,
const PermissionUpdatedCallback& callback);
PermissionUpdatedCallback callback);
// Returns an indicator of whether a permission infobar should be shown or
// not or cannot be shown.
......@@ -80,7 +80,7 @@ class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate {
content::WebContents* web_contents,
const std::vector<std::string>& android_permissions,
int permission_msg_id,
const PermissionUpdatedCallback& callback);
PermissionUpdatedCallback callback);
~PermissionUpdateInfoBarDelegate() override;
// InfoBarDelegate:
......
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