Closed Bug 900865 Opened 11 years ago Closed 11 years ago

Make homepage call nsSearchService.getSubmission for all searches

Categories

(Firefox :: Search, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 26

People

(Reporter: mikedeboer, Assigned: mikedeboer)

References

Details

Attachments

(1 file, 4 obsolete files)

As mentioned in bug 890690 comment 14, the current implementation to support POST search engines in about:home duplicates behavior as implemented by nsSearchService.getSubmission(). To allow getSubmission() to be called from a non-chrome context like about:home, we need to use events to transfer messages between differently privileged areas.
Severity: major → normal
Version: unspecified → Trunk
No longer depends on: 890690
Gavin, as you might notice from this patch, I can pretty much revert the entire changeset from bug 890690. Is there a reason you might still postDataString somewhere? If not, I'll revert all those changes to this new - preferred - way of doing things. Instead of introducing a new event, I simply reused 'AboutHomeSearchEvent', which was only used for FHR. I was careful not to break the FHR mechanism (and luckily, it is covered by a unit test). Do you agree that that is the correct direction? Thanks!
Attachment #788904 - Flags: feedback?(gavin.sharp)
In fact, in this case we don't even need the 'searchEngineURL' attribute anymore for about:home... Since this is starting to look so elegant and simple, I begin to wonder if this implementation was tried before, but disregarded for some reason?
Comment on attachment 788904 [details] [diff] [review] Patch v1: make about:home call nsSearchService.getSubmission Looks good - this does look like it will simplify things a lot. The history is in bug 563723. IIRC we didn't take this approach just because it wasn't necessary (about:home then was less tied to the search service and had a hardcoded list of engines, didn't support POST data, etc.).
Attachment #788904 - Flags: feedback?(gavin.sharp) → feedback+
Part of this patch is about reverting the code I added for bug 890690. I also reverted the UUID of nsISearchEngine, is that the correct thing to do? I also removed the searchEngineURL attribute and the corresponding code in AboutHomeUtils.jsm. \o/ I checked the unit tests and they run without problems. Could do a try run to be safe.
Assignee: nobody → mdeboer
Attachment #788904 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #789199 - Flags: review?(gavin.sharp)
Report exception when it occurs. This will never ever happen, but still...
Attachment #789199 - Attachment is obsolete: true
Attachment #789199 - Flags: review?(gavin.sharp)
Attachment #789201 - Flags: review?(gavin.sharp)
Try run looks good.
Comment on attachment 789201 [details] [diff] [review] Patch v1.3: make about:home call nsISearchEngine.getSubmission >diff --git a/browser/base/content/abouthome/aboutHome.js b/browser/base/content/abouthome/aboutHome.js > function onSearchSubmit(aEvent) >+ // Send an event that will perform a search. This was originally added so >+ // Firefox Health Report could record that a search from about:home had >+ // occurred, but now it will also perform the search (properly) in >+ // browser.js through nsISearchEngine.getSubmission(). I think the "this was originally added" bit is not really relevant to someone looking at this code (and can be found in blame), so I would just remove it. >diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js > let updateSearchEngine = function() { >+ // Again, keep the searchEngineName as the last attribute, because the > // mutation observer in aboutHome.js is counting on that. >+ docElt.setAttribute("searchEngineName", Services.search.defaultEngine.name); This comment isn't so useful now, since it's not the only attribute. >+ // Trigger a search through nsISearchEngine.getSubmission() >+ let submission = Services.search.currentEngine.getSubmission(data.searchTerms); >+ openUILinkIn(submission.uri.spec, "current", null, submission.postData); I think this might do the wrong thing if about:home is loaded in an app tab (it will open the search in a new tab). Probably better to use gBrowser.loadURI? Also, in theory you want to use the same tab that the event bubbles up from, rather than the currently selected tab, but since I think it's impossible for the event to be fired in a background tab in practice, I guess you don't need to worry about that. r=me with those addressed.
Attachment #789201 - Flags: review?(gavin.sharp) → review+
and sorry for the delay!
Patch with Gavin's comments addressed. Carrying over r=gavin.
Attachment #789201 - Attachment is obsolete: true
Attachment #796600 - Flags: review+
Keywords: checkin-needed
Flags: in-testsuite+
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Whiteboard: [fixed-in-fx-team]
Another try push for this, because I only see Win XP crashes in the logs... https://tbpl.mozilla.org/?tree=Try&rev=d2aeead9167a
Try push looks good, so I attempted another push to integration: https://hg.mozilla.org/integration/fx-team/rev/41729438f597
Now with a completely new UUID for the nsISearchSubmission interface.
Attachment #796600 - Attachment is obsolete: true
Attachment #797909 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: