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 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | |
190 web_contents_->GetRenderViewHost()); | |
qinmin
2014/08/25 18:57:12
nit: -2 indent
David Trainor- moved to gerrit
2014/08/25 23:42:15
Done.
| |
191 #if defined(ENABLE_BROWSER_CDMS) | |
192 if (rvhi && rvhi->GetMainFrame()) { | |
qinmin
2014/08/25 18:57:12
nit: nested if statements. Consider rewriting:
if
David Trainor- moved to gerrit
2014/08/25 23:42:15
Done.
| |
193 BrowserMediaPlayerManager* manager = | |
194 rvhi->media_web_contents_observer()->GetMediaPlayerManager( | |
195 rvhi->GetMainFrame()); | |
196 if (manager) | |
197 manager->ReleaseAllMediaPlayers(); | |
198 } | |
199 #endif // defined(ENABLE_BROWSER_CDMS) | |
200 } | |
201 | |
187 void WebContentsAndroid::PauseVideo() { | 202 void WebContentsAndroid::PauseVideo() { |
188 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 203 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
189 web_contents_->GetRenderViewHost()); | 204 web_contents_->GetRenderViewHost()); |
190 if (rvhi) | 205 if (rvhi) |
191 rvhi->media_web_contents_observer()->PauseVideo(); | 206 rvhi->media_web_contents_observer()->PauseVideo(); |
192 } | 207 } |
193 | 208 |
194 void WebContentsAndroid::AddStyleSheetByURL( | 209 void WebContentsAndroid::AddStyleSheetByURL( |
195 JNIEnv* env, | 210 JNIEnv* env, |
196 jobject obj, | 211 jobject obj, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 ScopedJavaGlobalRef<jobject> j_callback; | 367 ScopedJavaGlobalRef<jobject> j_callback; |
353 j_callback.Reset(env, callback); | 368 j_callback.Reset(env, callback); |
354 content::RenderFrameHost::JavaScriptResultCallback js_callback = | 369 content::RenderFrameHost::JavaScriptResultCallback js_callback = |
355 base::Bind(&JavaScriptResultCallback, j_callback); | 370 base::Bind(&JavaScriptResultCallback, j_callback); |
356 | 371 |
357 web_contents_->GetMainFrame()->ExecuteJavaScript( | 372 web_contents_->GetMainFrame()->ExecuteJavaScript( |
358 ConvertJavaStringToUTF16(env, script), js_callback); | 373 ConvertJavaStringToUTF16(env, script), js_callback); |
359 } | 374 } |
360 | 375 |
361 } // namespace content | 376 } // namespace content |
OLD | NEW |