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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/SignInPreference.java

Issue 2784353002: Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Fix tests 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.preferences; 5 package org.chromium.chrome.browser.preferences;
6 6
7 import android.accounts.Account; 7 import android.accounts.Account;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Resources; 9 import android.content.res.Resources;
10 import android.graphics.Bitmap; 10 import android.graphics.Bitmap;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 /** 81 /**
82 * Updates the title, summary, and image based on the current sign-in state. 82 * Updates the title, summary, and image based on the current sign-in state.
83 */ 83 */
84 private void update() { 84 private void update() {
85 String title; 85 String title;
86 String summary; 86 String summary;
87 String fragment; 87 String fragment;
88 88
89 Account account = ChromeSigninController.get(getContext()).getSignedInUs er(); 89 Account account = ChromeSigninController.get().getSignedInUser();
90 if (account == null) { 90 if (account == null) {
91 title = getContext().getString(R.string.sign_in_to_chrome); 91 title = getContext().getString(R.string.sign_in_to_chrome);
92 summary = getContext().getString(R.string.sign_in_to_chrome_summary) ; 92 summary = getContext().getString(R.string.sign_in_to_chrome_summary) ;
93 fragment = null; 93 fragment = null;
94 } else { 94 } else {
95 summary = SyncPreference.getSyncStatusSummary(getContext()); 95 summary = SyncPreference.getSyncStatusSummary(getContext());
96 fragment = AccountManagementFragment.class.getName(); 96 fragment = AccountManagementFragment.class.getName();
97 title = AccountManagementFragment.getCachedUserName(account.name); 97 title = AccountManagementFragment.getCachedUserName(account.name);
98 if (title == null) { 98 if (title == null) {
99 final Profile profile = Profile.getLastUsedProfile(); 99 final Profile profile = Profile.getLastUsedProfile();
100 String cachedName = ProfileDownloader.getCachedFullName(profile) ; 100 String cachedName = ProfileDownloader.getCachedFullName(profile) ;
101 Bitmap cachedBitmap = ProfileDownloader.getCachedAvatar(profile) ; 101 Bitmap cachedBitmap = ProfileDownloader.getCachedAvatar(profile) ;
102 if (TextUtils.isEmpty(cachedName) || cachedBitmap == null) { 102 if (TextUtils.isEmpty(cachedName) || cachedBitmap == null) {
103 AccountManagementFragment.startFetchingAccountInformation( 103 AccountManagementFragment.startFetchingAccountInformation(
104 getContext(), profile, account.name); 104 getContext(), profile, account.name);
105 } 105 }
106 title = TextUtils.isEmpty(cachedName) ? account.name : cachedNam e; 106 title = TextUtils.isEmpty(cachedName) ? account.name : cachedNam e;
107 } 107 }
108 } 108 }
109 109
110 setTitle(title); 110 setTitle(title);
111 setSummary(summary); 111 setSummary(summary);
112 setFragment(fragment); 112 setFragment(fragment);
113 updateSyncStatusIcon(); 113 updateSyncStatusIcon();
114 114
115 ChromeSigninController signinController = ChromeSigninController.get(get Context()); 115 ChromeSigninController signinController = ChromeSigninController.get();
116 boolean enabled = signinController.isSignedIn() 116 boolean enabled = signinController.isSignedIn()
117 || SigninManager.get(getContext()).isSignInAllowed(); 117 || SigninManager.get(getContext()).isSignInAllowed();
118 if (mViewEnabled != enabled) { 118 if (mViewEnabled != enabled) {
119 mViewEnabled = enabled; 119 mViewEnabled = enabled;
120 notifyChanged(); 120 notifyChanged();
121 } 121 }
122 if (!enabled) setFragment(null); 122 if (!enabled) setFragment(null);
123 123
124 if (SigninManager.get(getContext()).isSigninDisabledByPolicy()) { 124 if (SigninManager.get(getContext()).isSigninDisabledByPolicy()) {
125 setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId()); 125 setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
(...skipping 17 matching lines...) Expand all
143 } 143 }
144 }); 144 });
145 145
146 if (account == null && enabled) { 146 if (account == null && enabled) {
147 RecordUserAction.record("Signin_Impression_FromSettings"); 147 RecordUserAction.record("Signin_Impression_FromSettings");
148 } 148 }
149 } 149 }
150 150
151 private void updateSyncStatusIcon() { 151 private void updateSyncStatusIcon() {
152 if (SyncPreference.showSyncErrorIcon(getContext()) 152 if (SyncPreference.showSyncErrorIcon(getContext())
153 && ChromeSigninController.get(getContext()).isSignedIn()) { 153 && ChromeSigninController.get().isSignedIn()) {
154 setWidgetLayoutResource(R.layout.sync_error_widget); 154 setWidgetLayoutResource(R.layout.sync_error_widget);
155 } else { 155 } else {
156 setWidgetLayoutResource(0); 156 setWidgetLayoutResource(0);
157 } 157 }
158 } 158 }
159 159
160 @Override 160 @Override
161 protected void onBindView(View view) { 161 protected void onBindView(View view) {
162 super.onBindView(view); 162 super.onBindView(view);
163 163
(...skipping 24 matching lines...) Expand all
188 AccountManagementFragment.updateUserNamePictureCache(accountId, fullName , bitmap); 188 AccountManagementFragment.updateUserNamePictureCache(accountId, fullName , bitmap);
189 update(); 189 update();
190 } 190 }
191 191
192 // AndroidSyncSettings.AndroidSyncSettingsObserver 192 // AndroidSyncSettings.AndroidSyncSettingsObserver
193 @Override 193 @Override
194 public void androidSyncSettingsChanged() { 194 public void androidSyncSettingsChanged() {
195 update(); 195 update();
196 } 196 }
197 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698