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
Setting the user agent string is done in 2 places:
- Setting RendererPrefere nces::user_ agent_override Navigate_ Params: :is_overriding_ user_agent, which is sent with the FrameMsg_Navigate IPC message for browser initiated navigations
- Setting FrameMsg_
content: :RenderFrameImp l::userAgentOve rride() only returns the override user agent string if InternalDocumen tStateData: :is_overriding_ user_agent( ) returns true. InternalDocumen tStateData is an object tied to the WebDataSource associated with a frame. It is created in content: :RenderFrameImp l::didCreateDat aSource( ), where:
- If there is a pending browser-initiated navigation, InternalDocumen tStateData: :set_is_ overriding_ user_agent( ) is called with the value set from the FrameMsg_Navigate message. tStateData: :set_is_ overriding_ user_agent( ) is called with the value from the previous data source associated with the frame.
- If the navigation is content initiated, InternalDocumen
For a newly opened webview, none of the above 2 conditions are met, and so the setting gets lost