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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java

Issue 2138643004: [Autofill] Add support for signin promo on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aaa
Patch Set: another include Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.support.annotation.IntDef; 10 import android.support.annotation.IntDef;
(...skipping 23 matching lines...) Expand all
34 implements AccountSigninView.Listener, AccountSigninView.Delegate { 34 implements AccountSigninView.Listener, AccountSigninView.Delegate {
35 private static final String TAG = "AccountSigninActivity"; 35 private static final String TAG = "AccountSigninActivity";
36 private static final String INTENT_SIGNIN_ACCESS_POINT = 36 private static final String INTENT_SIGNIN_ACCESS_POINT =
37 "AccountSigninActivity.SigninAccessPoint"; 37 "AccountSigninActivity.SigninAccessPoint";
38 38
39 private AccountSigninView mView; 39 private AccountSigninView mView;
40 private ProfileDataCache mProfileDataCache; 40 private ProfileDataCache mProfileDataCache;
41 41
42 @IntDef({SigninAccessPoint.SETTINGS, SigninAccessPoint.BOOKMARK_MANAGER, 42 @IntDef({SigninAccessPoint.SETTINGS, SigninAccessPoint.BOOKMARK_MANAGER,
43 SigninAccessPoint.RECENT_TABS, SigninAccessPoint.SIGNIN_PROMO, 43 SigninAccessPoint.RECENT_TABS, SigninAccessPoint.SIGNIN_PROMO,
44 SigninAccessPoint.NTP_LINK}) 44 SigninAccessPoint.NTP_LINK, SigninAccessPoint.AUTOFILL_DROPDOWN})
45 @Retention(RetentionPolicy.SOURCE) 45 @Retention(RetentionPolicy.SOURCE)
46 public @interface AccessPoint {} 46 public @interface AccessPoint {}
47 @AccessPoint private int mAccessPoint; 47 @AccessPoint private int mAccessPoint;
48 48
49 /** 49 /**
50 * A convenience method to create a AccountSigninActivity passing the access point as an 50 * A convenience method to create a AccountSigninActivity passing the access point as an
51 * intent. 51 * intent.
52 * @param accessPoint - A SigninAccessPoint designating where the activity i s created from. 52 * @param accessPoint - A SigninAccessPoint designating where the activity i s created from.
53 */ 53 */
54 public static void startAccountSigninActivity(Context context, @AccessPoint int accessPoint) { 54 public static void startAccountSigninActivity(
55 Context context, @AccessPoint int accessPoint, boolean useNewTaskFla g) {
55 Intent intent = new Intent(context, AccountSigninActivity.class); 56 Intent intent = new Intent(context, AccountSigninActivity.class);
56 intent.putExtra(INTENT_SIGNIN_ACCESS_POINT, accessPoint); 57 intent.putExtra(INTENT_SIGNIN_ACCESS_POINT, accessPoint);
58 if (useNewTaskFlag) {
Ted C 2016/07/19 20:21:48 another thing if you find yourself doing this in t
Mathieu 2016/07/19 21:00:19 Acknowledged.
59 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
60 }
57 context.startActivity(intent); 61 context.startActivity(intent);
58 } 62 }
59 63
60 /** 64 /**
61 * A convenience method to create a AccountSigninActivity passing the access point as an 65 * A convenience method to create a AccountSigninActivity passing the access point as an
62 * intent. Checks if the sign in flow can be started before showing the acti vity. 66 * intent. Checks if the sign in flow can be started before showing the acti vity.
63 * @param accessPoint - A SigninAccessPoint designating where the activity i s created from. 67 * @param accessPoint - A SigninAccessPoint designating where the activity i s created from.
64 * @return {@code true} if sign in has been allowed. 68 * @return {@code true} if sign in has been allowed.
65 */ 69 */
66 public static boolean startIfAllowed(Context context, @AccessPoint int acces sPoint) { 70 public static boolean startIfAllowed(Context context, @AccessPoint int acces sPoint) {
67 if (!SigninManager.get(context).isSignInAllowed()) { 71 if (!SigninManager.get(context).isSignInAllowed()) {
68 if (SigninManager.get(context).isSigninDisabledByPolicy()) { 72 if (SigninManager.get(context).isSigninDisabledByPolicy()) {
69 ManagedPreferencesUtils.showManagedByAdministratorToast(context) ; 73 ManagedPreferencesUtils.showManagedByAdministratorToast(context) ;
70 } 74 }
71 return false; 75 return false;
72 } 76 }
73 77
74 startAccountSigninActivity(context, accessPoint); 78 startAccountSigninActivity(context, accessPoint, /* useNewTaskFlag */ fa lse);
75 return true; 79 return true;
76 } 80 }
77 81
78 @Override 82 @Override
79 @SuppressFBWarnings("DM_EXIT") 83 @SuppressFBWarnings("DM_EXIT")
80 protected void onCreate(Bundle savedInstanceState) { 84 protected void onCreate(Bundle savedInstanceState) {
81 // The browser process must be started here because this activity may be started from the 85 // The browser process must be started here because this activity may be started from the
82 // recent apps list and it relies on other activities and the native lib rary to be loaded. 86 // recent apps list and it relies on other activities and the native lib rary to be loaded.
83 try { 87 try {
84 ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup( ); 88 ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup( );
85 } catch (ProcessInitException e) { 89 } catch (ProcessInitException e) {
86 Log.e(TAG, "Failed to start browser process.", e); 90 Log.e(TAG, "Failed to start browser process.", e);
87 // Since the library failed to initialize nothing in the application 91 // Since the library failed to initialize nothing in the application
88 // can work, so kill the whole application not just the activity 92 // can work, so kill the whole application not just the activity
89 System.exit(-1); 93 System.exit(-1);
90 } 94 }
91 95
92 // We don't trust android to restore the saved state correctly, so pass null. 96 // We don't trust android to restore the saved state correctly, so pass null.
93 super.onCreate(null); 97 super.onCreate(null);
94 98
95 mAccessPoint = getIntent().getIntExtra(INTENT_SIGNIN_ACCESS_POINT, -1); 99 mAccessPoint = getIntent().getIntExtra(INTENT_SIGNIN_ACCESS_POINT, -1);
96 assert mAccessPoint == SigninAccessPoint.BOOKMARK_MANAGER 100 assert mAccessPoint == SigninAccessPoint.BOOKMARK_MANAGER
97 || mAccessPoint == SigninAccessPoint.RECENT_TABS 101 || mAccessPoint == SigninAccessPoint.RECENT_TABS
98 || mAccessPoint == SigninAccessPoint.SETTINGS 102 || mAccessPoint == SigninAccessPoint.SETTINGS
99 || mAccessPoint == SigninAccessPoint.SIGNIN_PROMO 103 || mAccessPoint == SigninAccessPoint.SIGNIN_PROMO
100 : "invalid access point: " + mAccessPoint; 104 || mAccessPoint
105 == SigninAccessPoint.AUTOFILL_DROPDOWN : "invalid access point: "
106 + mAccessPoint;
101 107
102 mView = (AccountSigninView) LayoutInflater.from(this).inflate( 108 mView = (AccountSigninView) LayoutInflater.from(this).inflate(
103 R.layout.account_signin_view, null); 109 R.layout.account_signin_view, null);
104 mView.init(getProfileDataCache()); 110 mView.init(getProfileDataCache());
105 mView.setListener(this); 111 mView.setListener(this);
106 mView.setDelegate(this); 112 mView.setDelegate(this);
107 113
108 if (getAccessPoint() == SigninAccessPoint.BOOKMARK_MANAGER 114 if (getAccessPoint() == SigninAccessPoint.BOOKMARK_MANAGER
109 || getAccessPoint() == SigninAccessPoint.RECENT_TABS) { 115 || getAccessPoint() == SigninAccessPoint.RECENT_TABS) {
110 mView.configureForRecentTabsOrBookmarksPage(); 116 mView.configureForRecentTabsOrBookmarksPage();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 @Override 172 @Override
167 public void onSignInAborted() {} 173 public void onSignInAborted() {}
168 }); 174 });
169 } 175 }
170 176
171 @Override 177 @Override
172 public void onFailedToSetForcedAccount(String forcedAccountName) {} 178 public void onFailedToSetForcedAccount(String forcedAccountName) {}
173 179
174 private void recordSigninStartedUserAction() { 180 private void recordSigninStartedUserAction() {
175 switch (getAccessPoint()) { 181 switch (getAccessPoint()) {
182 case SigninAccessPoint.AUTOFILL_DROPDOWN:
183 RecordUserAction.record("Signin_Signin_FromAutofillDropdown");
184 break;
176 case SigninAccessPoint.BOOKMARK_MANAGER: 185 case SigninAccessPoint.BOOKMARK_MANAGER:
177 RecordUserAction.record("Signin_Signin_FromBookmarkManager"); 186 RecordUserAction.record("Signin_Signin_FromBookmarkManager");
178 break; 187 break;
179 case SigninAccessPoint.RECENT_TABS: 188 case SigninAccessPoint.RECENT_TABS:
180 RecordUserAction.record("Signin_Signin_FromRecentTabs"); 189 RecordUserAction.record("Signin_Signin_FromRecentTabs");
181 break; 190 break;
182 case SigninAccessPoint.SETTINGS: 191 case SigninAccessPoint.SETTINGS:
183 RecordUserAction.record("Signin_Signin_FromSettings"); 192 RecordUserAction.record("Signin_Signin_FromSettings");
184 break; 193 break;
185 case SigninAccessPoint.SIGNIN_PROMO: 194 case SigninAccessPoint.SIGNIN_PROMO:
186 RecordUserAction.record("Signin_Signin_FromSigninPromo"); 195 RecordUserAction.record("Signin_Signin_FromSigninPromo");
187 break; 196 break;
188 default: 197 default:
189 assert false : "Invalid access point."; 198 assert false : "Invalid access point.";
190 } 199 }
191 } 200 }
192 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698