Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permanently delete sync account #13562

Merged
merged 29 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
02a3e90
Permanently delete account button on desktop
AlexeyBarabash Jun 1, 2022
0be3aac
Introduced BraveSyncHandler::HandlePermanentlyDeleteAccount
AlexeyBarabash Jun 1, 2022
52d0e70
Add patch for sync.proto
Jun 9, 2022
85e9369
Classes to post ClearServerDataMessage
AlexeyBarabash Jun 9, 2022
d7e932c
BraveSyncServiceImpl::PermanentlyDeleteAccount improvements
AlexeyBarabash Jun 20, 2022
7537f48
Fixed html syntax at brave_sync_code_dialog.html
AlexeyBarabash Jun 24, 2022
ba9224a
Desktop UI for permanent delete sync account
AlexeyBarabash Jun 27, 2022
c052257
Removed unused includes/forwards
AlexeyBarabash Jun 29, 2022
93e3cbf
BraveSyncAccountDisabledInfoBar and BraveSyncAlertsService classes
AlexeyBarabash Jun 29, 2022
1480049
Delete sync chain button in Android browser
AlexeyBarabash Jul 8, 2022
ae3a699
Android informer for deleted sync account
AlexeyBarabash Jul 15, 2022
f6360ee
Improve cleanup of local sync data when account is permanently deleted.
AlexeyBarabash Aug 23, 2022
baf5b05
Don't show account deleted informer for Brave Sync setup page
AlexeyBarabash Aug 25, 2022
cf4814b
Give error when trying connect the deleted sync chain on desktop
AlexeyBarabash Sep 12, 2022
28179f4
Don't expect join_chain_result_callback_ is set
AlexeyBarabash Sep 13, 2022
3ecb801
Give error when trying connect the deleted sync chain on Android
AlexeyBarabash Sep 16, 2022
943603d
BraveSyncServiceImplTest.* tests
AlexeyBarabash Sep 21, 2022
bb2e68a
UI fix: buttons [Leave Sync Chain] and [Delete Sync account] are alig…
AlexeyBarabash Oct 6, 2022
9c09326
UI fix: on confirmation dialog [Cancel] button is on the left side to…
AlexeyBarabash Oct 6, 2022
f37f33b
Resolving issues after CR107 rebase
AlexeyBarabash Oct 17, 2022
d718541
Sync informer icon respects dark/light theme
AlexeyBarabash Oct 18, 2022
3121cb0
UI fix: changed informer on Android
AlexeyBarabash Oct 19, 2022
56b5744
UI fix: changed informer on Desktop
AlexeyBarabash Oct 21, 2022
123c3eb
Removed patch as we always disable the chain when clearing data
AlexeyBarabash Oct 21, 2022
f138346
Client code changes for reverted disable_sync_chain flag proto patch
AlexeyBarabash Oct 21, 2022
6fb2524
Change Sync datatypes names in settings for Android and desktop
AlexeyBarabash Oct 14, 2022
c9ec73f
Fixed cr108 rebase issue
AlexeyBarabash Nov 16, 2022
5b08587
Fix presubmit errors and warnings
AlexeyBarabash Dec 13, 2022
de692ee
Fix for presubmit JS style checks
AlexeyBarabash Dec 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/infobar/BraveInfoBarIdentifier.java",
"../../brave/android/java/org/chromium/chrome/browser/infobar/BraveTranslateCompactInfoBarBase.java",
"../../brave/android/java/org/chromium/chrome/browser/informers/BraveAndroidSyncDisabledInformer.java",
"../../brave/android/java/org/chromium/chrome/browser/informers/BraveSyncAccountDeletedInformer.java",
"../../brave/android/java/org/chromium/chrome/browser/language/settings/BraveLanguageSettings.java",
"../../brave/android/java/org/chromium/chrome/browser/local_database/BraveStatsTable.java",
"../../brave/android/java/org/chromium/chrome/browser/local_database/DatabaseHelper.java",
Expand Down
1 change: 1 addition & 0 deletions android/java/apk_for_test.flags
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
*** mReviewSyncData;
*** mSyncPaymentsIntegration;
*** mSyncReadingList;
*** mSyncAutofill;
*** mTurnOffSync;
}

Expand Down
31 changes: 31 additions & 0 deletions android/java/org/chromium/chrome/browser/BraveSyncWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.Context;
import android.content.SharedPreferences;

import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
Expand Down Expand Up @@ -200,6 +201,32 @@ public void setSyncV2MigrateNoticeDismissed(boolean isDismissed) {
mNativeBraveSyncWorker, isDismissed);
}

@CalledByNative
private static void onPermanentlyDeleteAccountResult(Callback<String> callback, String result) {
callback.onResult(result);
}

public void permanentlyDeleteAccount(Callback<String> callback) {
BraveSyncWorkerJni.get().permanentlyDeleteAccount(mNativeBraveSyncWorker, callback);
}

public void clearAccountDeletedNoticePending() {
BraveSyncWorkerJni.get().clearAccountDeletedNoticePending(mNativeBraveSyncWorker);
}

public boolean isAccountDeletedNoticePending() {
return BraveSyncWorkerJni.get().isAccountDeletedNoticePending(mNativeBraveSyncWorker);
}

@CalledByNative
private static void onJoinSyncChainResult(Callback<Boolean> callback, Boolean result) {
callback.onResult(result);
}

public void setJoinSyncChainCallback(Callback<Boolean> callback) {
BraveSyncWorkerJni.get().setJoinSyncChainCallback(mNativeBraveSyncWorker, callback);
}

@NativeMethods
interface Natives {
void init(BraveSyncWorker caller);
Expand Down Expand Up @@ -231,5 +258,9 @@ interface Natives {
boolean getSyncV1WasEnabled(long nativeBraveSyncWorker);
boolean getSyncV2MigrateNoticeDismissed(long nativeBraveSyncWorker);
void setSyncV2MigrateNoticeDismissed(long nativeBraveSyncWorker, boolean isDismissed);
void permanentlyDeleteAccount(long nativeBraveSyncWorker, Callback<String> callback);
void clearAccountDeletedNoticePending(long nativeBraveSyncWorker);
boolean isAccountDeletedNoticePending(long nativeBraveSyncWorker);
void setJoinSyncChainCallback(long nativeBraveSyncWorker, Callback<Boolean> callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.fullscreen.BrowserControlsManager;
import org.chromium.chrome.browser.informers.BraveAndroidSyncDisabledInformer;
import org.chromium.chrome.browser.informers.BraveSyncAccountDeletedInformer;
import org.chromium.chrome.browser.notifications.BraveNotificationWarningDialog;
import org.chromium.chrome.browser.notifications.BravePermissionUtils;
import org.chromium.chrome.browser.notifications.permissions.NotificationPermissionController;
Expand Down Expand Up @@ -943,6 +944,7 @@ public void finishNativeInitialization() {
}
BraveSyncInformers.show();
BraveAndroidSyncDisabledInformer.showInformers();
BraveSyncAccountDeletedInformer.show();

if (!OnboardingPrefManager.getInstance().isOneTimeNotificationStarted()
&& PackageUtils.isFirstInstall(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
@IntDef({BraveInfoBarIdentifier.INVALID, BraveInfoBarIdentifier.BRAVE_CONFIRM_P3A_INFOBAR_DELEGATE,
BraveInfoBarIdentifier.WAYBACK_MACHINE_INFOBAR_DELEGATE,
BraveInfoBarIdentifier.SYNC_V2_MIGRATE_INFOBAR_DELEGATE,
BraveInfoBarIdentifier.ANDROID_SYSTEM_SYNC_DISABLED_INFOBAR})
BraveInfoBarIdentifier.ANDROID_SYSTEM_SYNC_DISABLED_INFOBAR,
BraveInfoBarIdentifier.SYNC_CANNOT_RUN_INFOBAR,
BraveInfoBarIdentifier.WEB_DISCOVERY_INFOBAR_DELEGATE,
BraveInfoBarIdentifier.BRAVE_SYNC_ACCOUNT_DELETED_INFOBAR})

@Retention(RetentionPolicy.SOURCE)
public @interface BraveInfoBarIdentifier {
Expand All @@ -24,4 +27,7 @@
int WAYBACK_MACHINE_INFOBAR_DELEGATE = 502;
int SYNC_V2_MIGRATE_INFOBAR_DELEGATE = 503;
int ANDROID_SYSTEM_SYNC_DISABLED_INFOBAR = 504;
int SYNC_CANNOT_RUN_INFOBAR = 505;
int WEB_DISCOVERY_INFOBAR_DELEGATE = 506;
int BRAVE_SYNC_ACCOUNT_DELETED_INFOBAR = 507;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */

package org.chromium.chrome.browser.informers;

import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.provider.Settings;

import org.chromium.base.ContextUtils;
import org.chromium.base.IntentUtils;
import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.BraveSyncWorker;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.infobar.BraveInfoBarIdentifier;
import org.chromium.chrome.browser.settings.BraveSyncScreensPreference;
import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.ui.messages.infobar.BraveSimpleConfirmInfoBarBuilder;
import org.chromium.chrome.browser.ui.messages.infobar.SimpleConfirmInfoBarBuilder;
import org.chromium.chrome.browser.util.TabUtils;
import org.chromium.components.browser_ui.settings.SettingsLauncher;

public class BraveSyncAccountDeletedInformer {
@CalledByNative
public static void show() {
BraveActivity activity = BraveActivity.getBraveActivity();
if (activity == null) return;

Tab tab = activity.getActivityTabProvider().get();
if (tab == null) return;

if (!BraveSyncWorker.get().isAccountDeletedNoticePending()) {
return;
}

BraveSimpleConfirmInfoBarBuilder.createInfobarWithDrawable(tab.getWebContents(),
new SimpleConfirmInfoBarBuilder.Listener() {
@Override
public void onInfoBarDismissed() {
// Pressing cross
// In any way don't show the informer again
disableInformer();
}

@Override
public boolean onInfoBarButtonClicked(boolean isPrimary) {
assert isPrimary : "We don't have secondary button";
// Pressing `OK`
// Don't show the informer again
disableInformer();
return false;
}

@Override
public boolean onInfoBarLinkClicked() {
// Pressing link `re-create the account`
// Don't show the informer again
disableInformer();
SettingsLauncher settingsLauncher = new SettingsLauncherImpl();
settingsLauncher.launchSettingsActivity(
ContextUtils.getApplicationContext(),
BraveSyncScreensPreference.class);
return false;
}
},
BraveInfoBarIdentifier.BRAVE_SYNC_ACCOUNT_DELETED_INFOBAR, activity,
R.drawable.ic_warning_circle,
// See comment at |BraveSyncAccountDeletedInfoBarDelegate::GetMessageText|
// for the informer text and link test placeholder empty substitution
activity.getString(R.string.brave_sync_account_deleted_infobar_message, ""),
activity.getString(R.string.ok), "",
activity.getString(R.string.brave_sync_account_deleted_infobar_link_text, ""),
false);
}

private static void disableInformer() {
BraveSyncWorker.get().clearAccountDeletedNoticePending();
}
}
Loading