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.content.Context; | |
8 import android.content.Intent; | 7 import android.content.Intent; |
9 import android.provider.Settings; | 8 import android.provider.Settings; |
10 | 9 |
| 10 import org.chromium.base.ContextUtils; |
11 import org.chromium.base.ThreadUtils; | 11 import org.chromium.base.ThreadUtils; |
12 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
13 import org.chromium.chrome.browser.profiles.Profile; | 13 import org.chromium.chrome.browser.profiles.Profile; |
14 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics; | 14 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics; |
15 | 15 |
16 /** | 16 /** |
17 * Stub entry points and implementation interface for the account management fra
gment delegate. | 17 * Stub entry points and implementation interface for the account management fra
gment delegate. |
18 */ | 18 */ |
19 public class AccountManagementScreenHelper { | 19 public class AccountManagementScreenHelper { |
20 | 20 |
(...skipping 10 matching lines...) Expand all Loading... |
31 /** | 31 /** |
32 * The signin::GAIAServiceType value used when openAndroidAccountCreationScr
een is triggered by | 32 * The signin::GAIAServiceType value used when openAndroidAccountCreationScr
een is triggered by |
33 * the GAIA service to create a new account | 33 * the GAIA service to create a new account |
34 */ | 34 */ |
35 public static final int GAIA_SERVICE_TYPE_SIGNUP = 5; | 35 public static final int GAIA_SERVICE_TYPE_SIGNUP = 5; |
36 | 36 |
37 private static final String EXTRA_ACCOUNT_TYPES = "account_types"; | 37 private static final String EXTRA_ACCOUNT_TYPES = "account_types"; |
38 private static final String EXTRA_VALUE_GOOGLE_ACCOUNTS = "com.google"; | 38 private static final String EXTRA_VALUE_GOOGLE_ACCOUNTS = "com.google"; |
39 | 39 |
40 @CalledByNative | 40 @CalledByNative |
41 private static void openAccountManagementScreen( | 41 private static void openAccountManagementScreen(Profile profile, int gaiaSer
viceType) { |
42 Context applicationContext, Profile profile, int gaiaServiceType) { | |
43 ThreadUtils.assertOnUiThread(); | 42 ThreadUtils.assertOnUiThread(); |
44 | 43 |
45 if (gaiaServiceType == GAIA_SERVICE_TYPE_SIGNUP) { | 44 if (gaiaServiceType == GAIA_SERVICE_TYPE_SIGNUP) { |
46 openAndroidAccountCreationScreen(applicationContext); | 45 openAndroidAccountCreationScreen(); |
47 return; | 46 return; |
48 } | 47 } |
49 | 48 |
50 AccountManagementFragment.openAccountManagementScreen( | 49 AccountManagementFragment.openAccountManagementScreen(gaiaServiceType); |
51 applicationContext, profile, gaiaServiceType); | |
52 } | 50 } |
53 | 51 |
54 /** | 52 /** |
55 * Opens the Android account manager for adding or creating a Google account
. | 53 * Opens the Android account manager for adding or creating a Google account
. |
56 * @param applicationContext | |
57 */ | 54 */ |
58 private static void openAndroidAccountCreationScreen( | 55 private static void openAndroidAccountCreationScreen() { |
59 Context applicationContext) { | |
60 logEvent(ProfileAccountManagementMetrics.DIRECT_ADD_ACCOUNT, GAIA_SERVIC
E_TYPE_SIGNUP); | 56 logEvent(ProfileAccountManagementMetrics.DIRECT_ADD_ACCOUNT, GAIA_SERVIC
E_TYPE_SIGNUP); |
61 | 57 |
62 Intent createAccountIntent = new Intent(Settings.ACTION_ADD_ACCOUNT); | 58 Intent createAccountIntent = new Intent(Settings.ACTION_ADD_ACCOUNT); |
63 createAccountIntent.putExtra( | 59 createAccountIntent.putExtra( |
64 EXTRA_ACCOUNT_TYPES, new String[]{EXTRA_VALUE_GOOGLE_ACCOUNTS}); | 60 EXTRA_ACCOUNT_TYPES, new String[]{EXTRA_VALUE_GOOGLE_ACCOUNTS}); |
65 createAccountIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | 61 createAccountIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT |
66 | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TAS
K | 62 | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TAS
K |
67 | Intent.FLAG_ACTIVITY_CLEAR_TOP); | 63 | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
68 | 64 |
69 applicationContext.startActivity(createAccountIntent); | 65 ContextUtils.getApplicationContext().startActivity(createAccountIntent); |
70 } | 66 } |
71 | 67 |
72 /** | 68 /** |
73 * Log a UMA event for a given metric and a signin type. | 69 * Log a UMA event for a given metric and a signin type. |
74 * @param metric One of ProfileAccountManagementMetrics constants. | 70 * @param metric One of ProfileAccountManagementMetrics constants. |
75 * @param gaiaServiceType A signin::GAIAServiceType. | 71 * @param gaiaServiceType A signin::GAIAServiceType. |
76 */ | 72 */ |
77 public static void logEvent(int metric, int gaiaServiceType) { | 73 public static void logEvent(int metric, int gaiaServiceType) { |
78 nativeLogEvent(metric, gaiaServiceType); | 74 nativeLogEvent(metric, gaiaServiceType); |
79 } | 75 } |
80 | 76 |
81 // Native methods. | 77 // Native methods. |
82 private static native void nativeLogEvent(int metric, int gaiaServiceType); | 78 private static native void nativeLogEvent(int metric, int gaiaServiceType); |
83 } | 79 } |
OLD | NEW |