Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2657)

Unified Diff: ios/crnet/crnet_environment.mm

Issue 2206283003: [Cronet] Add CrNet.setUserAgent method on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@crnetgn
Patch Set: Unmark setPartialUserAgent as deprecated. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/crnet/crnet_environment.h ('k') | ios/crnet/test/crnet_http_tests.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/crnet/crnet_environment.mm
diff --git a/ios/crnet/crnet_environment.mm b/ios/crnet/crnet_environment.mm
index b63b59df987f8390fea552c4256e30d3cd70b65d..8bd9de09b61655d25953334c1458700f5459107d 100644
--- a/ios/crnet/crnet_environment.mm
+++ b/ios/crnet/crnet_environment.mm
@@ -264,12 +264,14 @@ void CrNetEnvironment::CloseAllSpdySessionsInternal() {
}
}
-CrNetEnvironment::CrNetEnvironment(const std::string& user_agent_product_name)
+CrNetEnvironment::CrNetEnvironment(const std::string& user_agent,
+ bool user_agent_partial)
: spdy_enabled_(false),
quic_enabled_(false),
sdch_enabled_(false),
main_context_(new net::URLRequestContext),
- user_agent_product_name_(user_agent_product_name),
+ user_agent_(user_agent),
+ user_agent_partial_(user_agent_partial),
net_log_(new net::NetLog) {}
void CrNetEnvironment::Install() {
@@ -382,16 +384,18 @@ void CrNetEnvironment::InitializeOnNetworkThread() {
acceptableLanguages = @"en-US,en";
std::string acceptable_languages =
[acceptableLanguages cStringUsingEncoding:NSUTF8StringEncoding];
- std::string user_agent =
- web::BuildUserAgentFromProduct(user_agent_product_name_);
+ if (user_agent_partial_) {
+ user_agent_ = web::BuildUserAgentFromProduct(user_agent_);
+ user_agent_partial_ = false;
+ }
// Set the user agent through NSUserDefaults. This sets it for both
// UIWebViews and WKWebViews, and javascript calls to navigator.userAgent
// return this value.
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
- @"UserAgent" : [NSString stringWithUTF8String:user_agent.c_str()]
+ @"UserAgent" : [NSString stringWithUTF8String:user_agent_.c_str()]
}];
main_context_->set_http_user_agent_settings(
- new net::StaticHttpUserAgentSettings(acceptable_languages, user_agent));
+ new net::StaticHttpUserAgentSettings(acceptable_languages, user_agent_));
main_context_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
main_context_->set_transport_security_state(
« no previous file with comments | « ios/crnet/crnet_environment.h ('k') | ios/crnet/test/crnet_http_tests.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698