Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 main_loop_->RemoveDestructionObserver(this); | 116 main_loop_->RemoveDestructionObserver(this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { | 119 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { |
| 120 load(url, NULL, cors_mode); | 120 load(url, NULL, cors_mode); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void WebMediaPlayerAndroid::load(const WebURL& url, | 123 void WebMediaPlayerAndroid::load(const WebURL& url, |
| 124 WebMediaSource* media_source, | 124 WebMediaSource* media_source, |
| 125 CORSMode cors_mode) { | 125 CORSMode cors_mode) { |
| 126 if (cors_mode != CORSModeUnspecified) | 126 url_ = url; |
| 127 NOTIMPLEMENTED() << "No CORS support"; | |
| 128 | 127 |
| 129 if (media_source) { | 128 if (media_source) { |
| 130 media_source_delegate_.reset( | 129 media_source_delegate_.reset( |
| 131 new MediaSourceDelegate(proxy_, player_id_, media_log_)); | 130 new MediaSourceDelegate(proxy_, player_id_, media_log_)); |
| 132 // |media_source_delegate_| is owned, so Unretained() is safe here. | 131 // |media_source_delegate_| is owned, so Unretained() is safe here. |
| 133 media_source_delegate_->Initialize( | 132 media_source_delegate_->Initialize( |
| 134 media_source, | 133 media_source, |
| 135 base::Bind(&WebMediaPlayerAndroid::OnNeedKey, base::Unretained(this)), | 134 base::Bind(&WebMediaPlayerAndroid::OnNeedKey, base::Unretained(this)), |
| 136 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, | 135 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, |
| 137 base::Unretained(this))); | 136 base::Unretained(this))); |
| 138 } | 137 InitializeProxy(true); |
| 139 | 138 } else { |
| 140 url_ = url; | 139 info_loader_.reset( |
| 141 GURL first_party_url = frame_->document().firstPartyForCookies(); | 140 new MediaInfoLoaderAndroid( |
| 142 if (proxy_) { | 141 url_, |
| 143 proxy_->Initialize(player_id_, url_, media_source != NULL, first_party_url); | 142 cors_mode, |
| 144 if (manager_->IsInFullscreen(frame_)) | 143 base::Bind(&WebMediaPlayerAndroid::DidLoadMediaInfo, |
| 145 proxy_->EnterFullscreen(player_id_); | 144 base::Unretained(this)))); |
| 145 info_loader_->Start(frame_); | |
| 146 } | 146 } |
| 147 | 147 |
| 148 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); | 148 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 149 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 149 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void WebMediaPlayerAndroid::DidLoadMediaInfo( | |
| 153 MediaInfoLoaderAndroid::Status status) { | |
| 154 DCHECK(!media_source_delegate_); | |
| 155 if (status == MediaInfoLoaderAndroid::kFailed) { | |
| 156 info_loader_.reset(); | |
| 157 return; | |
| 158 } | |
| 159 | |
| 160 InitializeProxy(false); | |
| 161 } | |
| 162 | |
| 163 void WebMediaPlayerAndroid::InitializeProxy(bool is_media_source) { | |
| 164 GURL first_party_url = frame_->document().firstPartyForCookies(); | |
| 165 if (proxy_) { | |
| 166 proxy_->Initialize(player_id_, url_, is_media_source, first_party_url); | |
| 167 if (manager_->IsInFullscreen(frame_)) | |
| 168 proxy_->EnterFullscreen(player_id_); | |
| 169 } | |
| 170 } | |
| 171 | |
| 152 void WebMediaPlayerAndroid::cancelLoad() { | 172 void WebMediaPlayerAndroid::cancelLoad() { |
| 153 NOTIMPLEMENTED(); | 173 info_loader_.reset(); |
| 154 } | 174 } |
| 155 | 175 |
| 156 void WebMediaPlayerAndroid::play() { | 176 void WebMediaPlayerAndroid::play() { |
| 157 #if defined(GOOGLE_TV) | 177 #if defined(GOOGLE_TV) |
| 158 if (hasVideo() && needs_external_surface_) { | 178 if (hasVideo() && needs_external_surface_) { |
| 159 DCHECK(!needs_establish_peer_); | 179 DCHECK(!needs_establish_peer_); |
| 160 if (proxy_) | 180 if (proxy_) |
| 161 proxy_->RequestExternalSurface(player_id_, last_computed_rect_); | 181 proxy_->RequestExternalSurface(player_id_, last_computed_rect_); |
| 162 } | 182 } |
| 163 #endif | 183 #endif |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, | 357 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, |
| 338 texture, level, internal_format, | 358 texture, level, internal_format, |
| 339 type); | 359 type); |
| 340 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 360 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
| 341 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 361 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 342 false); | 362 false); |
| 343 return true; | 363 return true; |
| 344 } | 364 } |
| 345 | 365 |
| 346 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { | 366 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { |
| 347 // TODO(qinmin): fix this for urls that are not file. | 367 if (info_loader_) |
| 348 // https://code.google.com/p/chromium/issues/detail?id=234710 | 368 return info_loader_->HasSingleOrigin(); |
| 349 if (url_.SchemeIsFile()) | |
| 350 return true; | |
| 351 return false; | 369 return false; |
|
Ken Russell (switch to Gerrit)
2013/06/05 18:33:50
Should this return true? WebMediaPlayerImpl::hasSi
Sami
2013/06/06 12:29:48
This path is reached when we're playing from a med
| |
| 352 } | 370 } |
| 353 | 371 |
| 354 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const { | 372 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const { |
| 373 if (info_loader_) | |
| 374 return info_loader_->DidPassCORSAccessCheck(); | |
| 355 return false; | 375 return false; |
| 356 } | 376 } |
| 357 | 377 |
| 358 WebMediaPlayer::MovieLoadType WebMediaPlayerAndroid::movieLoadType() const { | 378 WebMediaPlayer::MovieLoadType WebMediaPlayerAndroid::movieLoadType() const { |
| 359 // Deprecated. | 379 // Deprecated. |
| 360 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. | 380 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. |
| 361 return WebMediaPlayer::MovieLoadTypeUnknown; | 381 return WebMediaPlayer::MovieLoadTypeUnknown; |
| 362 } | 382 } |
| 363 | 383 |
| 364 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { | 384 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 void WebMediaPlayerAndroid::exitFullscreen() { | 980 void WebMediaPlayerAndroid::exitFullscreen() { |
| 961 if (proxy_) | 981 if (proxy_) |
| 962 proxy_->ExitFullscreen(player_id_); | 982 proxy_->ExitFullscreen(player_id_); |
| 963 } | 983 } |
| 964 | 984 |
| 965 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 985 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 966 return manager_->CanEnterFullscreen(frame_); | 986 return manager_->CanEnterFullscreen(frame_); |
| 967 } | 987 } |
| 968 | 988 |
| 969 } // namespace webkit_media | 989 } // namespace webkit_media |
| OLD | NEW |