Commit a7ce8df9 authored by ellyjones's avatar ellyjones Committed by Commit bot

ios: add CrNet

This code is copied directly from the downstream iOS repo, except for the
changes to ios/ios.gyp.

BUG=483209

Review URL: https://codereview.chromium.org/1125293004

Cr-Commit-Position: refs/heads/master@{#330952}
parent 01edd9af
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>google.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Provides a main() function for an empty dummy app.
int main(int argc, char *argv[]) {
return 0;
}
#!/usr/bin/env python
#
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Links the deps of a binary into a static library.
Run with a working directory, the name of a binary target, and the name of the
static library that should be produced. For example:
$ link_dependencies.py out/Release-iphoneos \
crnet_consumer.app/crnet_consumer \
out/Release-iphoneos/crnet_standalone.a
"""
import argparse
import os
import subprocess
class SubprocessError(Exception):
pass
def extract_inputs(query_result, prefix=''):
"""Extracts inputs from ninja query output.
Given 'ninja -t query' output for a target, extracts all the inputs of that
target, prefixing them with an optional prefix. Inputs prefixed with '|' are
implicit, so we discard them as they shouldn't be linked into the resulting
binary (these are things like the .ninja files themselves, dep lists, and so
on).
Example query result:
arch/crnet_consumer.armv7:
input: link
obj/[long path...]/crnet_consumer.crnet_consumer_app_delegate.armv7.o
obj/[long path...]/crnet_consumer.crnet_consumer_view_controller.armv7.o
obj/[long path...]/crnet_consumer.main.armv7.o
libcrnet.a
libdata_reduction_proxy_code_browser.a
... many more inputs ...
liburl_util.a
| obj/content/content.actions_depends.stamp
| gen/components/data_reduction_proxy/common/version.h
| obj/ui/resources/ui_resources.actions_rules_copies.stamp
... more implicit inputs ...
outputs:
crnet_consumer.app/crnet_consumer
Args:
query_result: output from 'ninja -t query'
prefix: optional file system path to prefix to returned inputs
Returns:
A list of the inputs.
"""
extracting = False
inputs = []
for line in query_result.splitlines():
if line.startswith(' input:'):
extracting = True
elif line.startswith(' outputs:'):
extracting = False
elif extracting and '|' not in line:
inputs.append(os.path.join(prefix, line.strip()))
return inputs
def query_ninja(target, workdir, prefix=''):
"""Returns the inputs for the named target.
Queries ninja for the set of inputs of the named target, then returns the list
of inputs to that target.
Args:
target: ninja target name to query for
workdir: workdir for ninja
prefix: optional file system path to prefix to returned inputs
Returns:
A list of file system paths to the inputs to the named target.
"""
proc = subprocess.Popen(['ninja', '-C', workdir, '-t', 'query', target],
stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
return extract_inputs(stdout, prefix)
def is_library(target):
"""Returns whether target is a library file."""
return os.path.splitext(target)[1] in ('.a', '.o')
def library_deps(targets, workdir, query=query_ninja):
"""Returns the set of library dependencies for the supplied targets.
The entries in the targets list can be either a static library, an object
file, or an executable. Static libraries and object files are incorporated
directly; executables are treated as being thin executable inputs to a fat
executable link step, and have their own library dependencies added in their
place.
Args:
targets: list of targets to include library dependencies from
workdir: working directory to run ninja queries in
query: function taking target, workdir, and prefix and returning an input
set
Returns:
Set of library dependencies.
"""
deps = set()
for target in targets:
if is_library(target):
deps.add(os.path.join(workdir, target))
else:
deps = deps.union(query(target, workdir, workdir))
return deps
def link(output, inputs):
"""Links output from inputs using libtool.
Args:
output: file system path to desired output library
inputs: list of file system paths to input libraries
"""
p = subprocess.Popen(['libtool', '-o', output] + inputs)
p.communicate()
if p.returncode != 0:
message = "subprocess libtool returned {0}".format(p.returncode)
raise SubprocessError(message)
def main():
parser = argparse.ArgumentParser(
description='Link dependencies of a ninja target into a static library')
parser.add_argument('workdir', nargs=1, help='ninja working directory')
parser.add_argument('target', nargs=1, help='target to query for deps')
parser.add_argument('output', nargs=1, help='path to output static library')
args = parser.parse_args()
inputs = query_ninja(args.target[0], args.workdir[0])
link(args.output[0], list(library_deps(inputs, args.workdir[0])))
if __name__ == '__main__':
main()
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from link_dependencies import extract_inputs, library_deps
import unittest
class ExtractInputsTest(unittest.TestCase):
def test_empty(self):
self.assertListEqual([], extract_inputs(''))
query_result = '\n'.join([
'header',
' input: link',
' outputs: nothing',
'footer'
])
self.assertListEqual([], extract_inputs(query_result))
def test_one_input(self):
query_result = '\n'.join([
'header',
' input: link',
' foo',
' outputs: link',
' quxx',
'footer'
])
self.assertListEqual(['foo'], extract_inputs(query_result))
def test_many_inputs(self):
query_result = '\n'.join([
'header',
' input: link',
' foo',
' bar',
' baz',
' outputs:',
' quxx',
'footer'
])
self.assertListEqual(['foo', 'bar', 'baz'], extract_inputs(query_result))
def test_no_pipe_inputs(self):
query_result = '\n'.join([
'header',
' input: link',
' |foo',
' bar',
' |baz',
' outputs:',
' quxx',
'footer'
])
self.assertListEqual(['bar'], extract_inputs(query_result))
def test_prefix(self):
query_result = '\n'.join([
'header',
' input: link',
' bar',
' outputs:',
'footer'
])
self.assertListEqual(['foo/bar'],
extract_inputs(query_result, 'foo/'))
class LibraryDepsTest(unittest.TestCase):
def mkquery(self, answers):
"""Creates a query function for library_deps.
Creates a query function for library_deps that returns answers from the
supplied map.
"""
return lambda target, unused_workdir, unused_prefix='': answers[target]
def test_empty(self):
self.assertEqual(set(), library_deps([], 'wd', self.mkquery({})))
def test_nonarch(self):
deps = ['abc.a', 'def.o', 'abc.a']
self.assertEqual({'wd/abc.a', 'wd/def.o'},
library_deps(deps, 'wd', self.mkquery({})))
def test_arch(self):
dep_map = {'abc': ['wd/def.a', 'wd/ghi.o']}
deps = ['abc', 'jkl.o']
self.assertEqual({'wd/def.a', 'wd/ghi.o', 'wd/jkl.o'},
library_deps(deps, 'wd', self.mkquery(dep_map)))
def test_arch_many(self):
dep_map = {'abc': ['wd/def.o', 'wd/ghi.a'],
'def': ['wd/def.o', 'wd/jkl.a']}
deps = ['abc', 'def', 'def.o']
self.assertEqual({'wd/def.o', 'wd/ghi.a', 'wd/jkl.a'},
library_deps(deps, 'wd', self.mkquery(dep_map)))
if __name__ == '__main__':
unittest.main()
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Foundation/Foundation.h>
// A block, that takes a request, and returns YES if the request should
// be handled.
typedef BOOL(^RequestFilterBlock)(NSURLRequest *request);
// A callback, called when the clearCache message has completed. The |errorCode|
// is a network stack error code indicating whether the clear request succeeded
// or not. Even if the request failed, the cache may have been cleared anyway,
// or it may not have; it is not useful to retry a failing cache-clear attempt.
// The only real use of |errorCode| is for error reporting and statistics
// gathering.
typedef void(^ClearCacheCallback)(int errorCode);
// Interface for installing CrNet.
@interface CrNet : NSObject
// Sets whether SPDY should be supported by CrNet. This method only has any
// effect before |install| is called.
+ (void)setSpdyEnabled:(BOOL)spdyEnabled;
// Sets whether QUIC should be supported by CrNet. This method only has any
// effect before |install| is called.
+ (void)setQuicEnabled:(BOOL)quicEnabled;
// Set the alternate protocol threshold. Servers announce alternate protocols
// with a probability value; any alternate protocol whose probability value is
// greater than this value will be used, so |alternateProtocolThreshold| == 0
// implies any announced alternate protocol will be used, and
// |alternateProtocolThreshold| == 1 implies no alternate protocol will ever be
// used. Note that individual alternate protocols must also be individually
// enabled to be considered; currently the only alternate protocol is QUIC (SPDY
// is not controlled by this mechanism).
//
// For example, imagine your service has two frontends a.service.com and
// b.service.com, and you would like to divide your users into three classes:
// Users who use QUIC for both a and b
// Users who use QUIC for a but not b
// Users who use QUIC for neither a nor b
// You can achieve that effect with:
// a.service.com advertises QUIC with p=0.67
// b.service.com advertises QUIC with p=0.33
// alternateProtocolThreshold set to a uniform random number in [0,1]
// Now equal proportions of users will fall into the three experimental groups.
//
// The default for this value is 1.0, i.e. all alternate protocols disabled.
+ (void)setAlternateProtocolThreshold:(double)alternateProtocolThreshold;
// |userAgent| is expected to be of the form Product/Version.
// Example: Foo/3.0.0.0
//
// This method only has any effect before |install| is called.
+ (void)setPartialUserAgent:(NSString *)userAgent;
// Set the block used to determine whether or not CrNet should handle the
// request. If this is not set, CrNet will handle all requests.
// Must not be called while requests are in progress. This method can be called
// either before or after |install|.
+ (void)setRequestFilterBlock:(RequestFilterBlock)block;
// Installs CrNet. Once installed, CrNet intercepts and handles all
// NSURLConnection and NSURLRequests issued by the app, including UIWebView page
// loads.
+ (void)install;
// Installs CrNet into an NSURLSession, passed in by the caller. Note that this
// NSURLSession will share settings with the sharedSession, which the |install|
// method installs CrNet into. This method must be called after |install|.
+ (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config;
// Installs CrNet. This function is a deprecated shortcut for:
// [CrNet setPartialUserAgent:userAgent];
// [CrNet install];
// See the documentation for |setPartialUserAgent| for details about the
// |userAgent| argument.
+ (void)installWithPartialUserAgent:(NSString *)userAgent
__attribute__((deprecated));
// Installs CrNet. This function is a deprecated shortcut for:
// [CrNet setPartialUserAgent:userAgent];
// [CrNet install];
// The |enableDataReductionProxy| argument is ignored since data reduction proxy
// support is currently missing from CrNet. See |setPartialUserAgent| for
// details about the |userAgent| argument.
+ (void)installWithPartialUserAgent:(NSString *)userAgent
enableDataReductionProxy:(BOOL)enableDataReductionProxy
__attribute__((deprecated));
// Installs CrNet. This function is a deprecated shortcut for:
// [CrNet setPartialUserAgent:userAgent];
// [CrNet setRequestFilterBlock:block];
// [CrNet install];
// See |setPartialUserAgent| and |setRequestFilterBlock| for details about the
// |userAgent| and |requestFilterBlock| arguments respectively.
+ (void)installWithPartialUserAgent:(NSString *)userAgent
withRequestFilterBlock:(RequestFilterBlock)requestFilterBlock
__attribute__((deprecated));
// Starts net-internals logging to a file named |fileName| in the application
// temporary directory. |fileName| must not be empty. Log level is determined
// by |logBytes| - if YES then LOG_ALL otherwise LOG_ALL_BUT_BYTES. If the file
// exists it is truncated before starting. If actively logging the call is
// ignored.
+ (void)startNetLogToFile:(NSString *)fileName logBytes:(BOOL)logBytes;
// Stop net-internals logging and flush file to disk. If a logging session is
// not in progress this call is ignored.
+ (void)stopNetLog;
// Closes all current SPDY sessions. Do not do this unless you know what
// you're doing.
// TODO(alokm): This is a hack. Remove it later.
+ (void)closeAllSpdySessions;
// "Uninstalls" CrNet. This means that CrNet will stop intercepting requests.
// However, it won't tear down all of the CrNet environment.
+ (void)uninstall;
// Returns the full user-agent that the stack uses.
// This is the exact string servers will see.
+ (NSString *)userAgent;
// Clears CrNet's http cache. The supplied callback, if not nil, is run on an
// unspecified thread.
+ (void)clearCacheWithCompletionCallback:(ClearCacheCallback)completionBlock;
@end
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/crnet/CrNet.h"
#include "base/logging.h"
#import "ios/net/crn_http_protocol_handler.h"
#import "ios/crnet/crnet_environment.h"
static CrNetEnvironment* g_chrome_net = NULL;
static BOOL g_spdy_enabled = YES;
static BOOL g_quic_enabled = NO;
static NSString *g_user_agent = nil;
static double g_alternate_protocol_threshold = 1.0;
static RequestFilterBlock g_request_filter_block = nil;
@implementation CrNet
+ (void)setSpdyEnabled:(BOOL)spdyEnabled {
g_spdy_enabled = spdyEnabled;
}
+ (void)setQuicEnabled:(BOOL)quicEnabled {
g_quic_enabled = quicEnabled;
}
+ (void)setPartialUserAgent:(NSString *)userAgent {
g_user_agent = userAgent;
}
+ (void)setAlternateProtocolThreshold:(double)alternateProtocolThreshold {
g_alternate_protocol_threshold = alternateProtocolThreshold;
}
+ (void)installInternal {
CrNetEnvironment::Initialize();
std::string partial_user_agent =
[g_user_agent cStringUsingEncoding:NSASCIIStringEncoding];
g_chrome_net = new CrNetEnvironment(partial_user_agent);
g_chrome_net->set_spdy_enabled(g_spdy_enabled);
g_chrome_net->set_quic_enabled(g_quic_enabled);
g_chrome_net->set_alternate_protocol_threshold(
g_alternate_protocol_threshold);
g_chrome_net->Install();
g_chrome_net->SetHTTPProtocolHandlerRegistered(true);
g_chrome_net->SetRequestFilterBlock(g_request_filter_block);
}
+ (void)install {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self installInternal];
});
}
+ (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config {
g_chrome_net->InstallIntoSessionConfiguration(config);
}
+ (void)installWithPartialUserAgent:(NSString *)partialUserAgent {
[self setPartialUserAgent:partialUserAgent];
[self install];
}
+ (void)installWithPartialUserAgent:(NSString *)partialUserAgent
enableDataReductionProxy:(BOOL)enableDataReductionProxy {
LOG(ERROR) << "enableDataReductionProxy is no longer respected. The "
<< "functionality has been removed from CrNet.";
[self setPartialUserAgent:partialUserAgent];
[self install];
}
+ (void)installWithPartialUserAgent:(NSString *)partialUserAgent
withRequestFilterBlock:(RequestFilterBlock)requestFilterBlock {
[self setPartialUserAgent:partialUserAgent];
[self setRequestFilterBlock:requestFilterBlock];
[self install];
}
+ (void)setRequestFilterBlock:(RequestFilterBlock)block {
if (g_chrome_net)
g_chrome_net->SetRequestFilterBlock(block);
else
g_request_filter_block = block;
}
+ (void)uninstall {
if (g_chrome_net) {
g_chrome_net->SetHTTPProtocolHandlerRegistered(false);
}
}
+ (void)startNetLogToFile:(NSString *)fileName logBytes:(BOOL)logBytes {
if (g_chrome_net && [fileName length]) {
g_chrome_net->StartNetLog([fileName UTF8String], logBytes);
}
}
+ (void)stopNetLog {
if (g_chrome_net) {
return g_chrome_net->StopNetLog();
}
}
+ (NSString *)userAgent {
if (!g_chrome_net) {
return nil;
}
std::string user_agent = g_chrome_net->user_agent();
return [NSString stringWithCString:user_agent.c_str()
encoding:[NSString defaultCStringEncoding]];
}
+ (void)closeAllSpdySessions {
if (g_chrome_net) {
return g_chrome_net->CloseAllSpdySessions();
}
}
+ (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback {
if (g_chrome_net) {
g_chrome_net->ClearCache(clearCacheCallback);
}
}
@end
include_rules = [
"+components/webp_transcode",
"+crypto/nss_util.h",
"+ios/crnet",
"+ios/net",
"+ios/web/public/user_agent.h",
"+net"
]
droger@chromium.org
ellyjones@chromium.org
mef@chromium.org
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "am,en-GB,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ar,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "bg-BG,bg";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "bn-IN,bn,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ca-ES,ca";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "cs-CZ,cs";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "da-DK,da,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "de-DE,de,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "el-GR,el";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "en-GB,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. DO NOT TRANSLATE. */
"IDS_ACCEPT_LANGUAGES" = "en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "es-419,es";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "es-ES,es";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "et-EE,et,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "fa,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "fi-FI,fi,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "fil,fil-PH,tl,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "fr-FR,fr,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "gu-IN,gu,hi-IN,hi,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "he-IL,he,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "hi-IN,hi,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "hr-HR,hr,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "hu-HU,hu,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "id-ID,id,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "it-IT,it,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ja,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "kn-IN,kn,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ko-KR,ko,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "lt,en-US,en,ru,pl";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "lv-LV,lv,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ml-IN,ml,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "mr-IN,mr,hi-IN,hi,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. DO NOT TRANSLATE. */
"IDS_ACCEPT_LANGUAGES" = "ms,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "nb-NO,nb,no,nn,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "nl-NL,nl,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "pl-PL,pl,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "pt-BR,pt,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "pt-PT,pt,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. DO NOT TRANSLATE. */
"IDS_ACCEPT_LANGUAGES" = "pt-PT,pt,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ro-RO,ro,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ru-RU,ru,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "sk-SK,sk,cs,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "sl-SI,sl,en-GB,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "sr-RS,sr,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "sv-SE,sv,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "sw,en-GB,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "ta-IN,ta,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "te-IN,te,hi-IN,hi,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "th-TH,th";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "tr-TR,tr,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "uk-UA,uk,ru,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. */
"IDS_ACCEPT_LANGUAGES" = "vi-VN,vi,fr-FR,fr,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. DO NOT TRANSLATE. */
"IDS_ACCEPT_LANGUAGES" = "zh-CN,zh";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. DO NOT TRANSLATE. */
"IDS_ACCEPT_LANGUAGES" = "zh-TW,zh,en-US,en";
\ No newline at end of file
/* These values are copied from Chrome's .xtb files, this is so the same values are used in the |Accept-Language| header. Key name matches Chrome's. DO NOT TRANSLATE. */
"IDS_ACCEPT_LANGUAGES" = "zh-CN,zh";
\ No newline at end of file
This localization directory contains language strings taken from Chrome. These
language strings are taken from Chrome's *.xtb files with the key
IDS_ACCEPT_LANGUAGES.
DO NOT translate strings with a IDS_ACCEPT_LANGUAGES key from these .strings
files in the translation console.
On top of Chrome's language list, the following languages were added:
"pt" "ms" "zh"
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
import time
SUPPORTED_ARCHES = ['i386', 'x86_64', 'armv7', 'arm64']
class SubprocessError(Exception):
pass
class ConfigurationError(Exception):
pass
def out_directories(root):
"""Returns all output directories containing crnet objects under root.
Currently this list is just hardcoded.
Args:
root: prefix for output directories.
"""
out_dirs = ['Release-iphoneos', 'Release-iphonesimulator']
return map(lambda x: os.path.join(root, 'out', x), out_dirs)
def check_command(command):
"""Runs a command, raising an exception if it fails.
If the command returns a nonzero exit code, prints any data the command
emitted on stdout and stderr.
Args:
command: command to execute, in argv format.
Raises:
SubprocessError: the specified command returned nonzero exit status.
"""
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if p.returncode == 0:
return
message = 'Command failed: {0} (status {1})'.format(command, p.returncode)
print message
print 'stdout: {0}'.format(stdout)
print 'stderr: {0}'.format(stderr)
raise SubprocessError(message)
def file_contains_string(path, string):
"""Returns whether the file named by path contains string.
Args:
path: path of the file to search.
string: string to search the file for.
Returns:
True if file contains string, False otherwise.
"""
with open(path, 'r') as f:
for line in f:
if string in line:
return True
return False
def is_object_filename(filename):
"""Returns whether the given filename names an object file.
Args:
filename: filename to inspect.
Returns:
True if filename names an object file, false otherwise.
"""
(_, ext) = os.path.splitext(filename)
return ext in ('.a', '.o')
class Step(object):
"""Represents a single step of the crnet build process.
This parent class exists only to define the interface Steps present and keep
track of elapsed time for each step. Subclasses of Step should override the
run() method, which is called internally by start().
Attributes:
name: human-readable name of this step, used in debug output.
started_at: seconds since epoch that this step started running at.
"""
def __init__(self, name):
self._name = name
self._started_at = None
self._ended_at = None
@property
def name(self):
return self._name
def start(self):
"""Start running this step.
This method keeps track of how long the run() method takes to run and emits
the elapsed time after run() returns.
"""
self._started_at = time.time()
print '{0}: '.format(self._name),
sys.stdout.flush()
self._run()
self._ended_at = time.time()
print '{0:.2f}s'.format(self._ended_at - self._started_at)
def _run(self):
"""Actually run this step.
Subclasses should override this method to implement their own step logic.
"""
raise NotImplementedError
class CleanStep(Step):
"""Clean the build output directories.
This step deletes intermediates generated by the build process. Some of these
intermediates (crnet_consumer.app and crnet_resources.bundle) are directories,
which contain files ninja doesn't know and hence won't remove, so the run()
method here explicitly deletes those directories before running 'ninja -t
clean'.
Attributes:
dirs: list of output directories to clean.
"""
def __init__(self, root):
super(CleanStep, self).__init__('clean')
self._dirs = out_directories(root)
def _run(self):
"""Runs the clean step.
Deletes crnet_consumer.app and crnet_resources.bundle in each output
directory and runs 'ninja -t clean' in each output directory.
"""
for d in self._dirs:
if os.path.exists(os.path.join(d, 'crnet_consumer.app')):
shutil.rmtree(os.path.join(d, 'crnet_consumer.app'))
if os.path.exists(os.path.join(d, 'crnet_resources.bundle')):
shutil.rmtree(os.path.join(d, 'crnet_resources.bundle'))
check_command(['ninja', '-C', d, '-t', 'clean'])
class HooksStep(Step):
"""Validates the gyp config and reruns gclient hooks.
Attributes:
root: directory to find gyp config under.
"""
def __init__(self, root):
super(HooksStep, self).__init__('hooks')
self._root = root
def _run(self):
"""Runs the hooks step.
Checks that root/build/common.gypi contains target_subarch = both in a crude
way, then calls 'gclient runhooks'. TODO(ellyjones): parse common.gypi in a
more robust way.
Raises:
ConfigurationError: if target_subarch != both
"""
common_gypi = os.path.join(self._root, 'build', 'common.gypi')
if not file_contains_string(common_gypi, "'target_subarch%': 'both'"):
raise ConfigurationError('target_subarch must be both in {0}'.format(
common_gypi))
check_command(['gclient', 'runhooks'])
class BuildStep(Step):
"""Builds all the intermediate crnet binaries.
All the hard work of this step is done by ninja; this step just shells out to
ninja to build the crnet_pack target.
Attributes:
dirs: output directories to run ninja in.
"""
def __init__(self, root):
super(BuildStep, self).__init__('build')
self._dirs = out_directories(root)
def _run(self):
"""Runs the build step.
For each output directory, run ninja to build the crnet_pack target in that
directory.
"""
for d in self._dirs:
check_command(['ninja', '-C', d, 'crnet_pack'])
class PackageStep(Step):
"""Packages the built object files for release.
The release format is a tarball, containing one gzipped tarball per
architecture and a manifest file, which lists metadata about the build.
Attributes:
outdirs: directories containing built object files.
workdir: temporary working directory. Deleted at end of the step.
archdir: temporary directory under workdir. Used for collecting per-arch
binaries.
proddir: temporary directory under workdir. Used for intermediate per-arch
tarballs.
"""
def __init__(self, root, outfile):
super(PackageStep, self).__init__('package')
self._outdirs = out_directories(root)
self._outfile = outfile
def _run(self):
"""Runs the package step.
Packages each architecture from |root| into an individual .tar.gz file, then
packages all the .tar.gz files into one .tar file, which is written to
|outfile|.
"""
(workdir, archdir, proddir) = self.create_work_dirs()
for arch in SUPPORTED_ARCHES:
self.package_arch(archdir, proddir, arch)
self.package(proddir)
shutil.rmtree(workdir)
def create_work_dirs(self):
"""Creates working directories and returns their paths."""
workdir = tempfile.mkdtemp()
archdir = os.path.join(workdir, 'arch')
proddir = os.path.join(workdir, 'prod')
os.mkdir(archdir)
os.mkdir(proddir)
return (workdir, archdir, proddir)
def object_files_for_arch(self, arch):
"""Returns a list of object files for the given architecture.
Under each outdir d, per-arch files are stored in d/arch, and object files
for a given arch contain the arch's name as a substring.
Args:
arch: architecture name. Must be in SUPPORTED_ARCHES.
Returns:
List of full pathnames to object files in outdirs for the named arch.
"""
arch_files = []
for d in self._outdirs:
files = os.listdir(os.path.join(d, 'arch'))
for f in filter(is_object_filename, files):
if arch in f:
arch_files.append(os.path.join(d, 'arch', f))
return arch_files
def package_arch(self, archdir, proddir, arch):
"""Packages an individual architecture.
Copies all the object files for the specified arch into a working directory
under self.archdir, then tars them up into a gzipped tarball under
self.proddir.
Args:
archdir: directory to stage architecture files in.
proddir: directory to stage result tarballs in.
arch: architecture name to package. Must be in SUPPORTED_ARCHES.
"""
arch_files = self.object_files_for_arch(arch)
os.mkdir(os.path.join(archdir, arch))
for f in arch_files:
shutil.copy(f, os.path.join(archdir, arch))
out_filename = os.path.join(proddir, '{0}.tar.gz'.format(arch))
check_command(['tar', '-C', archdir, '-czf', out_filename, arch])
def package(self, proddir):
"""Final packaging step. Packages all the arch tarballs into one tarball."""
arch_tarballs = []
for a in SUPPORTED_ARCHES:
arch_tarballs.append('{0}.tar.gz'.format(a))
check_command(['tar', '-C', proddir, '-cf', self._outfile] +
arch_tarballs)
def main():
step_classes = {
'clean': lambda: CleanStep(args.rootdir),
'hooks': lambda: HooksStep(args.rootdir),
'build': lambda: BuildStep(args.rootdir),
'package': lambda: PackageStep(args.rootdir, args.outfile)
}
parser = argparse.ArgumentParser(description='Build and package crnet.')
parser.add_argument('--outfile', dest='outfile', default='crnet.tar',
help='Output file to generate (default: crnet.tar)')
parser.add_argument('--rootdir', dest='rootdir', default='../..',
help='Root directory to build from (default: ../..)')
parser.add_argument('steps', metavar='step', nargs='*')
args = parser.parse_args()
step_names = args.steps or ['clean', 'hooks', 'build', 'package']
steps = [step_classes[x]() for x in step_names]
for step in steps:
step.start()
if __name__ == '__main__':
main()
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'targets': [
{
'target_name': 'crnet',
'type': 'static_library',
'dependencies': [
'../../components/components.gyp:webp_transcode',
'../../ios/net/ios_net.gyp:ios_net',
'../../ios/web/ios_web.gyp:user_agent',
'../../net/net.gyp:net',
'crnet_resources',
],
'mac_framework_headers': [
'CrNet.h',
],
'direct_dependent_settings': {
'include_dirs': [ '.' ],
},
'sources': [
# TODO(ellyjones): http://crbug.com/485144
'../../net/url_request/sdch_dictionary_fetcher.cc',
'../../net/url_request/sdch_dictionary_fetcher.h',
'CrNet.h',
'CrNet.mm',
'crnet_environment.h',
'crnet_environment.mm',
'crnet_net_log.h',
'crnet_net_log.cc',
],
'defines': [
# TODO(stuartmorgan): Revisit the way this is set, and the above is
# built, once the web/ layer is complete. Note that this setting doesn't
# propagate to any included targets.
'CRNET=1',
],
'xcode_settings': {
'DEAD_CODE_STRIPPING': 'YES',
},
},
{
# This bundle contains "Accept-Languages" header values for known locales.
# TODO(huey): These strings should be auto-generated from chrome's .xtb
# files, not hardcoded.
'target_name': 'crnet_resources',
'type': 'loadable_module',
'mac_bundle': 1,
'mac_bundle_resources': [
'Resources/Localization/am.lproj/Localizable.strings',
'Resources/Localization/ar.lproj/Localizable.strings',
'Resources/Localization/bg.lproj/Localizable.strings',
'Resources/Localization/bn.lproj/Localizable.strings',
'Resources/Localization/ca.lproj/Localizable.strings',
'Resources/Localization/cs.lproj/Localizable.strings',
'Resources/Localization/da.lproj/Localizable.strings',
'Resources/Localization/de.lproj/Localizable.strings',
'Resources/Localization/el.lproj/Localizable.strings',
'Resources/Localization/en-GB.lproj/Localizable.strings',
'Resources/Localization/en.lproj/Localizable.strings',
'Resources/Localization/es-419.lproj/Localizable.strings',
'Resources/Localization/es.lproj/Localizable.strings',
'Resources/Localization/fa.lproj/Localizable.strings',
'Resources/Localization/fi.lproj/Localizable.strings',
'Resources/Localization/fil.lproj/Localizable.strings',
'Resources/Localization/fr.lproj/Localizable.strings',
'Resources/Localization/gu.lproj/Localizable.strings',
'Resources/Localization/he.lproj/Localizable.strings',
'Resources/Localization/hi.lproj/Localizable.strings',
'Resources/Localization/hr.lproj/Localizable.strings',
'Resources/Localization/hu.lproj/Localizable.strings',
'Resources/Localization/id.lproj/Localizable.strings',
'Resources/Localization/it.lproj/Localizable.strings',
'Resources/Localization/ja.lproj/Localizable.strings',
'Resources/Localization/kn.lproj/Localizable.strings',
'Resources/Localization/ko.lproj/Localizable.strings',
'Resources/Localization/lt.lproj/Localizable.strings',
'Resources/Localization/lv.lproj/Localizable.strings',
'Resources/Localization/ml.lproj/Localizable.strings',
'Resources/Localization/mr.lproj/Localizable.strings',
'Resources/Localization/ms.lproj/Localizable.strings',
'Resources/Localization/nb.lproj/Localizable.strings',
'Resources/Localization/nl.lproj/Localizable.strings',
'Resources/Localization/pl.lproj/Localizable.strings',
'Resources/Localization/pt-BR.lproj/Localizable.strings',
'Resources/Localization/pt-PT.lproj/Localizable.strings',
'Resources/Localization/pt.lproj/Localizable.strings',
'Resources/Localization/ro.lproj/Localizable.strings',
'Resources/Localization/ru.lproj/Localizable.strings',
'Resources/Localization/sk.lproj/Localizable.strings',
'Resources/Localization/sl.lproj/Localizable.strings',
'Resources/Localization/sr.lproj/Localizable.strings',
'Resources/Localization/sv.lproj/Localizable.strings',
'Resources/Localization/sw.lproj/Localizable.strings',
'Resources/Localization/ta.lproj/Localizable.strings',
'Resources/Localization/te.lproj/Localizable.strings',
'Resources/Localization/th.lproj/Localizable.strings',
'Resources/Localization/tr.lproj/Localizable.strings',
'Resources/Localization/uk.lproj/Localizable.strings',
'Resources/Localization/vi.lproj/Localizable.strings',
'Resources/Localization/zh-Hans.lproj/Localizable.strings',
'Resources/Localization/zh-Hant.lproj/Localizable.strings',
'Resources/Localization/zh.lproj/Localizable.strings',
],
'all_dependent_settings': {
'link_settings': {
'mac_bundle_resources': [
'>(PRODUCT_DIR)/crnet_resources.bundle',
],
},
},
},
],
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>chromium.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'targets': [],
'conditions': [
# Our shared library hack only works with ninja; xcode cannot generate
# iOS build targets for dynamic libraries.
['"<(GENERATOR)"=="ninja"', {
'targets': [
{
'target_name': 'crnet_consumer',
'type': 'executable',
'mac_bundle': 1,
'dependencies': [
'../../../ios/crnet/crnet_pack.gyp:crnet_pack',
],
'sources': [
'crnet_consumer_app_delegate.h',
'crnet_consumer_app_delegate.mm',
'crnet_consumer_view_controller.h',
'crnet_consumer_view_controller.m',
'main.m',
],
'mac_bundle_resources': [
'crnet-consumer-Info.plist',
'../../../third_party/icu/source/data/in/icudtl.dat',
],
'include_dirs': [
'../../..',
'..',
],
'link_settings': {
'libraries': [
'<(PRODUCT_DIR)/libcrnet_standalone.a',
'$(SDKROOT)/System/Library/Frameworks/CFNetwork.framework',
'$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
'$(SDKROOT)/System/Library/Frameworks/CoreGraphics.framework',
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
'$(SDKROOT)/System/Library/Frameworks/MobileCoreServices.framework',
'$(SDKROOT)/System/Library/Frameworks/UIKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Security.framework',
'$(SDKROOT)/System/Library/Frameworks/SystemConfiguration.framework',
'$(SDKROOT)/usr/lib/libresolv.dylib',
'$(SDKROOT)/usr/lib/libsqlite3.dylib',
'$(SDKROOT)/usr/lib/libxml2.dylib',
],
},
'xcode_settings': {
'CLANG_ENABLE_OBJC_ARC': 'YES',
'DEAD_CODE_STRIPPING': 'YES',
'INFOPLIST_FILE': 'crnet-consumer-Info.plist',
},
},
],
}],
],
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CRNET_CONSUMER_APP_DELEGATE_
#define CRNET_CONSUMER_APP_DELEGATE_
#import <UIKit/UIKit.h>
@class CrNetConsumerViewController;
// The main app controller and UIApplicationDelegate.
@interface CrNetConsumerAppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;
@property(strong, nonatomic) CrNetConsumerViewController* viewController;
@end
#endif // CRNET_CONSUMER_APP_DELEGATE_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "crnet_consumer_app_delegate.h"
#import "CrNet.h"
#include "base/format_macros.h"
#import "crnet_consumer_view_controller.h"
@implementation CrNetConsumerAppDelegate {
NSUInteger _counter;
}
@synthesize window;
@synthesize viewController;
// Returns a file name to save net internals logging. This method suffixes
// the ivar |_counter| to the file name so a new name can be obtained by
// modifying that.
- (NSString *)currentNetLogFileName {
return [NSString
stringWithFormat:@"crnet-consumer-net-log%" PRIuNS ".json", _counter];
}
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[CrNet setPartialUserAgent:@"Dummy/1.0"];
[CrNet setQuicEnabled:YES];
// Always use QUIC if able.
[CrNet setAlternateProtocolThreshold:0.0];
[CrNet install];
[CrNet startNetLogToFile:[self currentNetLogFileName] logBytes:NO];
NSURLSessionConfiguration* config =
[NSURLSessionConfiguration ephemeralSessionConfiguration];
[CrNet installIntoSessionConfiguration:config];
// Just for fun, don't route chromium.org requests through CrNet.
//
// |chromiumPrefix| is declared outside the scope of the request block so that
// the block references something outside of its own scope, and cannot be
// declared as a global block. This makes sure the block is
// an __NSStackBlock__, and verifies the fix for http://crbug.com/436175 .
NSString *chromiumPrefix = @"www.chromium.org";
[CrNet setRequestFilterBlock:^BOOL (NSURLRequest *request) {
BOOL isChromiumSite = [[[request URL] host] hasPrefix:chromiumPrefix];
return !isChromiumSite;
}];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController =
[[CrNetConsumerViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
[CrNet stopNetLog];
[CrNet clearCacheWithCompletionCallback:^(int error) {
NSLog(@"Cache cleared: %d\n", error);
}];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
_counter++;
[CrNet startNetLogToFile:[self currentNetLogFileName] logBytes:NO];
}
@end
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CRNET_CONSUMER_VIEW_CONTROLLER_
#define CRNET_CONSUMER_VIEW_CONTROLLER_
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface CrNetConsumerViewController : UIViewController
@end
#endif // CRNET_CONSUMER_VIEW_CONTROLLER_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "crnet_consumer_view_controller.h"
#import "CrNet.h"
@implementation CrNetConsumerViewController {
UIWebView* _webView;
}
- (void)viewDidLoad {
self.view.backgroundColor = [UIColor whiteColor];
UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem];
[button setTitle:@"chromium.org" forState:UIControlStateNormal];
[button setFrame:CGRectMake(5, 0, 95, 50)];
[button addTarget:self
action:@selector(loadChromium)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
_webView = [[UIWebView alloc]
initWithFrame:CGRectMake(0,
52,
self.view.bounds.size.width,
self.view.bounds.size.height - 52)];
[self.view addSubview:_webView];
_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
[self loadChromium];
}
// Disable the status bar to sidestep all the iOS7 status bar issues.
- (BOOL)prefersStatusBarHidden {
return YES;
}
- (void)loadChromium {
[_webView loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:@"https://www.chromium.org"]]];
}
@end
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "crnet_consumer_app_delegate.h"
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(
argc, argv, nil, NSStringFromClass([CrNetConsumerAppDelegate class]));
}
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CRNET_CRNET_ENVIRONMENT_H_
#define IOS_CRNET_CRNET_ENVIRONMENT_H_
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#import "ios/crnet/CrNet.h"
#include "ios/crnet/crnet_net_log.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
namespace net {
class HttpCache;
class NetworkChangeNotifier;
class ProxyConfigService;
class SdchManager;
class URLRequestContextGetter;
}
class CrNetHttpProtocolHandlerDelegate;
// CrNetEnvironment contains all the network stack configuration
// and initialization.
class CrNetEnvironment {
public:
// Must be called on the main thread.
static void Initialize();
// |user_agent_product_name| will be used to generate the user-agent.
CrNetEnvironment(std::string user_agent_product_name);
~CrNetEnvironment();
// Installs this CrNet environment so requests are intercepted.
// Can only be called once; to enable/disable CrNet at runtime, use
// SetHTTPProtocolHandlerRegistered.
void Install();
// Installs this CrNet environment into the supplied
// NSURLSessionConfiguration. Settings are inherited from the shared
// NSURLSessionConfiguration, which Install() affects.
void InstallIntoSessionConfiguration(NSURLSessionConfiguration* config);
// The full user-agent.
std::string user_agent();
// Returns the global request context getter for use in the network stack.
//
// The request context gathers all the settings needed to do an actual network
// request (cache type and path, cookies store, proxy setting ...).
// Chrome network stacks supports multiple active contexts, and this is used
// for example to separate Incognito data from the main profile data.
// CrNetEnvironment only implement one request context for now, but it can be
// extended in the future.
net::URLRequestContextGetter* GetMainContextGetter();
// Enables or disables the HTTP protocol handler.
//
// When the HTTP protocol handler is registered, it will be used for all the
// network requests the application does (including requests from UIWebView).
void SetHTTPProtocolHandlerRegistered(bool registered);
// Creates a new net log (overwrites existing file with this name). If
// actively logging, this call is ignored.
void StartNetLog(base::FilePath::StringType file_name, bool log_bytes);
// Stops logging and flushes file. If not currently logging this call is
// ignored.
void StopNetLog();
// Closes all existing SPDY sessions with ERR_ABORTED.
void CloseAllSpdySessions();
// Sets the block used to determine whether or not CrNet should handle the
// request. If this is not set, CrNet will handle all requests.
// Must not be called while requests are in progress.
void SetRequestFilterBlock(RequestFilterBlock block);
// Setters and getters for |spdy_enabled_|, |quic_enabled_|, and
// |forced_quic_origin_|. These only have any effect before Install() is
// called.
void set_spdy_enabled(bool enabled) { spdy_enabled_ = enabled; }
void set_quic_enabled(bool enabled) { quic_enabled_ = enabled; }
void set_alternate_protocol_threshold(double threshold) {
alternate_protocol_threshold_ = threshold;
}
bool spdy_enabled() const { return spdy_enabled_; }
bool quic_enabled() const { return quic_enabled_; }
double alternate_protocol_threshold() const {
return alternate_protocol_threshold_;
}
// Clears the network stack's disk cache.
void ClearCache(ClearCacheCallback callback);
private:
// Runs a closure on the network thread.
void PostToNetworkThread(const tracked_objects::Location& from_here,
const base::Closure& task);
// Performs initialization tasks that must happen on the network thread.
void InitializeOnNetworkThread();
// Runs a closure on the file user blocking thread.
void PostToFileUserBlockingThread(const tracked_objects::Location& from_here,
const base::Closure& task);
// Helper methods that start/stop net-internals logging on the file
// user blocking thread.
void StartNetLogInternal(base::FilePath::StringType file_name,
bool log_bytes);
void StopNetLogInternal();
// Returns the HttpNeteworkSession object from the passed in
// URLRequestContext or NULL if none exists.
net::HttpNetworkSession* GetHttpNetworkSession(
net::URLRequestContext* context);
// Helper method that closes all current SPDY sessions on the network IO
// thread.
void CloseAllSpdySessionsInternal();
bool spdy_enabled_;
bool quic_enabled_;
double alternate_protocol_threshold_;
// Helper method that clears the cache on the network thread.
void ClearCacheOnNetworkThread(ClearCacheCallback callback);
static CrNetEnvironment* chrome_net_;
scoped_ptr<base::Thread> network_io_thread_;
scoped_ptr<base::Thread> network_cache_thread_;
scoped_ptr<base::Thread> file_thread_;
scoped_ptr<base::Thread> file_user_blocking_thread_;
scoped_ptr<net::SdchManager> sdch_manager_;
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::HttpServerProperties> http_server_properties_;
scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
scoped_ptr<net::URLRequestContext> main_context_;
scoped_ptr<CrNetHttpProtocolHandlerDelegate> http_protocol_handler_delegate_;
std::string user_agent_product_name_;
base::Lock net_log_lock_;
bool net_log_started_;
scoped_ptr<CrNetNetLog> net_log_;
DISALLOW_COPY_AND_ASSIGN(CrNetEnvironment);
};
#endif // IOS_CRNET_CRNET_ENVIRONMENT_H_
This diff is collapsed.
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/crnet/crnet_net_log.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/values.h"
#include "net/log/net_log.h"
#include "net/log/net_log_util.h"
#include "net/log/write_to_file_net_log_observer.h"
CrNetNetLog::CrNetNetLog() { }
CrNetNetLog::~CrNetNetLog() { }
bool CrNetNetLog::Start(const base::FilePath& log_file,
CrNetNetLog::Mode mode) {
DCHECK(thread_checker_.CalledOnValidThread());
base::FilePath temp_dir;
if (!base::GetTempDir(&temp_dir))
return false;
base::FilePath full_path = temp_dir.Append(log_file);
base::ScopedFILE file(base::OpenFile(full_path, "w"));
if (!file)
return false;
scoped_ptr<base::Value> constants(net::GetNetConstants().Pass());
net::NetLogCaptureMode capture_mode = mode == LOG_ALL_BYTES ?
net::NetLogCaptureMode::IncludeSocketBytes() :
net::NetLogCaptureMode::Default();
write_to_file_observer_.reset(new net::WriteToFileNetLogObserver());
write_to_file_observer_->set_capture_mode(capture_mode);
write_to_file_observer_->StartObserving(this, file.Pass(), constants.get(),
nullptr);
return true;
}
void CrNetNetLog::Stop() {
DCHECK(thread_checker_.CalledOnValidThread());
write_to_file_observer_->StopObserving(nullptr);
write_to_file_observer_.reset();
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CRNET_CRNET_NET_LOG_H_
#define IOS_CRNET_CRNET_NET_LOG_H_
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "net/log/net_log.h"
namespace base {
class FilePath;
class DictionaryValue;
}
namespace net {
class WriteToFileNetLogObserver;
}
// CrNet-specific NetLog subclass.
// This class can be used as a NetLog where needed; it logs all log entries to
// the file specified in Start().
class CrNetNetLog : public net::NetLog {
public:
enum Mode {
LOG_ALL_BYTES,
LOG_STRIP_PRIVATE_DATA,
};
CrNetNetLog();
~CrNetNetLog() override;
// Starts logging to the file named |log_file|. If |mode| is LOG_ALL_BYTES,
// logs all network traffic, including raw bytes. If |mode| is
// LOG_STRIP_PRIVATE_DATA, strips cookies and other private data, and does
// not log raw bytes.
bool Start(const base::FilePath& log_file, Mode mode);
// Stops logging.
void Stop();
private:
// Underlying file writer. This observer observes NetLog events and writes
// them back to the file this class is logging to.
scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_;
base::ThreadChecker thread_checker_;
};
#endif // IOS_CRNET_CRNET_NET_LOG_H
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'targets': [],
'conditions': [
# Our shared library hack only works with ninja; xcode cannot generate
# iOS build targets for dynamic libraries. More details below.
['"<(GENERATOR)"=="ninja"', {
'targets': [
{
'target_name': 'crnet_dummy',
'type': 'executable',
'mac_bundle': 1,
'dependencies': [
'../../ios/crnet/crnet.gyp:crnet',
],
'sources': [
'../../ios/build/packaging/dummy_main.mm',
],
'include_dirs': [
'../..',
],
'xcode_settings': {
'INFOPLIST_FILE': '../../ios/build/packaging/dummy-Info.plist',
},
},
{
# Build this target to package a standalone CrNet in a single
# .a file.
'target_name': 'crnet_pack',
'type': 'none',
'dependencies': [
# Depend on the dummy target so that all of CrNet's dependencies
# are built before packaging.
'crnet_dummy',
],
'actions': [
{
'action_name': 'Package CrNet',
'variables': {
'tool_path':
'../../ios/build/packaging/link_dependencies.py',
},
# Actions need an inputs list, even if it's empty.
'inputs': [],
# Only specify one output, since this will be libtool's output.
'outputs': [ '<(PRODUCT_DIR)/libcrnet_standalone.a' ],
'action': ['<(tool_path)',
'<(PRODUCT_DIR)',
'crnet_dummy.app/crnet_dummy',
'<@(_outputs)',
],
},
],
},
],
}],
],
}
......@@ -11,6 +11,9 @@
'type': 'none',
'dependencies': [
'chrome/ios_chrome_tests.gyp:*',
'crnet/crnet.gyp:*',
'crnet/crnet_pack.gyp:*',
'crnet/crnet_consumer/crnet_consumer.gyp:*',
'net/ios_net.gyp:*',
'net/ios_net_unittests.gyp:*',
'provider/ios_provider_chrome.gyp:*',
......
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