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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 2353063005: Refactor ContentViewClient (1/6) (Closed)
Patch Set: cast to activity Created 4 years, 2 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 #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
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()) {
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 } 222 }
226 #endif 223 #endif
227 if (!extract_metadata) { 224 if (!extract_metadata) {
228 // May reach here due to prerendering or throttling. Don't extract the 225 // May reach here due to prerendering or throttling. Don't extract the
229 // metadata since it is expensive. 226 // metadata since it is expensive.
230 // TODO(qinmin): extract the metadata once the user decided to load 227 // TODO(qinmin): extract the metadata once the user decided to load
231 // the page. 228 // the page.
232 OnMediaMetadataChanged(media_player_params.player_id, base::TimeDelta(), 229 OnMediaMetadataChanged(media_player_params.player_id, base::TimeDelta(),
233 0, 0, false); 230 0, 0, false);
234 } else if (!should_block) { 231 } else if (!should_block) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 445
449 // There's no ContentVideoView instance so create one. 446 // There's no ContentVideoView instance so create one.
450 // If we know the video frame size, use it. 447 // If we know the video frame size, use it.
451 gfx::Size natural_video_size; 448 gfx::Size natural_video_size;
452 MediaPlayerAndroid* player = GetFullscreenPlayer(); 449 MediaPlayerAndroid* player = GetFullscreenPlayer();
453 if (player && player->IsPlayerReady()) { 450 if (player && player->IsPlayerReady()) {
454 natural_video_size = 451 natural_video_size =
455 gfx::Size(player->GetVideoWidth(), player->GetVideoHeight()); 452 gfx::Size(player->GetVideoWidth(), player->GetVideoHeight());
456 } 453 }
457 454
455 if (!web_contents()->GetDelegate())
456 return;
457
458 base::android::ScopedJavaLocalRef<jobject> embedder(
459 web_contents()->GetDelegate()->GetContentVideoViewEmbedder());
458 video_view_.reset( 460 video_view_.reset(
459 new ContentVideoView(this, GetContentViewCore(), natural_video_size)); 461 new ContentVideoView(this,
462 GetContentViewCore(),
463 embedder,
464 natural_video_size));
460 465
461 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = 466 base::android::ScopedJavaLocalRef<jobject> j_content_video_view =
462 video_view_->GetJavaObject(base::android::AttachCurrentThread()); 467 video_view_->GetJavaObject(base::android::AttachCurrentThread());
463 if (!j_content_video_view.is_null()) { 468 if (!j_content_video_view.is_null()) {
464 fullscreen_player_id_ = player_id; 469 fullscreen_player_id_ = player_id;
465 } else { 470 } else {
466 Send(new MediaPlayerMsg_DidExitFullscreen(RoutingID(), player_id)); 471 Send(new MediaPlayerMsg_DidExitFullscreen(RoutingID(), player_id));
467 video_view_.reset(); 472 video_view_.reset();
468 } 473 }
469 #endif // defined(USE_AURA) 474 #endif // defined(USE_AURA)
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 if (!player) 685 if (!player)
681 return; 686 return;
682 player->Start(); 687 player->Start();
683 if (fullscreen_player_id_ == player_id && fullscreen_player_is_released_) { 688 if (fullscreen_player_id_ == player_id && fullscreen_player_is_released_) {
684 video_view_->OpenVideo(); 689 video_view_->OpenVideo();
685 fullscreen_player_is_released_ = false; 690 fullscreen_player_is_released_ = false;
686 } 691 }
687 } 692 }
688 693
689 } // namespace content 694 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | content/browser/media/android/browser_surface_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698