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

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. Same origin = true for media streams. 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #endif 141 #endif
142 } 142 }
143 143
144 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { 144 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) {
145 load(url, NULL, cors_mode); 145 load(url, NULL, cors_mode);
146 } 146 }
147 147
148 void WebMediaPlayerAndroid::load(const WebURL& url, 148 void WebMediaPlayerAndroid::load(const WebURL& url,
149 WebMediaSource* media_source, 149 WebMediaSource* media_source,
150 CORSMode cors_mode) { 150 CORSMode cors_mode) {
151 if (cors_mode != CORSModeUnspecified)
152 NOTIMPLEMENTED() << "No CORS support";
153
154 MediaPlayerAndroid::SourceType source_type = 151 MediaPlayerAndroid::SourceType source_type =
155 MediaPlayerAndroid::SOURCE_TYPE_URL; 152 MediaPlayerAndroid::SOURCE_TYPE_URL;
153 url_ = url;
156 154
157 if (media_source) 155 if (media_source)
158 source_type = MediaPlayerAndroid::SOURCE_TYPE_MSE; 156 source_type = MediaPlayerAndroid::SOURCE_TYPE_MSE;
159 #if defined(GOOGLE_TV) 157 #if defined(GOOGLE_TV)
160 if (media_stream_client_) { 158 if (media_stream_client_) {
161 DCHECK(!media_source); 159 DCHECK(!media_source);
162 source_type = MediaPlayerAndroid::SOURCE_TYPE_STREAM; 160 source_type = MediaPlayerAndroid::SOURCE_TYPE_STREAM;
163 } 161 }
164 #endif 162 #endif
165 163
(...skipping 12 matching lines...) Expand all
178 if (source_type == MediaPlayerAndroid::SOURCE_TYPE_STREAM) { 176 if (source_type == MediaPlayerAndroid::SOURCE_TYPE_STREAM) {
179 media_source_delegate_->InitializeMediaStream( 177 media_source_delegate_->InitializeMediaStream(
180 demuxer_, 178 demuxer_,
181 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, 179 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState,
182 base::Unretained(this))); 180 base::Unretained(this)));
183 audio_renderer_ = media_stream_client_->GetAudioRenderer(url); 181 audio_renderer_ = media_stream_client_->GetAudioRenderer(url);
184 if (audio_renderer_) 182 if (audio_renderer_)
185 audio_renderer_->Start(); 183 audio_renderer_->Start();
186 } 184 }
187 #endif 185 #endif
186 InitializeMediaPlayer(source_type);
187 } else {
188 info_loader_.reset(
189 new MediaInfoLoaderAndroid(
190 url_,
191 cors_mode,
192 base::Bind(&WebMediaPlayerAndroid::DidLoadMediaInfo,
193 base::Unretained(this))));
194 info_loader_->Start(frame_);
188 } 195 }
189
190 InitializeMediaPlayer(url, source_type);
191 }
192
193 void WebMediaPlayerAndroid::InitializeMediaPlayer(
194 const WebURL& url,
195 MediaPlayerAndroid::SourceType source_type) {
196 url_ = url;
197 GURL first_party_url = frame_->document().firstPartyForCookies();
198 if (proxy_) {
199 proxy_->Initialize(player_id_, url, source_type, first_party_url);
200 if (manager_->IsInFullscreen(frame_))
201 proxy_->EnterFullscreen(player_id_);
202 }
203
204 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); 196 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading);
205 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); 197 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing);
206 } 198 }
207 199
200 void WebMediaPlayerAndroid::DidLoadMediaInfo(
201 MediaInfoLoaderAndroid::Status status) {
202 DCHECK(!media_source_delegate_);
203 if (status == MediaInfoLoaderAndroid::kFailed) {
204 info_loader_.reset();
acolwell GONE FROM CHROMIUM 2013/06/10 19:17:32 I think you need to add something like UpdateNetwo
Sami 2013/06/11 13:51:25 Well spotted, thanks. Done.
205 return;
206 }
207
208 InitializeMediaPlayer(MediaPlayerAndroid::SOURCE_TYPE_URL);
209 }
210
211 void WebMediaPlayerAndroid::InitializeMediaPlayer(
212 MediaPlayerAndroid::SourceType source_type) {
213 GURL first_party_url = frame_->document().firstPartyForCookies();
214 if (proxy_) {
215 proxy_->Initialize(player_id_, url_, source_type, first_party_url);
216 if (manager_->IsInFullscreen(frame_))
217 proxy_->EnterFullscreen(player_id_);
218 }
219 }
220
208 void WebMediaPlayerAndroid::cancelLoad() { 221 void WebMediaPlayerAndroid::cancelLoad() {
acolwell GONE FROM CHROMIUM 2013/06/10 19:17:32 nit: Please remove. This method is never called.
Sami 2013/06/11 13:51:25 Done.
209 NOTIMPLEMENTED(); 222 info_loader_.reset();
210 } 223 }
211 224
212 void WebMediaPlayerAndroid::play() { 225 void WebMediaPlayerAndroid::play() {
213 #if defined(GOOGLE_TV) 226 #if defined(GOOGLE_TV)
214 if (hasVideo() && needs_external_surface_) { 227 if (hasVideo() && needs_external_surface_) {
215 DCHECK(!needs_establish_peer_); 228 DCHECK(!needs_establish_peer_);
216 if (proxy_) 229 if (proxy_)
217 proxy_->RequestExternalSurface(player_id_, last_computed_rect_); 230 proxy_->RequestExternalSurface(player_id_, last_computed_rect_);
218 } 231 }
219 if (audio_renderer_ && paused()) 232 if (audio_renderer_ && paused())
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, 412 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_,
400 texture, level, internal_format, 413 texture, level, internal_format,
401 type); 414 type);
402 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); 415 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false);
403 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 416 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
404 false); 417 false);
405 return true; 418 return true;
406 } 419 }
407 420
408 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { 421 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const {
409 // TODO(qinmin): fix this for urls that are not file. 422 if (info_loader_)
410 // https://code.google.com/p/chromium/issues/detail?id=234710 423 return info_loader_->HasSingleOrigin();
411 if (url_.SchemeIsFile()) 424 return true;
412 return true; 425 }
426
427 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const {
428 if (info_loader_)
429 return info_loader_->DidPassCORSAccessCheck();
413 return false; 430 return false;
414 } 431 }
415 432
416 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const {
417 return false;
418 }
419
420 WebMediaPlayer::MovieLoadType WebMediaPlayerAndroid::movieLoadType() const { 433 WebMediaPlayer::MovieLoadType WebMediaPlayerAndroid::movieLoadType() const {
421 // Deprecated. 434 // Deprecated.
422 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. 435 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used.
423 return WebMediaPlayer::MovieLoadTypeUnknown; 436 return WebMediaPlayer::MovieLoadTypeUnknown;
424 } 437 }
425 438
426 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { 439 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const {
427 return ConvertSecondsToTimestamp(timeValue).InSecondsF(); 440 return ConvertSecondsToTimestamp(timeValue).InSecondsF();
428 } 441 }
429 442
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 void WebMediaPlayerAndroid::exitFullscreen() { 1081 void WebMediaPlayerAndroid::exitFullscreen() {
1069 if (proxy_) 1082 if (proxy_)
1070 proxy_->ExitFullscreen(player_id_); 1083 proxy_->ExitFullscreen(player_id_);
1071 } 1084 }
1072 1085
1073 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1086 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1074 return manager_->CanEnterFullscreen(frame_); 1087 return manager_->CanEnterFullscreen(frame_);
1075 } 1088 }
1076 1089
1077 } // namespace webkit_media 1090 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698