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 "content/browser/media/android/browser_media_player_manager.h" | 5 #include "content/browser/media/android/browser_media_player_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 | 207 |
| 208 if (media_player_params.type == MEDIA_PLAYER_TYPE_REMOTE_ONLY) | 208 if (media_player_params.type == MEDIA_PLAYER_TYPE_REMOTE_ONLY) |
| 209 return media_player_bridge; | 209 return media_player_bridge; |
| 210 | 210 |
| 211 bool should_block = false; | 211 bool should_block = false; |
| 212 bool extract_metadata = | 212 bool extract_metadata = |
| 213 // Initialize the player will cause MediaMetadataExtractor to decode | 213 // Initialize the player will cause MediaMetadataExtractor to decode |
| 214 // small chunks of data. | 214 // small chunks of data. |
| 215 RequestDecoderResources(media_player_params.player_id, true); | 215 RequestDecoderResources(media_player_params.player_id, true); |
| 216 #if !defined(USE_AURA) | 216 #if !defined(USE_AURA) |
| 217 ContentViewCoreImpl* content_view_core_impl = | 217 if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) |
|
boliu
2016/09/26 21:25:25
style: need braces if the body is more than one li
Jinsuk Kim
2016/09/27 10:08:59
Done.
| |
| 218 static_cast<ContentViewCoreImpl*>( | 218 should_block = |
| 219 ContentViewCore::FromWebContents(web_contents_)); | 219 delegate->ShouldBlockMediaRequest(media_player_params.url); |
| 220 if (!content_view_core_impl) { | 220 else |
| 221 extract_metadata = false; | 221 extract_metadata = false; |
| 222 } else { | |
| 223 should_block = content_view_core_impl->ShouldBlockMediaRequest( | |
| 224 media_player_params.url); | |
| 225 } | |
| 226 #endif | 222 #endif |
| 227 if (!extract_metadata) { | 223 if (!extract_metadata) { |
| 228 // May reach here due to prerendering or throttling. Don't extract the | 224 // May reach here due to prerendering or throttling. Don't extract the |
| 229 // metadata since it is expensive. | 225 // metadata since it is expensive. |
| 230 // TODO(qinmin): extract the metadata once the user decided to load | 226 // TODO(qinmin): extract the metadata once the user decided to load |
| 231 // the page. | 227 // the page. |
| 232 OnMediaMetadataChanged(media_player_params.player_id, base::TimeDelta(), | 228 OnMediaMetadataChanged(media_player_params.player_id, base::TimeDelta(), |
| 233 0, 0, false); | 229 0, 0, false); |
| 234 } else if (!should_block) { | 230 } else if (!should_block) { |
| 235 media_player_bridge->Initialize(); | 231 media_player_bridge->Initialize(); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 | 444 |
| 449 // There's no ContentVideoView instance so create one. | 445 // There's no ContentVideoView instance so create one. |
| 450 // If we know the video frame size, use it. | 446 // If we know the video frame size, use it. |
| 451 gfx::Size natural_video_size; | 447 gfx::Size natural_video_size; |
| 452 MediaPlayerAndroid* player = GetFullscreenPlayer(); | 448 MediaPlayerAndroid* player = GetFullscreenPlayer(); |
| 453 if (player && player->IsPlayerReady()) { | 449 if (player && player->IsPlayerReady()) { |
| 454 natural_video_size = | 450 natural_video_size = |
| 455 gfx::Size(player->GetVideoWidth(), player->GetVideoHeight()); | 451 gfx::Size(player->GetVideoWidth(), player->GetVideoHeight()); |
| 456 } | 452 } |
| 457 | 453 |
| 454 base::android::ScopedJavaLocalRef<jobject> embedder( | |
| 455 web_contents()->GetDelegate()->GetContentVideoViewEmbedder()); | |
|
boliu
2016/09/26 21:25:25
null check GetDelegate
Jinsuk Kim
2016/09/27 10:08:58
Done.
| |
| 458 video_view_.reset( | 456 video_view_.reset( |
| 459 new ContentVideoView(this, GetContentViewCore(), natural_video_size)); | 457 new ContentVideoView(this, |
| 458 GetContentViewCore(), | |
| 459 embedder, | |
| 460 natural_video_size)); | |
| 460 | 461 |
| 461 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = | 462 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = |
| 462 video_view_->GetJavaObject(base::android::AttachCurrentThread()); | 463 video_view_->GetJavaObject(base::android::AttachCurrentThread()); |
| 463 if (!j_content_video_view.is_null()) { | 464 if (!j_content_video_view.is_null()) { |
| 464 fullscreen_player_id_ = player_id; | 465 fullscreen_player_id_ = player_id; |
| 465 } else { | 466 } else { |
| 466 Send(new MediaPlayerMsg_DidExitFullscreen(RoutingID(), player_id)); | 467 Send(new MediaPlayerMsg_DidExitFullscreen(RoutingID(), player_id)); |
| 467 video_view_.reset(); | 468 video_view_.reset(); |
| 468 } | 469 } |
| 469 #endif // defined(USE_AURA) | 470 #endif // defined(USE_AURA) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 if (!player) | 681 if (!player) |
| 681 return; | 682 return; |
| 682 player->Start(); | 683 player->Start(); |
| 683 if (fullscreen_player_id_ == player_id && fullscreen_player_is_released_) { | 684 if (fullscreen_player_id_ == player_id && fullscreen_player_is_released_) { |
| 684 video_view_->OpenVideo(); | 685 video_view_->OpenVideo(); |
| 685 fullscreen_player_is_released_ = false; | 686 fullscreen_player_is_released_ = false; |
| 686 } | 687 } |
| 687 } | 688 } |
| 688 | 689 |
| 689 } // namespace content | 690 } // namespace content |
| OLD | NEW |