| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.app.FragmentManager; |
| 8 import android.content.Intent; | 9 import android.content.Intent; |
| 9 import android.os.Bundle; | 10 import android.os.Bundle; |
| 10 import android.text.TextUtils; | 11 import android.text.TextUtils; |
| 11 import android.view.LayoutInflater; | 12 import android.view.LayoutInflater; |
| 12 import android.view.View; | 13 import android.view.View; |
| 13 import android.widget.LinearLayout; | 14 import android.widget.LinearLayout; |
| 14 | 15 |
| 15 import org.chromium.base.metrics.RecordUserAction; | 16 import org.chromium.base.metrics.RecordUserAction; |
| 16 import org.chromium.chrome.R; | 17 import org.chromium.chrome.R; |
| 17 import org.chromium.chrome.browser.firstrun.AccountFirstRunView; | |
| 18 import org.chromium.chrome.browser.firstrun.ProfileDataCache; | 18 import org.chromium.chrome.browser.firstrun.ProfileDataCache; |
| 19 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 19 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
| 20 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 20 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| 21 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 21 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 22 import org.chromium.chrome.browser.preferences.Preferences; | 22 import org.chromium.chrome.browser.preferences.Preferences; |
| 23 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 23 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
| 24 import org.chromium.chrome.browser.profiles.Profile; | 24 import org.chromium.chrome.browser.profiles.Profile; |
| 25 import org.chromium.chrome.browser.signin.SigninManager.SignInCallback; | 25 import org.chromium.chrome.browser.signin.SigninManager.SignInCallback; |
| 26 import org.chromium.chrome.browser.sync.ProfileSyncService; | 26 import org.chromium.chrome.browser.sync.ProfileSyncService; |
| 27 import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment; | 27 import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment; |
| 28 import org.chromium.chrome.browser.widget.AlwaysDismissedDialog; | 28 import org.chromium.chrome.browser.widget.AlwaysDismissedDialog; |
| 29 import org.chromium.sync.signin.ChromeSigninController; | 29 import org.chromium.sync.signin.ChromeSigninController; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * This class implements the dialog UI for the signin promo. | 32 * This class implements the dialog UI for the signin promo. |
| 33 */ | 33 */ |
| 34 public class SigninPromoScreen | 34 public class SigninPromoScreen extends AlwaysDismissedDialog |
| 35 extends AlwaysDismissedDialog implements AccountFirstRunView.Listener { | 35 implements AccountSigninView.Listener, AccountSigninView.Delegate { |
| 36 private AccountFirstRunView mAccountFirstRunView; | 36 private AccountSigninView mAccountFirstRunView; |
| 37 private ProfileDataCache mProfileDataCache; | 37 private ProfileDataCache mProfileDataCache; |
| 38 private String mAccountName; | 38 private String mAccountName; |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Launches the signin promo if it needs to be displayed. | 41 * Launches the signin promo if it needs to be displayed. |
| 42 * @param activity The parent activity. | 42 * @param activity The parent activity. |
| 43 * @return Whether the signin promo is shown. | 43 * @return Whether the signin promo is shown. |
| 44 */ | 44 */ |
| 45 public static boolean launchSigninPromoIfNeeded(final Activity activity) { | 45 public static boolean launchSigninPromoIfNeeded(final Activity activity) { |
| 46 // The promo is displayed if Chrome is launched directly (i.e., not with
the intent to | 46 // The promo is displayed if Chrome is launched directly (i.e., not with
the intent to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 /** | 68 /** |
| 69 * SigninPromoScreen constructor. | 69 * SigninPromoScreen constructor. |
| 70 * | 70 * |
| 71 * @param activity An Android activity. | 71 * @param activity An Android activity. |
| 72 */ | 72 */ |
| 73 private SigninPromoScreen(Activity activity) { | 73 private SigninPromoScreen(Activity activity) { |
| 74 super(activity, R.style.SigninPromoDialog); | 74 super(activity, R.style.SigninPromoDialog); |
| 75 setOwnerActivity(activity); | 75 setOwnerActivity(activity); |
| 76 | 76 |
| 77 LayoutInflater inflater = LayoutInflater.from(activity); | 77 LayoutInflater inflater = LayoutInflater.from(activity); |
| 78 View view = inflater.inflate(R.layout.fre_choose_account, null); | 78 View view = inflater.inflate(R.layout.account_signin_view, null); |
| 79 mProfileDataCache = new ProfileDataCache(activity, Profile.getLastUsedPr
ofile()); | 79 mProfileDataCache = new ProfileDataCache(activity, Profile.getLastUsedPr
ofile()); |
| 80 mAccountFirstRunView = (AccountFirstRunView) view.findViewById(R.id.fre_
account_layout); | 80 mAccountFirstRunView = (AccountSigninView) view.findViewById(R.id.accoun
t_layout); |
| 81 mAccountFirstRunView.init(mProfileDataCache); | 81 mAccountFirstRunView.init(mProfileDataCache); |
| 82 mAccountFirstRunView.configureForAddAccountPromo(); | 82 mAccountFirstRunView.configureForAddAccountPromo(); |
| 83 mAccountFirstRunView.setListener(this); | 83 mAccountFirstRunView.setListener(this); |
| 84 mAccountFirstRunView.setDelegate(this); |
| 84 | 85 |
| 85 setContentView(view, new LinearLayout.LayoutParams( | 86 setContentView(view, new LinearLayout.LayoutParams( |
| 86 LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParam
s.MATCH_PARENT)); | 87 LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParam
s.MATCH_PARENT)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 @Override | 90 @Override |
| 90 protected void onCreate(Bundle savedInstanceState) { | 91 protected void onCreate(Bundle savedInstanceState) { |
| 91 super.onCreate(savedInstanceState); | 92 super.onCreate(savedInstanceState); |
| 92 SigninPromoUma.recordAction(SigninPromoUma.SIGNIN_PROMO_SHOWN); | 93 SigninPromoUma.recordAction(SigninPromoUma.SIGNIN_PROMO_SHOWN); |
| 93 RecordUserAction.record("Signin_Impression_FromSigninPromo"); | 94 RecordUserAction.record("Signin_Impression_FromSigninPromo"); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 147 } |
| 147 | 148 |
| 148 SigninPromoUma.recordAction(SigninPromoUma.SIGNIN_PROMO_ACCEPTED_WITH_AD
VANCED); | 149 SigninPromoUma.recordAction(SigninPromoUma.SIGNIN_PROMO_ACCEPTED_WITH_AD
VANCED); |
| 149 dismiss(); | 150 dismiss(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 @Override | 153 @Override |
| 153 public void onFailedToSetForcedAccount(String forcedAccountName) { | 154 public void onFailedToSetForcedAccount(String forcedAccountName) { |
| 154 assert false : "No forced accounts in SigninPromoScreen"; | 155 assert false : "No forced accounts in SigninPromoScreen"; |
| 155 } | 156 } |
| 157 |
| 158 @Override |
| 159 public FragmentManager getFragmentManager() { |
| 160 return getOwnerActivity().getFragmentManager(); |
| 161 } |
| 156 } | 162 } |
| OLD | NEW |