Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Update tab title on back/forward fixes #3200 #3202

Merged
merged 1 commit into from
Aug 17, 2016
Merged

Update tab title on back/forward fixes #3200 #3202

merged 1 commit into from
Aug 17, 2016

Conversation

Sh1d0w
Copy link

@Sh1d0w Sh1d0w commented Aug 16, 2016

The page-title-updated event on webview is not triggered when invoking back/forward actions. This PR adds ipc message that makes sure window data such as title is always sent back to electron, so it can be properly updated when the page changes.

Reviewers: @bbondy @bridiver @bsclifton @diracdeltas

@bbondy
Copy link
Member

bbondy commented Aug 16, 2016

@bridiver pls review


var data = {
"title": document.title,
"url": window.location.href
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need the url here? The title is already set to the url if page-title-updated isn't fired. I can't articulate a particular threat, but I just feel like it would be generally safer to use the url from frames.js rather than sending back window.location.href @diracdeltas ?

@bridiver
Copy link
Collaborator

Thanks! This is definitely a reasonable change from the browser side and I think it's a good workaround, but I think we really want to retrieve the title from the navigation controller entry (not currently exposed in electron). I can open a separate ticket to make that electron change and we can merge this for now after comments.

@Sh1d0w
Copy link
Author

Sh1d0w commented Aug 16, 2016

@bridiver Just simplified the tests. I have also fixed the ipc event to take the url from the frame if no title is provided.

Let me know if there is something else 😄

@bridiver
Copy link
Collaborator

actually I was wrong, @bsclifton added the method that is required for this in brave/muon@11b8318
getTitleAtIndex and getCurrentEntryIndex will give you the title in frames.js

@Sh1d0w
Copy link
Author

Sh1d0w commented Aug 17, 2016

@bridiver Thanks, I was looking for this in official electron docs, obviously I should have looked in another place 😄

I have changed the way I set the title, since now we don't get it from the web view, do you think I should get rid of windowData.js and just put the updating of the title in THEME_COLOR_COMPUTED event in frame.js?

@bridiver
Copy link
Collaborator

bridiver commented Aug 17, 2016

I think you can remove windowData.js completely and set the title in did-navigate

@Sh1d0w
Copy link
Author

Sh1d0w commented Aug 17, 2016

@bridiver PR is updated. Let me know if all ok. Thank you very much for your feedback :)

@@ -773,6 +774,10 @@ class Frame extends ImmutableComponent {
this.webview.focus()
}
windowActions.setNavigated(e.url, this.props.frameKey, false)
// After navigating to the URL, set correct frame title
let webContents = this.webview.getWebContents()
let title = webContents.getTitleAtIndex(webContents.getCurrentEntryIndex())
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bsclifton - if you add these methods to https://github.com/brave/electron/blob/master/lib/renderer/web-view/web-view.js#L391 they can be called directly on the webview

@bridiver bridiver merged commit 2a0cf25 into brave:master Aug 17, 2016
@bridiver
Copy link
Collaborator

++ Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants