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

CRX: make disabling extension during run, optional #1604

Merged
merged 3 commits into from
Feb 4, 2017

Conversation

ebidel
Copy link
Contributor

@ebidel ebidel commented Feb 2, 2017

R: @brendankenny, all

This makes the enabling/disabling of extension before a LH run a user setting:

screen shot 2017-02-02 at 11 24 53 am

My worry was that some users would find the current default behavior (disable all extension before the run) unexpected and frustrating. Any extensions that don't save state when they're killed off will lose data. I suspect there are many that don't follow best practices. Instead, we're making this a setting for people to opt into.

@brendankenny I tried to move some of the bg methods into popup.html like we chatted about but it was getting trickier than it was worth. We allow the user to dismiss the popup while LH is running. It was getting gnarly to make a transient popup communicate state back to the bg page for persistence, then repopulate the UI when the user reopens the popup. I was also finding myself piping more background page variables through popup.js methods...which defeated the original purpose of the code refactor (separation of concerns between bg page and popup.js).

@ebidel
Copy link
Contributor Author

ebidel commented Feb 2, 2017

Tests are shoppy shop. Shop is the worst.

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

looking good, I think. I'll feel a lot better about this being an option, too. I'll actually build and try it out tomorrow

@@ -207,9 +209,11 @@ function initPopup() {
const okButton = document.getElementById('ok');
okButton.addEventListener('click', () => {
// Save selected aggregation categories on options page close.
Copy link
Member

Choose a reason for hiding this comment

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

"Save settings on options page close"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// Save settings when options page is closed.


let installedExtensions = [];
let DISABLE_EXTENSIONS_DURING_RUN = false;
Copy link
Member

Choose a reason for hiding this comment

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

not a constant so shouldn't be all caps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @param {!Array<{name: string, audits: !Array<string>}>} selectedAggregations
* @param {!{selectedAggregations: Array<{name: string, audits: !Array<string>}>,
* disableExtensions: boolean}} settings
* @param {!boolean} disableExtensions True if extensions should be disabled for the run.
Copy link
Member

Choose a reason for hiding this comment

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

not separate params, just one object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leftover from tinkering, done.

@brendankenny
Copy link
Member

I tried to move some of the bg methods into popup.html like we chatted about but it was getting trickier than it was worth.

maybe (in a future PR) we can move it into a separate background script, then, so other clients won't get the extension-specific stuff

@ebidel
Copy link
Contributor Author

ebidel commented Feb 3, 2017

maybe (in a future PR) we can move it into a separate background script, then, so other clients won't get the extension-specific stuff

Or we flip it and have something special for devtools. It's funky the devtools using the built background file from the extension. Those should really be separate targets.

@ebidel
Copy link
Contributor Author

ebidel commented Feb 3, 2017

PTAL

@ebidel
Copy link
Contributor Author

ebidel commented Feb 3, 2017

Tests are green

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

two jsdoc nits. Trying it out now...

@@ -251,41 +257,56 @@ window.getDefaultAggregations = function() {

/**
* Save currently selected set of aggregation categories to local storage.
* @param {!Array<{name: string, audits: !Array<string>}>} selectedAggregations
* @param {!{selectedAggregations: Array<{name: string, audits: !Array<string>}>,
Copy link
Member

Choose a reason for hiding this comment

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

somewhere along the line this became wrong. I believe its @param {{selectedAggregations: !Array<string>, disableExtensions: boolean}} settings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

chrome.storage.local.set(storage);
};

/**
* Load selected aggregation categories from local storage.
* @return {!Promise<!Object<boolean>>}
* @return {!Promise<{selectedAggregations: Array<{name: string, audits: !Array<string>}>,
Copy link
Member

@brendankenny brendankenny Feb 4, 2017

Choose a reason for hiding this comment

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

this one was right before, so @return {!Promise<{selectedAggregations: !Object<boolean>, disableExtensions: boolean}>}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM!

@brendankenny brendankenny merged commit 59f2f82 into master Feb 4, 2017
@brendankenny brendankenny deleted the crxenableoption branch February 4, 2017 01:00
@ebidel
Copy link
Contributor Author

ebidel commented Feb 4, 2017

Woot!

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

2 participants