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

[Sync] Add an option in setting page to Enter Custom Sync Url #25484

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

jagadeshjai
Copy link
Collaborator

@jagadeshjai jagadeshjai commented Sep 7, 2024

  • Added an option in settings page to enter custom sync url which is specific to each profile.
  • Also handle the GPO for the same.
  • Rename brave_components_sync_driver_[sources/deps] -> brave_components_sync_service_[sources/deps]

Resolves brave/brave-browser#12314

Resolves brave/brave-browser#41280

UI:

brave_custom_sync_input.webm

After configuring policy

image

Two different Profiles

image

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@jagadeshjai jagadeshjai changed the title [Sync] Add an option in setting page to Enable/Enter Custom Sync Url. [Sync] [WIP] Add an option in setting page to Enable/Enter Custom Sync Url. Sep 8, 2024
@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch from 8d7d7ff to f26c2e6 Compare September 8, 2024 19:18
@jagadeshjai
Copy link
Collaborator Author

Hey @aguscruiz ! Could you confirm the design for this UI?

Kindly refer SC in Overview.

@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch 2 times, most recently from e2da192 to 4fc9c3e Compare September 9, 2024 18:09
@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch 5 times, most recently from 7ddc422 to 8cc6efd Compare September 15, 2024 16:14
@jagadeshjai jagadeshjai changed the title [Sync] [WIP] Add an option in setting page to Enable/Enter Custom Sync Url. [Sync] [WIP] Add an option in setting page to Enter Custom Sync Url Sep 15, 2024
@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch 2 times, most recently from e0844cf to 6034292 Compare September 15, 2024 18:29
#include "brave/components/sync/service/brave_sync_service_impl.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/sync/device_info_sync_service_factory.h"
#include "components/sync/base/command_line_switches.h"

// Below includes are just to prevent redefining of
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These included seems nasty,
@goodov Do we have any known alternatives to avoid this, other than direct patching?

Copy link
Member

@goodov goodov Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is too messy.

I think we should stop using syncer::kSyncServiceURL for setting the URL via the command line, but instead do this:

  1. override syncer::internal::kSyncServerUrl and syncer::internal::kSyncDevServerUrl to be BUILDFLAG(BRAVE_SYNC_ENDPOINT).
  2. modify BraveGetSyncServiceURL to also use the pref value if syncer::kSyncServiceURL flag is not passed (right now it's used only if the pref is managed).
  3. remove syncer::kSyncServiceURL setting in //brave/app/brave_main_delegate.cc.
  4. support AdjustSyncServiceUrlForAndroid in BraveGetSyncServiceURL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @AlexeyBarabash ^ does this sound correct? aren't there any hidden shenanigans on iOS/Android if we go this way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, @jagadeshjai @goodov I have conmpletly missed this PR and the question.

all above sounds correct and I see the code is now much cleaner.

No hidden shenanigans on Android.

iOS should also be ok. Just in case lets ask @Brandon-T, does iOS have any code to setup custom sync server url?

I just have tested the PR on Android and Desktop - works fine.

@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch from 6034292 to c42c7ba Compare September 15, 2024 18:38
@jagadeshjai jagadeshjai marked this pull request as ready for review September 15, 2024 18:38
@jagadeshjai jagadeshjai requested review from a team as code owners September 15, 2024 18:38
@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch 5 times, most recently from 2c9a8ce to 0d046ba Compare September 22, 2024 04:30
}
}
}
#else
const char kBraveSyncServiceStagingURL[] =
Copy link
Collaborator Author

@jagadeshjai jagadeshjai Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexeyBarabash Could you please review these changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jagadeshjai , done

I left two comments about the places worth to be improved.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AlexeyBarabash 😄

@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch from 06fd867 to a0e1ef5 Compare September 27, 2024 18:25
@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch from a0e1ef5 to 22a48d8 Compare September 28, 2024 06:17
@jagadeshjai jagadeshjai changed the title [Sync] [WIP] Add an option in setting page to Enter Custom Sync Url [Sync] Add an option in setting page to Enter Custom Sync Url Sep 28, 2024
Copy link
Contributor

@AlexeyBarabash AlexeyBarabash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for sync logic, but for sure it needs design review.

The URL edit field at the beginning may cause many questions from users.

@AlexeyBarabash
Copy link
Contributor

AlexeyBarabash commented Sep 30, 2024

@jagadeshjai
Just found that sometimes the URL edibox is displayed at device screen list:
image

image

@jagadeshjai
Copy link
Collaborator Author

@jagadeshjai Just found that sometimes the URL edibox is displayed at device screen list

Yes, Thanks for pointing out, will push the fix now!

@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch 3 times, most recently from 88c82ea to ae64392 Compare October 8, 2024 01:36
@goodov
Copy link
Member

goodov commented Oct 8, 2024

@jagadeshjai

======= Failed test run #1 ==========
  FAILURE
  ------- Stdout: -------
  [ RUN      ] BraveMainDelegateUnitTest.DefaultCommandLineOverrides
  ../../brave/app/brave_main_delegate_unittest.cc:28: Failure
  Expected equality of these values:
    (("https://sync-v2.brave.com/v2"))
      Which is: "https://sync-v2.brave.com/v2
    command_line.GetSwitchValueASCII(syncer::kSyncServiceURL).c_str()
      Which is: ""
  Stack trace:
  #0 0x60bf182273b8 BraveMainDelegateUnitTest_DefaultCommandLineOverrides_Test::TestBody() [../../brave/app/brave_main_delegate_unittest.cc:38:3]
  [  FAILED  ] BraveMainDelegateUnitTest.DefaultCommandLineOverrides (1 ms)
  [3093/6896] BraveMainDelegateUnitTest.DefaultCommandLineOverrides (1 ms)
======= Failed test run #2 ==========
  FAILURE
  ------- Stdout: -------
  [ RUN      ] BraveMainDelegateUnitTest.DefaultCommandLineOverrides
  ../../brave/app/brave_main_delegate_unittest.cc:28: Failure
  Expected equality of these values:
    (("https://sync-v2.brave.com/v2"))
      Which is: "https://sync-v2.brave.com/v2
    command_line.GetSwitchValueASCII(syncer::kSyncServiceURL).c_str()
      Which is: ""
  Stack trace:
  #0 0x6444466e13b8 BraveMainDelegateUnitTest_DefaultCommandLineOverrides_Test::TestBody() [../../brave/app/brave_main_delegate_unittest.cc:38:3]
  [  FAILED  ] BraveMainDelegateUnitTest.DefaultCommandLineOverrides (0 ms)
  [6897/6901] BraveMainDelegateUnitTest.DefaultCommandLineOverrides (0 ms)

…ndling custom sync url.

Also show Relauch button and Managed icon when required.
…ervice via command line before bulding its service in browser context.
…DevServerUrl using chromium_src overrides instead of passing it via command_line
…s_sync_service_[sources/deps].

And Remove some unused includes.
@jagadeshjai jagadeshjai force-pushed the feature__add_option_custom_sync_url branch from ae64392 to a8b34bc Compare October 19, 2024 05:45
@jagadeshjai
Copy link
Collaborator Author

@jagadeshjai

======= Failed test run #1 ==========

Fixed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename brave_components_sync_driver_* gn vars Make Sync Server Url configurable in the UI
4 participants