OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/crnet/crnet_environment.h" | 5 #include "ios/crnet/crnet_environment.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 ofType:@"bundle"]; | 360 ofType:@"bundle"]; |
361 NSBundle* bundle = [NSBundle bundleWithPath:bundlePath]; | 361 NSBundle* bundle = [NSBundle bundleWithPath:bundlePath]; |
362 NSString* acceptableLanguages = NSLocalizedStringWithDefaultValue( | 362 NSString* acceptableLanguages = NSLocalizedStringWithDefaultValue( |
363 @"IDS_ACCEPT_LANGUAGES", | 363 @"IDS_ACCEPT_LANGUAGES", |
364 @"Localizable", | 364 @"Localizable", |
365 bundle, | 365 bundle, |
366 @"en-US,en", | 366 @"en-US,en", |
367 @"These values are copied from Chrome's .xtb files, so the same " | 367 @"These values are copied from Chrome's .xtb files, so the same " |
368 "values are used in the |Accept-Language| header. Key name matches " | 368 "values are used in the |Accept-Language| header. Key name matches " |
369 "Chrome's."); | 369 "Chrome's."); |
370 DCHECK(acceptableLanguages); | 370 if (acceptableLanguages == Nil) |
| 371 acceptableLanguages = @"en-US,en"; |
371 std::string acceptable_languages = | 372 std::string acceptable_languages = |
372 [acceptableLanguages cStringUsingEncoding:NSUTF8StringEncoding]; | 373 [acceptableLanguages cStringUsingEncoding:NSUTF8StringEncoding]; |
373 std::string user_agent = | 374 std::string user_agent = |
374 web::BuildUserAgentFromProduct(user_agent_product_name_); | 375 web::BuildUserAgentFromProduct(user_agent_product_name_); |
375 // Set the user agent through NSUserDefaults. This sets it for both | 376 // Set the user agent through NSUserDefaults. This sets it for both |
376 // UIWebViews and WKWebViews, and javascript calls to navigator.userAgent | 377 // UIWebViews and WKWebViews, and javascript calls to navigator.userAgent |
377 // return this value. | 378 // return this value. |
378 [[NSUserDefaults standardUserDefaults] registerDefaults:@{ | 379 [[NSUserDefaults standardUserDefaults] registerDefaults:@{ |
379 @"UserAgent" : [NSString stringWithUTF8String:user_agent.c_str()] | 380 @"UserAgent" : [NSString stringWithUTF8String:user_agent.c_str()] |
380 }]; | 381 }]; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 480 |
480 return user_agent_settings->GetUserAgent(); | 481 return user_agent_settings->GetUserAgent(); |
481 } | 482 } |
482 | 483 |
483 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 484 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
484 PostToNetworkThread( | 485 PostToNetworkThread( |
485 FROM_HERE, | 486 FROM_HERE, |
486 base::Bind(&net::ClearHttpCache, main_context_getter_, | 487 base::Bind(&net::ClearHttpCache, main_context_getter_, |
487 network_io_thread_->task_runner(), base::BindBlock(callback))); | 488 network_io_thread_->task_runner(), base::BindBlock(callback))); |
488 } | 489 } |
OLD | NEW |