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/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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "content/browser/android/interstitial_page_delegate_android.h" | 12 #include "content/browser/android/interstitial_page_delegate_android.h" |
13 #include "content/browser/frame_host/interstitial_page_impl.h" | 13 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 14 #include "content/browser/media/android/browser_media_player_manager.h" |
14 #include "content/browser/media/media_web_contents_observer.h" | 15 #include "content/browser/media/media_web_contents_observer.h" |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/web_contents/web_contents_impl.h" | 17 #include "content/browser/web_contents/web_contents_impl.h" |
17 #include "content/common/frame_messages.h" | 18 #include "content/common/frame_messages.h" |
18 #include "content/common/input_messages.h" | 19 #include "content/common/input_messages.h" |
19 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 178 |
178 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) { | 179 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) { |
179 web_contents_->WasHidden(); | 180 web_contents_->WasHidden(); |
180 PauseVideo(); | 181 PauseVideo(); |
181 } | 182 } |
182 | 183 |
183 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) { | 184 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) { |
184 web_contents_->WasShown(); | 185 web_contents_->WasShown(); |
185 } | 186 } |
186 | 187 |
| 188 void WebContentsAndroid::ReleaseMediaPlayers(JNIEnv* env, jobject jobj) { |
| 189 #if defined(ENABLE_BROWSER_CDMS) |
| 190 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| 191 web_contents_->GetRenderViewHost()); |
| 192 if (!rvhi || !rvhi->GetMainFrame()) |
| 193 return; |
| 194 |
| 195 BrowserMediaPlayerManager* manager = |
| 196 rvhi->media_web_contents_observer()->GetMediaPlayerManager( |
| 197 rvhi->GetMainFrame()); |
| 198 if (manager) |
| 199 manager->ReleaseAllMediaPlayers(); |
| 200 #endif // defined(ENABLE_BROWSER_CDMS) |
| 201 } |
| 202 |
187 void WebContentsAndroid::PauseVideo() { | 203 void WebContentsAndroid::PauseVideo() { |
188 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 204 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
189 web_contents_->GetRenderViewHost()); | 205 web_contents_->GetRenderViewHost()); |
190 if (rvhi) | 206 if (rvhi) |
191 rvhi->media_web_contents_observer()->PauseVideo(); | 207 rvhi->media_web_contents_observer()->PauseVideo(); |
192 } | 208 } |
193 | 209 |
194 void WebContentsAndroid::AddStyleSheetByURL( | 210 void WebContentsAndroid::AddStyleSheetByURL( |
195 JNIEnv* env, | 211 JNIEnv* env, |
196 jobject obj, | 212 jobject obj, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 ScopedJavaGlobalRef<jobject> j_callback; | 368 ScopedJavaGlobalRef<jobject> j_callback; |
353 j_callback.Reset(env, callback); | 369 j_callback.Reset(env, callback); |
354 content::RenderFrameHost::JavaScriptResultCallback js_callback = | 370 content::RenderFrameHost::JavaScriptResultCallback js_callback = |
355 base::Bind(&JavaScriptResultCallback, j_callback); | 371 base::Bind(&JavaScriptResultCallback, j_callback); |
356 | 372 |
357 web_contents_->GetMainFrame()->ExecuteJavaScript( | 373 web_contents_->GetMainFrame()->ExecuteJavaScript( |
358 ConvertJavaStringToUTF16(env, script), js_callback); | 374 ConvertJavaStringToUTF16(env, script), js_callback); |
359 } | 375 } |
360 | 376 |
361 } // namespace content | 377 } // namespace content |
OLD | NEW |