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

Unified Diff: components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java

Issue 2745533002: Fixed permission check in SystemAccountManagerDelegate.updateCredentials (Closed)
Patch Set: Added MANAGE_ACCOUNTS check Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
diff --git a/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java b/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
index ebbc3ddaaaa8e726fa7f027b8b75d7925ed40c3e..1f27097c1f1297f8058ec91fb10aa9433ced9998 100644
--- a/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
+++ b/components/signin/core/browser/android/java/src/org/chromium/components/signin/SystemAccountManagerDelegate.java
@@ -16,6 +16,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
+import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.SystemClock;
@@ -161,13 +162,15 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
public void updateCredentials(
Account account, Activity activity, final Callback<Boolean> callback) {
ThreadUtils.assertOnUiThread();
- if (!hasGetAccountsPermission()) {
- ThreadUtils.postOnUiThread(new Runnable() {
- @Override
- public void run() {
- callback.onResult(false);
- }
- });
+ if (!hasManageAccountsPermission()) {
+ if (callback != null) {
nyquist 2017/03/10 19:07:45 if (callback == null) return; It reduces indents,
bsazonov 2017/03/13 12:27:12 The Style Guide allows both one-line and braced if
+ ThreadUtils.postOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ callback.onResult(false);
+ }
+ });
+ }
return;
}
@@ -198,4 +201,13 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
Manifest.permission.GET_ACCOUNTS, Process.myPid(), Process.myUid())
== PackageManager.PERMISSION_GRANTED;
}
+
+ protected boolean hasManageAccountsPermission() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
nyquist 2017/03/10 19:07:45 Optional nit: This can just be on one line. Fine l
bsazonov 2017/03/13 12:27:12 See previous comment.
+ return true;
+ }
+ return ApiCompatibilityUtils.checkPermission(mApplicationContext,
+ "android.permission.MANAGE_ACCOUNTS", Process.myPid(), Process.myUid())
+ == PackageManager.PERMISSION_GRANTED;
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698