Comment 4 for bug 1324909

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Setting the user agent string is done in 2 places:

- Setting RendererPreferences::user_agent_override
- Setting FrameMsg_Navigate_Params::is_overriding_user_agent, which is sent with the FrameMsg_Navigate IPC message for browser initiated navigations

content::RenderFrameImpl::userAgentOverride() only returns the override user agent string if InternalDocumentStateData::is_overriding_user_agent() returns true. InternalDocumentStateData is an object tied to the WebDataSource associated with a frame. It is created in content::RenderFrameImpl::didCreateDataSource(), where:

- If there is a pending browser-initiated navigation, InternalDocumentStateData::set_is_overriding_user_agent() is called with the value set from the FrameMsg_Navigate message.
- If the navigation is content initiated, InternalDocumentStateData::set_is_overriding_user_agent() is called with the value from the previous data source associated with the frame.

For a newly opened webview, none of the above 2 conditions are met, and so the setting gets lost