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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.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.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().getGoogleAccounts(); 338 Account[] accounts = AccountManagerHelper.get(getActivity()).getGoog leAccounts();
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().updateCredentials( 711 AccountManagerHelper.get(getActivity())
712 ChromeSigninController.get().getSignedInUser(), getActivity( ), null); 712 .updateCredentials(ChromeSigninController.get(getActivity()) .getSignedInUser(),
713 getActivity(), null);
713 return; 714 return;
714 } 715 }
715 716
716 if (mCurrentSyncError == SYNC_CLIENT_OUT_OF_DATE) { 717 if (mCurrentSyncError == SYNC_CLIENT_OUT_OF_DATE) {
717 // Opens the client in play store for update. 718 // Opens the client in play store for update.
718 Intent intent = new Intent(Intent.ACTION_VIEW); 719 Intent intent = new Intent(Intent.ACTION_VIEW);
719 intent.setData(Uri.parse("market://details?id=" + BuildInfo.getPacka geName())); 720 intent.setData(Uri.parse("market://details?id=" + BuildInfo.getPacka geName()));
720 startActivity(intent); 721 startActivity(intent);
721 return; 722 return;
722 } 723 }
723 724
724 if (mCurrentSyncError == SYNC_OTHER_ERRORS) { 725 if (mCurrentSyncError == SYNC_OTHER_ERRORS) {
725 final Account account = ChromeSigninController.get().getSignedInUser (); 726 final Account account = ChromeSigninController.get(getActivity()).ge tSignedInUser();
726 SigninManager.get(getActivity()).signOut(new Runnable() { 727 SigninManager.get(getActivity()).signOut(new Runnable() {
727 @Override 728 @Override
728 public void run() { 729 public void run() {
729 SigninManager.get(getActivity()).signIn(account, null, null) ; 730 SigninManager.get(getActivity()).signIn(account, null, null) ;
730 } 731 }
731 }); 732 });
732 return; 733 return;
733 } 734 }
734 735
735 if (mCurrentSyncError == SYNC_PASSPHRASE_REQUIRED) { 736 if (mCurrentSyncError == SYNC_PASSPHRASE_REQUIRED) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 780 }
780 781
781 private void stopSync() { 782 private void stopSync() {
782 if (mProfileSyncService.isSyncRequested()) { 783 if (mProfileSyncService.isSyncRequested()) {
783 RecordHistogram.recordEnumeratedHistogram("Sync.StopSource", 784 RecordHistogram.recordEnumeratedHistogram("Sync.StopSource",
784 StopSource.CHROME_SYNC_SETTINGS, StopSource.STOP_SOURCE_LIMI T); 785 StopSource.CHROME_SYNC_SETTINGS, StopSource.STOP_SOURCE_LIMI T);
785 mProfileSyncService.requestStop(); 786 mProfileSyncService.requestStop();
786 } 787 }
787 } 788 }
788 } 789 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698