Closed Bug 1264835 Opened 8 years ago Closed 8 years ago

No way to set doorhanger checkbox default off

Categories

(Firefox for Android Graveyard :: General, defect)

defect
Not set
normal

Tracking

(firefox50 fixed)

RESOLVED FIXED
Firefox 50
Tracking Status
firefox50 --- fixed

People

(Reporter: mchiang, Assigned: enr0n, Mentored)

References

Details

(Whiteboard: [lang=java][good next bug])

Attachments

(1 file, 1 obsolete file)

For getusermedia permission granting & blocking, we want to grant as little persistent permissions as possible. So we need to set the doorhanger checkbox default off.
We allow to set the text but not the default state:
https://dxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/mozilla/gecko/widget/DefaultDoorHanger.java#124-127
Mentor: s.kaspari
Whiteboard: [lang=java][good next bug]
So do we want to allow for the default state of the checkbox to be passed in with options? Or are we just assuming a default of unchecked?
Flags: needinfo?(s.kaspari)
We should allow the default state to be passed in.
Flags: needinfo?(s.kaspari)
Attached patch Patch attempt 1 (obsolete) — Splinter Review
Here's my first try at it.
Attachment #8762766 - Flags: review?(s.kaspari)
Assignee: nobody → nrosbrook
Status: NEW → ASSIGNED
Comment on attachment 8762766 [details] [diff] [review]
Patch attempt 1

Review of attachment 8762766 [details] [diff] [review]:
-----------------------------------------------------------------

This is looking good! I think with the little change below we can land this. Did you test this?

We have a test for some doorhangers here:
https://dxr.mozilla.org/mozilla-central/source/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testDoorHanger.java

Maybe you can use this to write a new test just for the checkbox state?

::: mobile/android/base/java/org/mozilla/gecko/widget/DefaultDoorHanger.java
@@ +131,5 @@
> +        if (options.has("checkboxState")) {
> +            final boolean checkBoxState = options.optBoolean("checkboxState");
> +            mCheckBox = (CheckBox) findViewById(R.id.doorhanger_checkbox);
> +            mCheckBox.setChecked(checkBoxState);
> +            mCheckBox.setVisibility(VISIBLE);

I wonder if we should move this inside the checkboxText block: I guess it only makes sense to set the default for the checkbox if we are actually going to display a checkbox *with* text. This also avoids some of the code because we do not need to search the view again and update the visibility.
Attachment #8762766 - Flags: review?(s.kaspari) → feedback+
Attached patch Patch attempt 2Splinter Review
Here's the patch with the suggested fix. I'll try to write the test for it--but here's the patch itself for now.
Attachment #8762766 - Attachment is obsolete: true
Attachment #8763724 - Flags: review?(s.kaspari)
Comment on attachment 8763724 [details] [diff] [review]
Patch attempt 2

LGTM!
Attachment #8763724 - Flags: review?(s.kaspari) → review+
Let's get this into the tree (Adding checkin-needed..).

@Nicholas: If you write a UI test for this then just file a new bug, attach the patch and assign me for review. :)
Keywords: checkin-needed
@Sebastian: Okay, sounds good!
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/fx-team/rev/a5e39700fd44
Updated DefaultDoorHanger so that the default CheckBox state could be specified as an option. r=sebastian
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/a5e39700fd44
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 50
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: