Commit f7b51309 authored by kapishnikov's avatar kapishnikov Committed by Commit bot

Fixes in CrNet and Cronet frameworks

1. Port https://codereview.chromium.org/2115653002/
   to crnet_environment.mm
2. Port https://codereview.chromium.org/2110803002/ to
   crnet_environment.mm and cronet_environment.cc
3. Override CrNet FrameworkBundle, so that the icudtl.dat and
   IDS_ACCEPT_LANGUAGES can be read from the framework bundle itself.
4. Use base::mac::FrameworkBundle() instead of [NSBundle mainBundle].

Review-Url: https://codereview.chromium.org/2137623002
Cr-Commit-Position: refs/heads/master@{#404535}
parent dd7e82fd
......@@ -9,6 +9,7 @@
#include "base/at_exit.h"
#include "base/atomicops.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
......@@ -234,6 +235,7 @@ CronetEnvironment::~CronetEnvironment() {
void CronetEnvironment::InitializeOnNetworkThread() {
DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread());
base::FeatureList::InitializeInstance(std::string(), std::string());
// TODO(mef): Use net:UrlRequestContextBuilder instead of manual build.
main_context_.reset(new net::URLRequestContext);
main_context_->set_net_log(net_log_.get());
......
......@@ -11,12 +11,14 @@
#include "base/at_exit.h"
#include "base/atomicops.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/i18n/icu_util.h"
#include "base/json/json_writer.h"
#include "base/mac/bind_objc_block.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_block.h"
#include "base/macros.h"
......@@ -152,6 +154,10 @@ void CrNetEnvironment::Initialize() {
if (!g_at_exit_)
g_at_exit_ = new base::AtExitManager;
// Change the framework bundle to the bundle that contain CrNet framework.
// By default the framework bundle is set equal to the main (app) bundle.
NSBundle* frameworkBundle = [NSBundle bundleForClass:CrNet.class];
base::mac::SetOverrideFrameworkBundle(frameworkBundle);
#if !BUILDFLAG(USE_PLATFORM_ICU_ALTERNATIVES)
CHECK(base::i18n::InitializeICU());
#endif
......@@ -352,12 +358,14 @@ void CrNetEnvironment::ConfigureSdchOnNetworkThread() {
void CrNetEnvironment::InitializeOnNetworkThread() {
DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread());
base::FeatureList::InitializeInstance(std::string(), std::string());
ConfigureSdchOnNetworkThread();
// Use the framework bundle to search for resources.
NSBundle* frameworkBundle = base::mac::FrameworkBundle();
NSString* bundlePath =
[[NSBundle mainBundle] pathForResource:@"crnet_resources"
ofType:@"bundle"];
[frameworkBundle pathForResource:@"crnet_resources" ofType:@"bundle"];
NSBundle* bundle = [NSBundle bundleWithPath:bundlePath];
NSString* acceptableLanguages = NSLocalizedStringWithDefaultValue(
@"IDS_ACCEPT_LANGUAGES",
......@@ -422,6 +430,9 @@ void CrNetEnvironment::InitializeOnNetworkThread() {
net::HttpNetworkSession::Params params;
params.host_resolver = main_context_->host_resolver();
params.cert_verifier = main_context_->cert_verifier();
params.cert_transparency_verifier =
main_context_->cert_transparency_verifier();
params.ct_policy_enforcer = main_context_->ct_policy_enforcer();
params.channel_id_service = main_context_->channel_id_service();
params.transport_security_state = main_context_->transport_security_state();
params.proxy_service = main_context_->proxy_service();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment