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

Side by Side Diff: content/browser/android/content_video_view.cc

Issue 13669003: Refactoring ContentVideoViewContextDelegate.java (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/android/content_video_view.h" 5 #include "content/browser/android/content_video_view.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/android/media_player_manager_android.h" 10 #include "content/browser/android/media_player_manager_android.h"
11 #include "content/common/android/surface_texture_peer.h" 11 #include "content/common/android/surface_texture_peer.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "jni/ContentVideoView_jni.h" 13 #include "jni/ContentVideoView_jni.h"
14 14
15 using base::android::AttachCurrentThread; 15 using base::android::AttachCurrentThread;
16 using base::android::CheckException; 16 using base::android::CheckException;
17 using base::android::GetApplicationContext;
17 using base::android::ScopedJavaGlobalRef; 18 using base::android::ScopedJavaGlobalRef;
18 19
19 namespace content { 20 namespace content {
20 21
21 bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) { 22 bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) {
22 return RegisterNativesImpl(env); 23 return RegisterNativesImpl(env);
23 } 24 }
24 25
25 ContentVideoView::ContentVideoView(MediaPlayerManagerAndroid* manager) 26 ContentVideoView::ContentVideoView(MediaPlayerManagerAndroid* manager)
26 : manager_(manager) { 27 : manager_(manager) {
27 } 28 }
28 29
29 ContentVideoView::~ContentVideoView() { 30 ContentVideoView::~ContentVideoView() {
30 DestroyContentVideoView(); 31 DestroyContentVideoView();
31 } 32 }
32 33
33 void ContentVideoView::CreateContentVideoView() { 34 void ContentVideoView::CreateContentVideoView(
joth 2013/04/05 01:56:40 what if j_content_video_view_ were not null? I thi
michaelbai 2013/04/05 21:06:56 if j_content_video_view_ was not null, the same ob
joth 2013/04/08 18:47:34 Right, the java-side object is a singleton but the
34 if (j_content_video_view_.is_null()) { 35 ScopedJavaLocalRef<jobject> content_video_view_client) {
35 JNIEnv* env = AttachCurrentThread(); 36 j_content_video_view_.Reset(
36 j_content_video_view_.Reset(Java_ContentVideoView_createContentVideoView( 37 Java_ContentVideoView_createContentVideoView(AttachCurrentThread(),
37 env, reinterpret_cast<jint>(this))); 38 GetApplicationContext(), reinterpret_cast<int>(this),
38 } else { 39 content_video_view_client.obj()));
39 // Just ask video view to reopen the video.
40 Java_ContentVideoView_openVideo(AttachCurrentThread(),
41 j_content_video_view_.obj());
42 }
43 } 40 }
44 41
45 void ContentVideoView::DestroyContentVideoView() { 42 void ContentVideoView::DestroyContentVideoView() {
46 if (!j_content_video_view_.is_null()) { 43 if (!j_content_video_view_.is_null()) {
47 Java_ContentVideoView_destroyContentVideoView(AttachCurrentThread()); 44 Java_ContentVideoView_destroyContentVideoView(AttachCurrentThread(),
45 j_content_video_view_.obj());
48 j_content_video_view_.Reset(); 46 j_content_video_view_.Reset();
49 } 47 }
50 } 48 }
51 49
52 void ContentVideoView::OnMediaPlayerError(int error_type) { 50 void ContentVideoView::OnMediaPlayerError(int error_type) {
53 if (!j_content_video_view_.is_null()) { 51 if (!j_content_video_view_.is_null()) {
54 Java_ContentVideoView_onMediaPlayerError(AttachCurrentThread(), 52 Java_ContentVideoView_onMediaPlayerError(AttachCurrentThread(),
55 j_content_video_view_.obj(), 53 j_content_video_view_.obj(),
56 error_type); 54 error_type);
57 } 55 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void ContentVideoView::UpdateMediaMetadata(JNIEnv* env, jobject obj) { 135 void ContentVideoView::UpdateMediaMetadata(JNIEnv* env, jobject obj) {
138 media::MediaPlayerBridge* player = manager_->GetFullscreenPlayer(); 136 media::MediaPlayerBridge* player = manager_->GetFullscreenPlayer();
139 if (player && player->prepared()) 137 if (player && player->prepared())
140 Java_ContentVideoView_updateMediaMetadata( 138 Java_ContentVideoView_updateMediaMetadata(
141 env, obj, player->GetVideoWidth(), player->GetVideoHeight(), 139 env, obj, player->GetVideoWidth(), player->GetVideoHeight(),
142 player->GetDuration().InMilliseconds(), player->can_pause(), 140 player->GetDuration().InMilliseconds(), player->can_pause(),
143 player->can_seek_forward(), player->can_seek_backward()); 141 player->can_seek_forward(), player->can_seek_backward());
144 } 142 }
145 143
146 } // namespace content 144 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698