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

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

Issue 2800833003: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Created 3 years, 8 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 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;
7 import android.content.Intent; 8 import android.content.Intent;
8 import android.provider.Settings; 9 import android.provider.Settings;
9 10
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
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(Profile profile, int gaiaSer viceType) { 41 private static void openAccountManagementScreen(
42 Context applicationContext, Profile profile, int gaiaServiceType) {
42 ThreadUtils.assertOnUiThread(); 43 ThreadUtils.assertOnUiThread();
43 44
44 if (gaiaServiceType == GAIA_SERVICE_TYPE_SIGNUP) { 45 if (gaiaServiceType == GAIA_SERVICE_TYPE_SIGNUP) {
45 openAndroidAccountCreationScreen(); 46 openAndroidAccountCreationScreen(applicationContext);
46 return; 47 return;
47 } 48 }
48 49
49 AccountManagementFragment.openAccountManagementScreen(gaiaServiceType); 50 AccountManagementFragment.openAccountManagementScreen(
51 applicationContext, profile, gaiaServiceType);
50 } 52 }
51 53
52 /** 54 /**
53 * Opens the Android account manager for adding or creating a Google account . 55 * Opens the Android account manager for adding or creating a Google account .
56 * @param applicationContext
54 */ 57 */
55 private static void openAndroidAccountCreationScreen() { 58 private static void openAndroidAccountCreationScreen(
59 Context applicationContext) {
56 logEvent(ProfileAccountManagementMetrics.DIRECT_ADD_ACCOUNT, GAIA_SERVIC E_TYPE_SIGNUP); 60 logEvent(ProfileAccountManagementMetrics.DIRECT_ADD_ACCOUNT, GAIA_SERVIC E_TYPE_SIGNUP);
57 61
58 Intent createAccountIntent = new Intent(Settings.ACTION_ADD_ACCOUNT); 62 Intent createAccountIntent = new Intent(Settings.ACTION_ADD_ACCOUNT);
59 createAccountIntent.putExtra( 63 createAccountIntent.putExtra(
60 EXTRA_ACCOUNT_TYPES, new String[]{EXTRA_VALUE_GOOGLE_ACCOUNTS}); 64 EXTRA_ACCOUNT_TYPES, new String[]{EXTRA_VALUE_GOOGLE_ACCOUNTS});
61 createAccountIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT 65 createAccountIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
62 | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TAS K 66 | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TAS K
63 | Intent.FLAG_ACTIVITY_CLEAR_TOP); 67 | Intent.FLAG_ACTIVITY_CLEAR_TOP);
64 68
65 ContextUtils.getApplicationContext().startActivity(createAccountIntent); 69 applicationContext.startActivity(createAccountIntent);
66 } 70 }
67 71
68 /** 72 /**
69 * Log a UMA event for a given metric and a signin type. 73 * Log a UMA event for a given metric and a signin type.
70 * @param metric One of ProfileAccountManagementMetrics constants. 74 * @param metric One of ProfileAccountManagementMetrics constants.
71 * @param gaiaServiceType A signin::GAIAServiceType. 75 * @param gaiaServiceType A signin::GAIAServiceType.
72 */ 76 */
73 public static void logEvent(int metric, int gaiaServiceType) { 77 public static void logEvent(int metric, int gaiaServiceType) {
74 nativeLogEvent(metric, gaiaServiceType); 78 nativeLogEvent(metric, gaiaServiceType);
75 } 79 }
76 80
77 // Native methods. 81 // Native methods.
78 private static native void nativeLogEvent(int metric, int gaiaServiceType); 82 private static native void nativeLogEvent(int metric, int gaiaServiceType);
79 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698