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.base.annotations.CalledByNative; |
(...skipping 17 matching lines...) Expand all Loading... |
28 public static boolean launchSigninPromoIfNeeded(final Activity activity) { | 28 public static boolean launchSigninPromoIfNeeded(final Activity activity) { |
29 // The promo is displayed if Chrome is launched directly (i.e., not with
the intent to | 29 // The promo is displayed if Chrome is launched directly (i.e., not with
the intent to |
30 // navigate to and view a URL on startup), the instance is part of the f
ield trial, | 30 // navigate to and view a URL on startup), the instance is part of the f
ield trial, |
31 // and the promo has been marked to display. | 31 // and the promo has been marked to display. |
32 ChromePreferenceManager preferenceManager = ChromePreferenceManager.getI
nstance(); | 32 ChromePreferenceManager preferenceManager = ChromePreferenceManager.getI
nstance(); |
33 if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return
false; | 33 if (MultiWindowUtils.getInstance().isLegacyMultiWindow(activity)) return
false; |
34 if (!preferenceManager.getShowSigninPromo()) return false; | 34 if (!preferenceManager.getShowSigninPromo()) return false; |
35 preferenceManager.setShowSigninPromo(false); | 35 preferenceManager.setShowSigninPromo(false); |
36 | 36 |
37 String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccount
Name(); | 37 String lastSyncName = PrefServiceBridge.getInstance().getSyncLastAccount
Name(); |
38 if (ChromeSigninController.get().isSignedIn() || !TextUtils.isEmpty(last
SyncName)) { | 38 if (ChromeSigninController.get(activity).isSignedIn() || !TextUtils.isEm
pty(lastSyncName)) { |
39 return false; | 39 return false; |
40 } | 40 } |
41 | 41 |
42 AccountSigninActivity.startIfAllowed(activity, SigninAccessPoint.SIGNIN_
PROMO); | 42 AccountSigninActivity.startIfAllowed(activity, SigninAccessPoint.SIGNIN_
PROMO); |
43 preferenceManager.setSigninPromoShown(); | 43 preferenceManager.setSigninPromoShown(); |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 /** | 47 /** |
48 * A convenience method to create an AccountSigninActivity, passing the acce
ss point as an | 48 * A convenience method to create an AccountSigninActivity, passing the acce
ss point as an |
49 * intent extra. | 49 * intent extra. |
50 * @param window WindowAndroid from which to get the Activity/Context. | 50 * @param window WindowAndroid from which to get the Activity/Context. |
51 * @param accessPoint for metrics purposes. | 51 * @param accessPoint for metrics purposes. |
52 */ | 52 */ |
53 @CalledByNative | 53 @CalledByNative |
54 private static void openAccountSigninActivityForPromo(WindowAndroid window,
int accessPoint) { | 54 private static void openAccountSigninActivityForPromo(WindowAndroid window,
int accessPoint) { |
55 Activity activity = window.getActivity().get(); | 55 Activity activity = window.getActivity().get(); |
56 if (activity != null) { | 56 if (activity != null) { |
57 AccountSigninActivity.startIfAllowed(activity, accessPoint); | 57 AccountSigninActivity.startIfAllowed(activity, accessPoint); |
58 } | 58 } |
59 } | 59 } |
60 } | 60 } |
OLD | NEW |