| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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; | 5 package org.chromium.chrome.browser.sync; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.content.ContentResolver; | 8 import android.content.ContentResolver; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.SharedPreferences; | 10 import android.content.SharedPreferences; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 */ | 86 */ |
| 87 @VisibleForTesting | 87 @VisibleForTesting |
| 88 void clearDelayedSyncs(Context context) { | 88 void clearDelayedSyncs(Context context) { |
| 89 setDelayedSync(context, null); | 89 setDelayedSync(context, null); |
| 90 } | 90 } |
| 91 | 91 |
| 92 @VisibleForTesting | 92 @VisibleForTesting |
| 93 boolean shouldPerformSync(Context ctx, Bundle extras, Account account) { | 93 boolean shouldPerformSync(Context ctx, Bundle extras, Account account) { |
| 94 boolean manualSync = isManualSync(extras); | 94 boolean manualSync = isManualSync(extras); |
| 95 | 95 |
| 96 if (manualSync || ActivityStatus.isApplicationVisible()) { | 96 if (manualSync || ActivityStatus.hasVisibleActivities()) { |
| 97 clearDelayedSyncs(ctx); | 97 clearDelayedSyncs(ctx); |
| 98 return true; | 98 return true; |
| 99 } else { | 99 } else { |
| 100 Log.d(TAG, "Delaying sync."); | 100 Log.d(TAG, "Delaying sync."); |
| 101 setDelayedSync(ctx, account.name); | 101 setDelayedSync(ctx, account.name); |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 private static boolean isManualSync(Bundle extras) { | 106 private static boolean isManualSync(Bundle extras) { |
| 107 boolean manualSync = false; | 107 boolean manualSync = false; |
| 108 if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false)) { | 108 if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false)) { |
| 109 manualSync = true; | 109 manualSync = true; |
| 110 Log.d(TAG, "Manual sync requested."); | 110 Log.d(TAG, "Manual sync requested."); |
| 111 } | 111 } |
| 112 return manualSync; | 112 return manualSync; |
| 113 } | 113 } |
| 114 } | 114 } |
| OLD | NEW |