Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #3227: Implement History Sync #3703

Merged
merged 43 commits into from
Aug 4, 2021
Merged

Conversation

soner-yuksel
Copy link
Contributor

@soner-yuksel soner-yuksel commented May 21, 2021

Summary of Changes

This Pull Request contains

  • History Migration
  • Sync Profile
  • History Fetch/Add/Delete with Core and Sync
  • Brave-Core Bump 1.26.x
  • Delete All functionality on History
  • Empty State for History

History Migration:

We are adding history brave-core migration to our existing migrator used for bookmarks and making both of the sync types work together and handle error cases related for both of the types. So in future the new sync types can also use same migrator.

History Fetch/Add/Delete/Remove with Core and Sync

A new HistoryFetcher is created where we perform the fetch from brave-core and various utility methods are created over the data. This fetcher is using Ordered Dictionary so in order to use this we added Swift Collections package. Believe the utility brought with Swift Collections will also be useful for the rest of the application. https://swift.org/blog/swift-collections/

In addition old add delete methods are replaced with brave-core functionality.

Sync Profile

Enable/Disable different Sync Types is added. Sync Settings will contain a new section which will allow user to toggle different Sync types according to users preference. This is using BraveSyncProfileService and it will also help when new sync types are added to give user ability to turn them on/off.

This pull request fixes #3227
This pull request fixes #3723
This pull request fixes #3721
This pull request fixes #3869
This pull request fixes #3591

Brave Core PR is merged and uplifted to 1.26.x and in addition this PR also handles the changes made in core to align history and bookmarks code.

Core PR For History Sync: brave/brave-core#8869

Core PR For alignment: brave/brave-core#9145

SecReview: https://github.com/brave/security/issues/501

Submitter Checklist:

  • Unit Tests are updated to cover new or changed functionality
  • User-facing strings use NSLocalizableString()

Test Plan:

Test Migration: The test cases and conditions are same with bookmark. Try migration 3 times but for both history and bookmarks together in this case.

  • Update application with existing History base
  • Check migration is happened and data is same

Normal Add / Delete / Delete All

  • Fresh install or updated app
  • Try Add history by entering urls or redirecting from other places
  • Delete individual history
  • Delete All history in History Screen

Test Sync: Same testing cases with bookmarks release but this time after joining to sync chain can actually turn on/off
which type of sync should be enabled

  • Can test turning on different sync types and check If their functionality can be turned on/off
  • History Sync should be tested but keep in mind only typed urls is going to be synced from desktop to mobile also mobile to desktop
  • Migrated urls will be marked as types since we dont have informationa bout them so they should be synced

Screenshots:

119523015-6b475a80-bd4a-11eb-99f3-f2daf41bf66a

33 3333233

Reviewer Checklist:

  • Issues include necessary QA labels:
    • QA/(Yes|No)
    • release-notes/(include|exclude)
    • bug / enhancement
  • Necessary security reviews have taken place.
  • Adequate unit test coverage exists to prevent regressions.
  • Adequate test plan exists for QA to validate (if applicable).
  • Issue is assigned to a milestone (should happen at merge time).

@soner-yuksel soner-yuksel self-assigned this May 21, 2021
@soner-yuksel soner-yuksel changed the title [WIP] Fix #3227: Implement History Sync [WIP] Feature #3227: Implement History Sync May 26, 2021
@soner-yuksel soner-yuksel force-pushed the feature/history-sync branch 2 times, most recently from 5a0318a to 20fd26f Compare June 4, 2021 16:39
@soner-yuksel soner-yuksel added blocked If a ticket is blocked for some reason, if not using a sub-block label, please provide info in issue Epic: Sync good first issue and removed CI/skip labels Jun 4, 2021
@soner-yuksel soner-yuksel changed the title [WIP] Feature #3227: Implement History Sync Feature #3227: Implement History Sync Jun 4, 2021
@soner-yuksel soner-yuksel marked this pull request as ready for review June 4, 2021 20:55
@soner-yuksel soner-yuksel changed the title Feature #3227: Implement History Sync [WIP] Feature #3227: Implement History Sync Jun 9, 2021
@soner-yuksel soner-yuksel marked this pull request as draft June 9, 2021 16:22
@soner-yuksel soner-yuksel force-pushed the feature/history-sync branch 5 times, most recently from 446dd35 to a845929 Compare June 23, 2021 15:37
@kylehickinson kylehickinson linked an issue Jun 29, 2021 that may be closed by this pull request
@soner-yuksel soner-yuksel force-pushed the feature/history-sync branch 2 times, most recently from 8b7801e to 9613cca Compare June 30, 2021 14:17
return
}

let historyNode = HistoryNode(url: url, title: title, dateAdded: dateAdded)
Copy link
Contributor

Choose a reason for hiding this comment

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

@soner-yuksel - iOS supports special URLs and external URLs as well. about: | mailto: and tel: URLs. Do you know if these URLs are filtered before adding to the sync chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the condition of the where the add is used is not changed. Only how we add is changed in this context.
History add is used inside func navigateInTab(tab: Tab, to navigation: WKNavigation? = nil)

And the conditions are
if !url.isErrorPageURL, !url.isAboutHomeURL, !url.isFileURL

if !url.isErrorPageURL, !url.isAboutHomeURL, !url.isFileURL {

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good. I think we should add externalURL to this list. I can file a follow-up issue for that? Let me know if you disagree.

@soner-yuksel
Copy link
Contributor Author

The security review is ongoing. Merging this to unblock feature core requirements. If any issue arose in security review there will be upcoming Pull Request.

@soner-yuksel soner-yuksel merged commit 04eae84 into development Aug 4, 2021
@soner-yuksel soner-yuksel deleted the feature/history-sync branch August 4, 2021 18:21
var title: String?
var message: String?
var removeButtonName: String?
let deviceName = device.name ?? Strings.syncRemoveDeviceDefaultName
Copy link
Contributor

Choose a reason for hiding this comment

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

@soner-yuksel - do you know if the device-name is sanitized before presenting in UI? I've come across cases where <script> tags in device name causes script execution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an existing method which was moved in the file from previous position.
However the device_name is not a user entry field, it is fetched using BraveSyncAPI and underneath this information is fetched from DeviceInfoSyncServiceFactory

Copy link
Contributor

Choose a reason for hiding this comment

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

I verified that the device-name is not sanitized. I wasn't able to cause an injection, but as a defense in depth strategy what do you think about encoding the string before printing out the device name.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants