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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/ChromiumUrlRequestFactory.java

Issue 997623002: [Cronet] Respect user agent string from config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/cronet/android/test/javatests/src/org/chromium/net/HttpUrlRequestFactoryTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
9 9
10 import org.chromium.base.UsedByReflection; 10 import org.chromium.base.UsedByReflection;
11 11
12 import java.nio.channels.WritableByteChannel; 12 import java.nio.channels.WritableByteChannel;
13 import java.util.Map; 13 import java.util.Map;
14 14
15 /** 15 /**
16 * Network request factory using the native http stack implementation. 16 * Network request factory using the native http stack implementation.
17 */ 17 */
18 @UsedByReflection("HttpUrlRequestFactory.java") 18 @UsedByReflection("HttpUrlRequestFactory.java")
19 public class ChromiumUrlRequestFactory extends HttpUrlRequestFactory { 19 public class ChromiumUrlRequestFactory extends HttpUrlRequestFactory {
20 private ChromiumUrlRequestContext mRequestContext; 20 private ChromiumUrlRequestContext mRequestContext;
21 21
22 @UsedByReflection("HttpUrlRequestFactory.java") 22 @UsedByReflection("HttpUrlRequestFactory.java")
23 public ChromiumUrlRequestFactory( 23 public ChromiumUrlRequestFactory(
24 Context context, UrlRequestContextConfig config) { 24 Context context, UrlRequestContextConfig config) {
25 if (isEnabled()) { 25 if (isEnabled()) {
26 mRequestContext = 26 String userAgent = config.userAgent();
27 new ChromiumUrlRequestContext(context, UserAgent.from(contex t), config); 27 if (!userAgent.isEmpty()) {
mef 2015/03/16 15:39:55 Suggest changing to: if (userAgent.isEmpty())
xunjieli 2015/03/16 15:45:56 Done.
28 mRequestContext = new ChromiumUrlRequestContext(context,
29 userAgent, config);
30 } else {
31 mRequestContext = new ChromiumUrlRequestContext(context,
32 UserAgent.from(context), config);
33 }
28 } 34 }
29 } 35 }
30 36
31 @Override 37 @Override
32 public boolean isEnabled() { 38 public boolean isEnabled() {
33 return Build.VERSION.SDK_INT >= 14; 39 return Build.VERSION.SDK_INT >= 14;
34 } 40 }
35 41
36 @Override 42 @Override
37 public String getName() { 43 public String getName() {
(...skipping 22 matching lines...) Expand all
60 66
61 @Override 67 @Override
62 public void stopNetLog() { 68 public void stopNetLog() {
63 mRequestContext.stopNetLog(); 69 mRequestContext.stopNetLog();
64 } 70 }
65 71
66 public ChromiumUrlRequestContext getRequestContext() { 72 public ChromiumUrlRequestContext getRequestContext() {
67 return mRequestContext; 73 return mRequestContext;
68 } 74 }
69 } 75 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/test/javatests/src/org/chromium/net/HttpUrlRequestFactoryTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698