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

Side by Side Diff: media/base/android/java/src/org/chromium/media/MediaPlayerBridge.java

Issue 130363002: Pass Chrome user agent string to Android media player (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 6 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.media; 5 package org.chromium.media;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.media.MediaPlayer; 8 import android.media.MediaPlayer;
9 import android.net.Uri; 9 import android.net.Uri;
10 import android.os.AsyncTask; 10 import android.os.AsyncTask;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 getLocalPlayer().pause(); 130 getLocalPlayer().pause();
131 } 131 }
132 132
133 @CalledByNative 133 @CalledByNative
134 protected void seekTo(int msec) throws IllegalStateException { 134 protected void seekTo(int msec) throws IllegalStateException {
135 getLocalPlayer().seekTo(msec); 135 getLocalPlayer().seekTo(msec);
136 } 136 }
137 137
138 @CalledByNative 138 @CalledByNative
139 protected boolean setDataSource( 139 protected boolean setDataSource(
140 Context context, String url, String cookies, boolean hideUrlLog) { 140 Context context, String url, String cookies, String userAgent, boole an hideUrlLog) {
141 Uri uri = Uri.parse(url); 141 Uri uri = Uri.parse(url);
142 HashMap<String, String> headersMap = new HashMap<String, String>(); 142 HashMap<String, String> headersMap = new HashMap<String, String>();
143 if (hideUrlLog) headersMap.put("x-hide-urls-from-log", "true"); 143 if (hideUrlLog) headersMap.put("x-hide-urls-from-log", "true");
144 if (!TextUtils.isEmpty(cookies)) headersMap.put("Cookie", cookies); 144 if (!TextUtils.isEmpty(cookies)) headersMap.put("Cookie", cookies);
145 if (!TextUtils.isEmpty(userAgent)) headersMap.put("User-Agent", userAgen t);
145 try { 146 try {
146 getLocalPlayer().setDataSource(context, uri, headersMap); 147 getLocalPlayer().setDataSource(context, uri, headersMap);
147 return true; 148 return true;
148 } catch (Exception e) { 149 } catch (Exception e) {
149 return false; 150 return false;
150 } 151 }
151 } 152 }
152 153
153 @CalledByNative 154 @CalledByNative
154 protected boolean setDataUriDataSource(final Context context, final String u rl) { 155 protected boolean setDataUriDataSource(final Context context, final String u rl) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 Log.e(TAG, "Cannot access metadata: " + e); 326 Log.e(TAG, "Cannot access metadata: " + e);
326 } catch (NoSuchFieldException e) { 327 } catch (NoSuchFieldException e) {
327 Log.e(TAG, "Cannot find matching fields in Metadata class: " + e); 328 Log.e(TAG, "Cannot find matching fields in Metadata class: " + e);
328 } 329 }
329 return new AllowedOperations(canPause, canSeekForward, canSeekBackward); 330 return new AllowedOperations(canPause, canSeekForward, canSeekBackward);
330 } 331 }
331 332
332 private native void nativeOnDidSetDataUriDataSource(long nativeMediaPlayerBr idge, 333 private native void nativeOnDidSetDataUriDataSource(long nativeMediaPlayerBr idge,
333 boolean success); 334 boolean success);
334 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698