fix: use acceptLanguages argument in session.setUserAgent() (#23944)
This commit is contained in:
parent
90caa5eac9
commit
3fa4299939
2 changed files with 13 additions and 4 deletions
|
@ -40,6 +40,7 @@
|
|||
#include "net/http/http_auth_handler_factory.h"
|
||||
#include "net/http/http_auth_preferences.h"
|
||||
#include "net/http/http_cache.h"
|
||||
#include "net/http/http_util.h"
|
||||
#include "services/network/network_service.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "shell/browser/api/electron_api_app.h"
|
||||
|
@ -591,9 +592,16 @@ void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
|||
void Session::SetUserAgent(const std::string& user_agent,
|
||||
gin::Arguments* args) {
|
||||
browser_context_->SetUserAgent(user_agent);
|
||||
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
|
||||
->GetNetworkContext()
|
||||
->SetUserAgent(user_agent);
|
||||
auto* network_context = content::BrowserContext::GetDefaultStoragePartition(
|
||||
browser_context_.get())
|
||||
->GetNetworkContext();
|
||||
network_context->SetUserAgent(user_agent);
|
||||
|
||||
std::string accept_lang;
|
||||
if (args->GetNext(&accept_lang)) {
|
||||
network_context->SetAcceptLanguage(
|
||||
net::HttpUtil::GenerateAcceptLanguageHeader(accept_lang));
|
||||
}
|
||||
}
|
||||
|
||||
std::string Session::GetUserAgent() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue