OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.util; | 5 package org.chromium.chrome.browser.util; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 * @return Whether or not sync is allowed on this device. | 82 * @return Whether or not sync is allowed on this device. |
83 */ | 83 */ |
84 public static boolean canAllowSync(Context context) { | 84 public static boolean canAllowSync(Context context) { |
85 return (hasGoogleAccountAuthenticator(context) && hasSyncPermissions(con
text)) | 85 return (hasGoogleAccountAuthenticator(context) && hasSyncPermissions(con
text)) |
86 || hasGoogleAccounts(context); | 86 || hasGoogleAccounts(context); |
87 } | 87 } |
88 | 88 |
89 @VisibleForTesting | 89 @VisibleForTesting |
90 static boolean hasGoogleAccountAuthenticator(Context context) { | 90 static boolean hasGoogleAccountAuthenticator(Context context) { |
91 if (sHasGoogleAccountAuthenticator == null) { | 91 if (sHasGoogleAccountAuthenticator == null) { |
92 AccountManagerHelper accountHelper = AccountManagerHelper.get(contex
t); | 92 AccountManagerHelper accountHelper = AccountManagerHelper.get(); |
93 sHasGoogleAccountAuthenticator = accountHelper.hasGoogleAccountAuthe
nticator(); | 93 sHasGoogleAccountAuthenticator = accountHelper.hasGoogleAccountAuthe
nticator(); |
94 } | 94 } |
95 return sHasGoogleAccountAuthenticator; | 95 return sHasGoogleAccountAuthenticator; |
96 } | 96 } |
97 | 97 |
98 @VisibleForTesting | 98 @VisibleForTesting |
99 static boolean hasGoogleAccounts(Context context) { | 99 static boolean hasGoogleAccounts(Context context) { |
100 return AccountManagerHelper.get(context).hasGoogleAccounts(); | 100 return AccountManagerHelper.get().hasGoogleAccounts(); |
101 } | 101 } |
102 | 102 |
103 @SuppressLint("InlinedApi") | 103 @SuppressLint("InlinedApi") |
104 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) | 104 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) |
105 private static boolean hasSyncPermissions(Context context) { | 105 private static boolean hasSyncPermissions(Context context) { |
106 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return t
rue; | 106 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return t
rue; |
107 | 107 |
108 UserManager manager = (UserManager) context.getSystemService(Context.USE
R_SERVICE); | 108 UserManager manager = (UserManager) context.getSystemService(Context.USE
R_SERVICE); |
109 Bundle userRestrictions = manager.getUserRestrictions(); | 109 Bundle userRestrictions = manager.getUserRestrictions(); |
110 return !userRestrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS
, false); | 110 return !userRestrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS
, false); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (sChromeHomeEnabled == null) { | 261 if (sChromeHomeEnabled == null) { |
262 sChromeHomeEnabled = ChromePreferenceManager.getInstance().isChromeH
omeEnabled(); | 262 sChromeHomeEnabled = ChromePreferenceManager.getInstance().isChromeH
omeEnabled(); |
263 } | 263 } |
264 | 264 |
265 return sChromeHomeEnabled; | 265 return sChromeHomeEnabled; |
266 } | 266 } |
267 | 267 |
268 private static native void nativeSetCustomTabVisible(boolean visible); | 268 private static native void nativeSetCustomTabVisible(boolean visible); |
269 private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWin
dowMode); | 269 private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWin
dowMode); |
270 } | 270 } |
OLD | NEW |