-
Notifications
You must be signed in to change notification settings - Fork 879
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
Try to import chrome data w/o warning dialog #5336
Conversation
@bsclifton @rebron WDYT about this changed UX? |
7a4e2a9
to
13c0db1
Compare
@rebron @bsclifton Or how about using another sentence something like |
Restarted CI after brave/brave-browser#9431 was merged 😄 |
Got intermittent build error only on macOS. Re-run on macOS.
|
Got only unrelated |
@simonhong Let's not have a dialog at all and import data while Chrome is running matching Firefox behavior, and what we do for macOS and Linux (no warning dialog). |
13c0db1
to
3e20745
Compare
554c92e
to
189be2a
Compare
Kindly ping to reviewers :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this out- it works great 😄 Really nice approach
Kindly ping to @bridiver :) |
utility/importer/chrome_importer.cc
Outdated
@@ -108,6 +108,27 @@ bool SetEncryptionKeyForPasswordImporting( | |||
} | |||
#endif | |||
|
|||
class CreateCopyFile { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe ScopedTempFile is what you want here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want copying ScopedTempFile
to here and use it in this file?
Unfortunately, ScopedTempFile
could be only used by chromecast module's test file.
And, copying to temp file is another common pattern in this PR.
So, I think using CreateCopyFile
is appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that, but then I think this should be ScopedCopyFile
utility/importer/chrome_importer.cc
Outdated
explicit CreateCopyFile(const base::FilePath& original_file_path) { | ||
DCHECK(base::PathExists(original_file_path)); | ||
if (base::CreateTemporaryFile(&copied_file_path_)) | ||
base::CopyFile(original_file_path, copied_file_path_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if this fails? You need proper error handling and can't just assume the copy worked
sql::Database db; | ||
if (!db.Open(history_path)) | ||
if (!db.Open(copy_history_file.copied_file_path())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: https://github.com/brave/brave-core/pull/5336/files#r423416068 this could crash if either the temp file creation or the copy fails
@@ -196,7 +218,9 @@ void ChromeImporter::ImportBookmarks() { | |||
base::FilePath bookmarks_path = | |||
source_path_.Append( | |||
base::FilePath::StringType(FILE_PATH_LITERAL("Bookmarks"))); | |||
base::ReadFileToString(bookmarks_path, &bookmarks_content); | |||
CreateCopyFile copy_bookmark_file(bookmarks_path); | |||
base::ReadFileToString(copy_bookmark_file.copied_file_path(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, but I'm not sure what happens if you pass an empty string to JSONReader
With this warning dialog, user will close chrome windows. After that user clicks continue button, browser will not check lock again aind will try to import chrome's settings. Even if chrome is still running, importing will be done because importing is done with temporarily copied db files.
Browser will try to import data w/o warning about closing currently running chrome instance.
189be2a
to
38b53f3
Compare
@bridiver Handled file copy failure. |
Merged because CI only has |
Even if chrome is still running, importing will be done because
we will import from copied db file.
Resolves brave/brave-browser#2049
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Refer to issue.
Reviewer Checklist:
After-merge Checklist:
changes has landed on.