| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.signin; | 5 package org.chromium.chrome.browser.signin; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 | 9 |
| 10 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 11 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
| 11 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 12 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| 12 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 13 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 13 import org.chromium.sync.signin.ChromeSigninController; | 14 import org.chromium.sync.signin.ChromeSigninController; |
| 15 import org.chromium.ui.base.WindowAndroid; |
| 14 | 16 |
| 15 /** | 17 /** |
| 16 * Helper functions for promoting sign in. | 18 * Helper functions for promoting sign in. |
| 17 */ | 19 */ |
| 18 public class SigninPromoUtil { | 20 public class SigninPromoUtil { |
| 19 private SigninPromoUtil() {} | 21 private SigninPromoUtil() {} |
| 20 | 22 |
| 21 /** | 23 /** |
| 22 * Launches the signin promo if it needs to be displayed. | 24 * Launches the signin promo if it needs to be displayed. |
| 23 * @param activity The parent activity. | 25 * @param activity The parent activity. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 | 36 |
| 35 String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccount
Name(); | 37 String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccount
Name(); |
| 36 if (ChromeSigninController.get(activity).isSignedIn() || !TextUtils.isEm
pty(lastSyncName)) { | 38 if (ChromeSigninController.get(activity).isSignedIn() || !TextUtils.isEm
pty(lastSyncName)) { |
| 37 return false; | 39 return false; |
| 38 } | 40 } |
| 39 | 41 |
| 40 AccountSigninActivity.startAccountSigninActivity(activity, SigninAccessP
oint.SIGNIN_PROMO); | 42 AccountSigninActivity.startAccountSigninActivity(activity, SigninAccessP
oint.SIGNIN_PROMO); |
| 41 preferenceManager.setSigninPromoShown(); | 43 preferenceManager.setSigninPromoShown(); |
| 42 return true; | 44 return true; |
| 43 } | 45 } |
| 46 |
| 47 /** |
| 48 * A convenience method to create an AccountSigninActivity, passing the acce
ss point as an |
| 49 * intent extra. |
| 50 * @param window WindowAndroid from which to get the Activity/Context. |
| 51 * @param accessPoint for metrics purposes. |
| 52 */ |
| 53 @CalledByNative |
| 54 private static void openAccountSigninActivityForPromo(WindowAndroid window,
int accessPoint) { |
| 55 Activity activity = window.getActivity().get(); |
| 56 if (activity != null) { |
| 57 AccountSigninActivity.startIfAllowed(activity, accessPoint); |
| 58 } |
| 59 } |
| 44 } | 60 } |
| OLD | NEW |