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

Update downloads to mv3 #844

Closed

Conversation

Shubham-Rasal
Copy link
Contributor

@Shubham-Rasal Shubham-Rasal commented Mar 8, 2023

This PR aims to upgrade the existing download extension samples to MV3. Here I have migrated the downloads manager and download links samples.
If this PR is appropriate, I would love to continue to update others as well

@Shubham-Rasal Shubham-Rasal marked this pull request as ready for review March 9, 2023 09:40
@patrickkettner
Copy link
Collaborator

@oliverdunk would you be able to review?

Copy link
Member

@oliverdunk oliverdunk left a comment

Choose a reason for hiding this comment

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

Thanks so much for taking a look at this!

I left some initial thoughts - in both cases the extensions aren't working right now so it would be great to fix that. Maybe you had some extra changes that you didn't commit?

It would also be great to run the linter (npm run lint:fix). Note that this will change var to let which will break the download_links extension when you open the popup more than once, since it will try to re-declare variables. We'll need to look at fixing that.

{
"name": "Download Selected Links",
"description": "Select links on a page and download them.",
"version": "0.3",
Copy link
Member

Choose a reason for hiding this comment

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

Given the previous version was 0.1, this should probably be 0.2?

"activeTab",
"scripting"
],
"content_scripts":[
Copy link
Member

Choose a reason for hiding this comment

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

Given that we inject this script from the popup, do we need a content script?

}
}

console.log(links)
Copy link
Member

Choose a reason for hiding this comment

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

We weren't previously logging here, so I think we should probably remove this?

"minimum_chrome_version": "16.0.884",
"permissions": [
"downloads",
"activeTab",
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for moving to activeTab here!

"name": "Download Selected Links",
"description": "Select links on a page and download them.",
"version": "0.3",
"minimum_chrome_version": "16.0.884",
Copy link
Member

Choose a reason for hiding this comment

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

We should probably remove this, or otherwise bump it to Chrome 88 (the first version with Manifest V3 support).


//using runtime sendmessage to send the links to the popup
chrome.runtime.sendMessage({
request : links,
Copy link
Member

Choose a reason for hiding this comment

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

We used to just send links, rather than an object with a request property, and I think this is breaking the sample. Can you try that on your end and make any changes we need?

@@ -0,0 +1,30 @@
{
"name": "Downloads Manager",
Copy link
Member

Choose a reason for hiding this comment

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

We were previously using __MSG_extName__ which is the right way of doing localisation in an extension: https://developer.chrome.com/docs/extensions/mv3/i18n-messages/

Could we try and preserve that?

"downloads",
"downloads.open",
"downloads.shelf",
"storage"
Copy link
Member

Choose a reason for hiding this comment

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

Is there something specific we need the storage permission for? Perhaps you were looking to use chrome.storage.local in place of localStorage?

function maybeOpen(id) {
var openWhenComplete = [];
try {
openWhenComplete = JSON.parse(localStorage.openWhenComplete);
Copy link
Member

Choose a reason for hiding this comment

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

localStorage isn't available in MV3. We'll need to update this before we can test the extension.

@oliverdunk
Copy link
Member

Also: Removing fixes #744 since that is for the download_open sample which wasn't migrated here.

@Shubham-Rasal
Copy link
Contributor Author

Thanks for the feedback. On it.

@jpmedley
Copy link
Contributor

Does either of you have time to add READMEs to these?

@Shubham-Rasal
Copy link
Contributor Author

Yeah I will add them, once the code is ready.

@oliverdunk
Copy link
Member

Hi @Shubham-Rasal! I was just wondering if you plan on continuing this one? Totally fine either way, but it would be useful so we know if we need to include this one in our work planning :)

@Shubham-Rasal
Copy link
Contributor Author

Sorry, I won't be able to work on this. You can go ahead with your plan

@oliverdunk
Copy link
Member

Sorry, I won't be able to work on this. You can go ahead with your plan

No worries. Closing this for now, but we may use it as a reference when we're able to take another look at this.

@oliverdunk oliverdunk closed this May 25, 2023
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.

None yet

4 participants