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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.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.sync.ui; 5 package org.chromium.chrome.browser.sync.ui;
6 6
7 import android.accounts.Account; 7 import android.accounts.Account;
8 import android.app.DialogFragment; 8 import android.app.DialogFragment;
9 import android.app.FragmentManager; 9 import android.app.FragmentManager;
10 import android.app.FragmentTransaction; 10 import android.app.FragmentTransaction;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 updateSyncStateFromSwitch(); 328 updateSyncStateFromSwitch();
329 } 329 }
330 330
331 private void updateSyncAccountsListState() { 331 private void updateSyncAccountsListState() {
332 SyncedAccountPreference accountList = 332 SyncedAccountPreference accountList =
333 (SyncedAccountPreference) findPreference(PREFERENCE_SYNC_ACCOUNT _LIST); 333 (SyncedAccountPreference) findPreference(PREFERENCE_SYNC_ACCOUNT _LIST);
334 334
335 // We remove the the SyncedAccountPreference if there's only 1 account o n the device, so 335 // We remove the the SyncedAccountPreference if there's only 1 account o n the device, so
336 // it's possible for accountList to be null 336 // it's possible for accountList to be null
337 if (accountList != null) { 337 if (accountList != null) {
338 Account[] accounts = AccountManagerHelper.get(getActivity()).getGoog leAccounts(); 338 Account[] accounts = AccountManagerHelper.get().getGoogleAccounts();
339 if (accounts.length <= 1) { 339 if (accounts.length <= 1) {
340 getPreferenceScreen().removePreference(accountList); 340 getPreferenceScreen().removePreference(accountList);
341 } else { 341 } else {
342 accountList.setEnabled(mSyncSwitchPreference.isChecked()); 342 accountList.setEnabled(mSyncSwitchPreference.isChecked());
343 } 343 }
344 } 344 }
345 } 345 }
346 346
347 /** 347 /**
348 * Update the state of settings using the switch state to determine if sync is enabled. 348 * Update the state of settings using the switch state to determine if sync is enabled.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 // should update this when we figure that out. 701 // should update this when we figure that out.
702 Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS); 702 Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
703 intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, new String[] {"com.goo gle"}); 703 intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, new String[] {"com.goo gle"});
704 if (intent.resolveActivity(getActivity().getPackageManager()) != nul l) { 704 if (intent.resolveActivity(getActivity().getPackageManager()) != nul l) {
705 getActivity().startActivity(intent); 705 getActivity().startActivity(intent);
706 } 706 }
707 return; 707 return;
708 } 708 }
709 709
710 if (mCurrentSyncError == SYNC_AUTH_ERROR) { 710 if (mCurrentSyncError == SYNC_AUTH_ERROR) {
711 AccountManagerHelper.get(getActivity()) 711 AccountManagerHelper.get().updateCredentials(
712 .updateCredentials(ChromeSigninController.get(getActivity()) .getSignedInUser(), 712 ChromeSigninController.get().getSignedInUser(), getActivity( ), null);
713 getActivity(), null);
714 return; 713 return;
715 } 714 }
716 715
717 if (mCurrentSyncError == SYNC_CLIENT_OUT_OF_DATE) { 716 if (mCurrentSyncError == SYNC_CLIENT_OUT_OF_DATE) {
718 // Opens the client in play store for update. 717 // Opens the client in play store for update.
719 Intent intent = new Intent(Intent.ACTION_VIEW); 718 Intent intent = new Intent(Intent.ACTION_VIEW);
720 intent.setData(Uri.parse("market://details?id=" + BuildInfo.getPacka geName())); 719 intent.setData(Uri.parse("market://details?id=" + BuildInfo.getPacka geName()));
721 startActivity(intent); 720 startActivity(intent);
722 return; 721 return;
723 } 722 }
724 723
725 if (mCurrentSyncError == SYNC_OTHER_ERRORS) { 724 if (mCurrentSyncError == SYNC_OTHER_ERRORS) {
726 final Account account = ChromeSigninController.get(getActivity()).ge tSignedInUser(); 725 final Account account = ChromeSigninController.get().getSignedInUser ();
727 SigninManager.get(getActivity()).signOut(new Runnable() { 726 SigninManager.get(getActivity()).signOut(new Runnable() {
728 @Override 727 @Override
729 public void run() { 728 public void run() {
730 SigninManager.get(getActivity()).signIn(account, null, null) ; 729 SigninManager.get(getActivity()).signIn(account, null, null) ;
731 } 730 }
732 }); 731 });
733 return; 732 return;
734 } 733 }
735 734
736 if (mCurrentSyncError == SYNC_PASSPHRASE_REQUIRED) { 735 if (mCurrentSyncError == SYNC_PASSPHRASE_REQUIRED) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } 779 }
781 780
782 private void stopSync() { 781 private void stopSync() {
783 if (mProfileSyncService.isSyncRequested()) { 782 if (mProfileSyncService.isSyncRequested()) {
784 RecordHistogram.recordEnumeratedHistogram("Sync.StopSource", 783 RecordHistogram.recordEnumeratedHistogram("Sync.StopSource",
785 StopSource.CHROME_SYNC_SETTINGS, StopSource.STOP_SOURCE_LIMI T); 784 StopSource.CHROME_SYNC_SETTINGS, StopSource.STOP_SOURCE_LIMI T);
786 mProfileSyncService.requestStop(); 785 mProfileSyncService.requestStop();
787 } 786 }
788 } 787 }
789 } 788 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698