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

Side by Side Diff: webkit/renderer/media/android/webmediaplayer_android.cc

Issue 16327002: android: Implement single origin and CORS check for video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again. Created 7 years, 6 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 | Annotate | Revision Log
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 #include "webkit/renderer/media/android/webmediaplayer_android.h" 5 #include "webkit/renderer/media/android/webmediaplayer_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 #endif 143 #endif
144 } 144 }
145 145
146 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { 146 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) {
147 load(url, NULL, cors_mode); 147 load(url, NULL, cors_mode);
148 } 148 }
149 149
150 void WebMediaPlayerAndroid::load(const WebURL& url, 150 void WebMediaPlayerAndroid::load(const WebURL& url,
151 WebMediaSource* media_source, 151 WebMediaSource* media_source,
152 CORSMode cors_mode) { 152 CORSMode cors_mode) {
153 if (cors_mode != CORSModeUnspecified)
154 NOTIMPLEMENTED() << "No CORS support";
155
156 MediaPlayerAndroid::SourceType source_type = 153 MediaPlayerAndroid::SourceType source_type =
157 MediaPlayerAndroid::SOURCE_TYPE_URL; 154 MediaPlayerAndroid::SOURCE_TYPE_URL;
155 url_ = url;
158 156
159 if (media_source) 157 if (media_source)
160 source_type = MediaPlayerAndroid::SOURCE_TYPE_MSE; 158 source_type = MediaPlayerAndroid::SOURCE_TYPE_MSE;
161 #if defined(GOOGLE_TV) 159 #if defined(GOOGLE_TV)
162 if (media_stream_client_) { 160 if (media_stream_client_) {
163 DCHECK(!media_source); 161 DCHECK(!media_source);
164 source_type = MediaPlayerAndroid::SOURCE_TYPE_STREAM; 162 source_type = MediaPlayerAndroid::SOURCE_TYPE_STREAM;
165 } 163 }
166 #endif 164 #endif
167 165
(...skipping 12 matching lines...) Expand all
180 if (source_type == MediaPlayerAndroid::SOURCE_TYPE_STREAM) { 178 if (source_type == MediaPlayerAndroid::SOURCE_TYPE_STREAM) {
181 media_source_delegate_->InitializeMediaStream( 179 media_source_delegate_->InitializeMediaStream(
182 demuxer_, 180 demuxer_,
183 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, 181 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState,
184 base::Unretained(this))); 182 base::Unretained(this)));
185 audio_renderer_ = media_stream_client_->GetAudioRenderer(url); 183 audio_renderer_ = media_stream_client_->GetAudioRenderer(url);
186 if (audio_renderer_) 184 if (audio_renderer_)
187 audio_renderer_->Start(); 185 audio_renderer_->Start();
188 } 186 }
189 #endif 187 #endif
188 InitializeMediaPlayer(source_type);
189 } else {
190 info_loader_.reset(
191 new MediaInfoLoaderAndroid(
192 url_,
193 cors_mode,
194 base::Bind(&WebMediaPlayerAndroid::DidLoadMediaInfo,
195 base::Unretained(this))));
196 info_loader_->Start(frame_);
190 } 197 }
191
192 InitializeMediaPlayer(url, source_type);
193 }
194
195 void WebMediaPlayerAndroid::InitializeMediaPlayer(
196 const WebURL& url,
197 MediaPlayerAndroid::SourceType source_type) {
198 url_ = url;
199 GURL first_party_url = frame_->document().firstPartyForCookies();
200 proxy_->Initialize(player_id_, url, source_type, first_party_url);
201 if (manager_->IsInFullscreen(frame_))
202 proxy_->EnterFullscreen(player_id_);
203
204 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); 198 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading);
205 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); 199 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing);
206 } 200 }
207 201
202 void WebMediaPlayerAndroid::DidLoadMediaInfo(
203 MediaInfoLoaderAndroid::Status status) {
204 DCHECK(!media_source_delegate_);
205 if (status == MediaInfoLoaderAndroid::kFailed) {
206 info_loader_.reset();
207 return;
208 }
209
210 InitializeMediaPlayer(MediaPlayerAndroid::SOURCE_TYPE_URL);
211 }
212
213 void WebMediaPlayerAndroid::InitializeMediaPlayer(
214 MediaPlayerAndroid::SourceType source_type) {
215 GURL first_party_url = frame_->document().firstPartyForCookies();
216 if (proxy_) {
217 proxy_->Initialize(player_id_, url_, source_type, first_party_url);
218 if (manager_->IsInFullscreen(frame_))
219 proxy_->EnterFullscreen(player_id_);
220 }
221 }
222
208 void WebMediaPlayerAndroid::play() { 223 void WebMediaPlayerAndroid::play() {
209 #if defined(GOOGLE_TV) 224 #if defined(GOOGLE_TV)
210 if (hasVideo() && needs_external_surface_) { 225 if (hasVideo() && needs_external_surface_) {
211 DCHECK(!needs_establish_peer_); 226 DCHECK(!needs_establish_peer_);
212 proxy_->RequestExternalSurface(player_id_, last_computed_rect_); 227 proxy_->RequestExternalSurface(player_id_, last_computed_rect_);
213 } 228 }
214 if (audio_renderer_ && paused()) 229 if (audio_renderer_ && paused())
215 audio_renderer_->Play(); 230 audio_renderer_->Play();
216 #endif 231 #endif
217 if (hasVideo() && needs_establish_peer_) 232 if (hasVideo() && needs_establish_peer_)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, 382 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_,
368 texture, level, internal_format, 383 texture, level, internal_format,
369 type); 384 type);
370 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); 385 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
371 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 386 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
372 false); 387 false);
373 return true; 388 return true;
374 } 389 }
375 390
376 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { 391 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const {
377 // TODO(qinmin): fix this for urls that are not file. 392 if (info_loader_)
378 // https://code.google.com/p/chromium/issues/detail?id=234710 393 return info_loader_->HasSingleOrigin();
379 if (url_.SchemeIsFile()) 394 return true;
380 return true; 395 }
396
397 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const {
398 if (info_loader_)
399 return info_loader_->DidPassCORSAccessCheck();
381 return false; 400 return false;
382 } 401 }
383 402
384 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const {
385 return false;
386 }
387
388 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { 403 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const {
389 return ConvertSecondsToTimestamp(timeValue).InSecondsF(); 404 return ConvertSecondsToTimestamp(timeValue).InSecondsF();
390 } 405 }
391 406
392 unsigned WebMediaPlayerAndroid::decodedFrameCount() const { 407 unsigned WebMediaPlayerAndroid::decodedFrameCount() const {
393 if (media_source_delegate_) 408 if (media_source_delegate_)
394 return media_source_delegate_->DecodedFrameCount(); 409 return media_source_delegate_->DecodedFrameCount();
395 NOTIMPLEMENTED(); 410 NOTIMPLEMENTED();
396 return 0; 411 return 0;
397 } 412 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1040
1026 void WebMediaPlayerAndroid::exitFullscreen() { 1041 void WebMediaPlayerAndroid::exitFullscreen() {
1027 proxy_->ExitFullscreen(player_id_); 1042 proxy_->ExitFullscreen(player_id_);
1028 } 1043 }
1029 1044
1030 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1045 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1031 return manager_->CanEnterFullscreen(frame_); 1046 return manager_->CanEnterFullscreen(frame_);
1032 } 1047 }
1033 1048
1034 } // namespace webkit_media 1049 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698