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

Side by Side Diff: content/browser/web_contents/web_contents_android.cc

Issue 570183002: Make the pause of video playback and video capture consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 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/web_contents/web_contents_android.h" 5 #include "content/browser/web_contents/web_contents_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 void WebContentsAndroid::BeginExitTransition(JNIEnv* env, 171 void WebContentsAndroid::BeginExitTransition(JNIEnv* env,
172 jobject jobj, 172 jobject jobj,
173 jstring css_selector) { 173 jstring css_selector) {
174 web_contents_->GetMainFrame()->Send(new FrameMsg_BeginExitTransition( 174 web_contents_->GetMainFrame()->Send(new FrameMsg_BeginExitTransition(
175 web_contents_->GetMainFrame()->GetRoutingID(), 175 web_contents_->GetMainFrame()->GetRoutingID(),
176 ConvertJavaStringToUTF8(env, css_selector))); 176 ConvertJavaStringToUTF8(env, css_selector)));
177 } 177 }
178 178
179 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) { 179 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) {
180 web_contents_->WasHidden(); 180 web_contents_->WasHidden();
181 PauseVideo();
182 } 181 }
183 182
184 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) { 183 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) {
185 web_contents_->WasShown(); 184 web_contents_->WasShown();
186 } 185 }
187 186
188 void WebContentsAndroid::ReleaseMediaPlayers(JNIEnv* env, jobject jobj) { 187 void WebContentsAndroid::ReleaseMediaPlayers(JNIEnv* env, jobject jobj) {
189 #if defined(ENABLE_BROWSER_CDMS) 188 #if defined(ENABLE_BROWSER_CDMS)
190 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( 189 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
191 web_contents_->GetRenderViewHost()); 190 web_contents_->GetRenderViewHost());
192 if (!rvhi || !rvhi->GetMainFrame()) 191 if (!rvhi || !rvhi->GetMainFrame())
193 return; 192 return;
194 193
195 BrowserMediaPlayerManager* manager = 194 BrowserMediaPlayerManager* manager =
196 rvhi->media_web_contents_observer()->GetMediaPlayerManager( 195 rvhi->media_web_contents_observer()->GetMediaPlayerManager(
197 rvhi->GetMainFrame()); 196 rvhi->GetMainFrame());
198 if (manager) 197 if (manager)
199 manager->ReleaseAllMediaPlayers(); 198 manager->ReleaseAllMediaPlayers();
200 #endif // defined(ENABLE_BROWSER_CDMS) 199 #endif // defined(ENABLE_BROWSER_CDMS)
201 } 200 }
202 201
203 void WebContentsAndroid::PauseVideo() {
204 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
205 web_contents_->GetRenderViewHost());
206 if (rvhi)
207 rvhi->media_web_contents_observer()->PauseVideo();
208 }
209
210 void WebContentsAndroid::AddStyleSheetByURL( 202 void WebContentsAndroid::AddStyleSheetByURL(
211 JNIEnv* env, 203 JNIEnv* env,
212 jobject obj, 204 jobject obj,
213 jstring url) { 205 jstring url) {
214 web_contents_->GetMainFrame()->Send(new FrameMsg_AddStyleSheetByURL( 206 web_contents_->GetMainFrame()->Send(new FrameMsg_AddStyleSheetByURL(
215 web_contents_->GetMainFrame()->GetRoutingID(), 207 web_contents_->GetMainFrame()->GetRoutingID(),
216 ConvertJavaStringToUTF8(env, url))); 208 ConvertJavaStringToUTF8(env, url)));
217 } 209 }
218 210
219 void WebContentsAndroid::ShowInterstitialPage( 211 void WebContentsAndroid::ShowInterstitialPage(
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ScopedJavaGlobalRef<jobject> j_callback; 359 ScopedJavaGlobalRef<jobject> j_callback;
368 j_callback.Reset(env, callback); 360 j_callback.Reset(env, callback);
369 content::RenderFrameHost::JavaScriptResultCallback js_callback = 361 content::RenderFrameHost::JavaScriptResultCallback js_callback =
370 base::Bind(&JavaScriptResultCallback, j_callback); 362 base::Bind(&JavaScriptResultCallback, j_callback);
371 363
372 web_contents_->GetMainFrame()->ExecuteJavaScript( 364 web_contents_->GetMainFrame()->ExecuteJavaScript(
373 ConvertJavaStringToUTF16(env, script), js_callback); 365 ConvertJavaStringToUTF16(env, script), js_callback);
374 } 366 }
375 367
376 } // namespace content 368 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_android.h ('k') | content/common/media/media_player_messages_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698