| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/browser/android/cast_window_android.h" | 5 #include "chromecast/browser/android/cast_window_android.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "chromecast/base/version.h" |
| 9 #include "chromecast/browser/android/cast_window_manager.h" | 10 #include "chromecast/browser/android/cast_window_manager.h" |
| 10 #include "chromecast/browser/cast_content_window.h" | 11 #include "chromecast/browser/cast_content_window.h" |
| 11 #include "content/public/browser/devtools_agent_host.h" | 12 #include "content/public/browser/devtools_agent_host.h" |
| 12 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 13 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
| 14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/render_widget_host.h" | 17 #include "content/public/browser/render_widget_host.h" |
| 17 #include "content/public/browser/render_widget_host_view.h" | 18 #include "content/public/browser/render_widget_host_view.h" |
| 18 #include "content/public/common/renderer_preferences.h" | 19 #include "content/public/common/renderer_preferences.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 void CastWindowAndroid::Initialize() { | 59 void CastWindowAndroid::Initialize() { |
| 59 web_contents_ = content_window_->CreateWebContents(browser_context_); | 60 web_contents_ = content_window_->CreateWebContents(browser_context_); |
| 60 web_contents_->SetDelegate(this); | 61 web_contents_->SetDelegate(this); |
| 61 content::WebContentsObserver::Observe(web_contents_.get()); | 62 content::WebContentsObserver::Observe(web_contents_.get()); |
| 62 | 63 |
| 63 JNIEnv* env = base::android::AttachCurrentThread(); | 64 JNIEnv* env = base::android::AttachCurrentThread(); |
| 64 window_java_.Reset(CreateCastWindowView(this)); | 65 window_java_.Reset(CreateCastWindowView(this)); |
| 65 | 66 |
| 66 Java_CastWindowAndroid_initFromNativeWebContents( | 67 Java_CastWindowAndroid_initFromNativeWebContents( |
| 67 env, window_java_.obj(), web_contents_->GetJavaWebContents().obj(), | 68 env, window_java_, web_contents_->GetJavaWebContents(), |
| 68 web_contents_->GetRenderProcessHost()->GetID()); | 69 web_contents_->GetRenderProcessHost()->GetID(), |
| 70 base::android::ConvertUTF8ToJavaString(env, PRODUCT_VERSION)); |
| 69 | 71 |
| 70 // Enabling hole-punching also requires runtime renderer preference | 72 // Enabling hole-punching also requires runtime renderer preference |
| 71 content::RendererPreferences* prefs = | 73 content::RendererPreferences* prefs = |
| 72 web_contents_->GetMutableRendererPrefs(); | 74 web_contents_->GetMutableRendererPrefs(); |
| 73 prefs->use_video_overlay_for_embedded_encrypted_video = true; | 75 prefs->use_video_overlay_for_embedded_encrypted_video = true; |
| 74 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 76 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 CastWindowAndroid::~CastWindowAndroid() { | 79 CastWindowAndroid::~CastWindowAndroid() { |
| 78 } | 80 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 int32_t line_no, | 138 int32_t line_no, |
| 137 const base::string16& source_id) { | 139 const base::string16& source_id) { |
| 138 return false; | 140 return false; |
| 139 } | 141 } |
| 140 | 142 |
| 141 void CastWindowAndroid::ActivateContents(content::WebContents* contents) { | 143 void CastWindowAndroid::ActivateContents(content::WebContents* contents) { |
| 142 DCHECK_EQ(contents, web_contents_.get()); | 144 DCHECK_EQ(contents, web_contents_.get()); |
| 143 contents->GetRenderViewHost()->GetWidget()->Focus(); | 145 contents->GetRenderViewHost()->GetWidget()->Focus(); |
| 144 } | 146 } |
| 145 | 147 |
| 148 base::android::ScopedJavaLocalRef<jobject> |
| 149 CastWindowAndroid::GetContentVideoViewEmbedder() { |
| 150 JNIEnv* env = base::android::AttachCurrentThread(); |
| 151 return Java_CastWindowAndroid_getContentVideoViewEmbedder(env, window_java_); |
| 152 } |
| 153 |
| 146 void CastWindowAndroid::RenderProcessGone(base::TerminationStatus status) { | 154 void CastWindowAndroid::RenderProcessGone(base::TerminationStatus status) { |
| 147 LOG(ERROR) << "Render process gone: status=" << status; | 155 LOG(ERROR) << "Render process gone: status=" << status; |
| 148 Destroy(); | 156 Destroy(); |
| 149 } | 157 } |
| 150 | 158 |
| 151 } // namespace shell | 159 } // namespace shell |
| 152 } // namespace chromecast | 160 } // namespace chromecast |
| OLD | NEW |