| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_content_window_android.h" | 5 #include "chromecast/browser/android/cast_content_window_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chromecast/base/metrics/cast_metrics_helper.h" | |
| 11 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/browser/render_widget_host.h" | 11 #include "content/public/browser/render_widget_host.h" |
| 13 #include "content/public/browser/render_widget_host_view.h" | 12 #include "content/public/browser/render_widget_host_view.h" |
| 14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/renderer_preferences.h" | 14 #include "content/public/common/renderer_preferences.h" |
| 16 #include "ipc/ipc_message.h" | 15 #include "ipc/ipc_message.h" |
| 17 #include "jni/CastContentWindowAndroid_jni.h" | 16 #include "jni/CastContentWindowAndroid_jni.h" |
| 18 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 19 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 20 #include "ui/events/keycodes/keyboard_code_conversion_android.h" | 19 #include "ui/events/keycodes/keyboard_code_conversion_android.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 content::WebContents::Create(create_params)); | 81 content::WebContents::Create(create_params)); |
| 83 | 82 |
| 84 content::RendererPreferences* prefs = web_contents->GetMutableRendererPrefs(); | 83 content::RendererPreferences* prefs = web_contents->GetMutableRendererPrefs(); |
| 85 prefs->use_video_overlay_for_embedded_encrypted_video = true; | 84 prefs->use_video_overlay_for_embedded_encrypted_video = true; |
| 86 web_contents->GetRenderViewHost()->SyncRendererPrefs(); | 85 web_contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 87 | 86 |
| 88 content::WebContentsObserver::Observe(web_contents.get()); | 87 content::WebContentsObserver::Observe(web_contents.get()); |
| 89 return web_contents; | 88 return web_contents; |
| 90 } | 89 } |
| 91 | 90 |
| 92 void CastContentWindowAndroid::DidFirstVisuallyNonEmptyPaint() { | |
| 93 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); | |
| 94 } | |
| 95 | |
| 96 void CastContentWindowAndroid::MediaStartedPlaying( | |
| 97 const MediaPlayerInfo& media_info, | |
| 98 const MediaPlayerId& id) { | |
| 99 metrics::CastMetricsHelper::GetInstance()->LogMediaPlay(); | |
| 100 } | |
| 101 | |
| 102 void CastContentWindowAndroid::MediaStoppedPlaying( | |
| 103 const MediaPlayerInfo& media_info, | |
| 104 const MediaPlayerId& id) { | |
| 105 metrics::CastMetricsHelper::GetInstance()->LogMediaPause(); | |
| 106 } | |
| 107 | |
| 108 void CastContentWindowAndroid::RenderViewCreated( | 91 void CastContentWindowAndroid::RenderViewCreated( |
| 109 content::RenderViewHost* render_view_host) { | 92 content::RenderViewHost* render_view_host) { |
| 110 content::RenderWidgetHostView* view = | 93 content::RenderWidgetHostView* view = |
| 111 render_view_host->GetWidget()->GetView(); | 94 render_view_host->GetWidget()->GetView(); |
| 112 if (view) { | 95 if (view) { |
| 113 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT | 96 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT |
| 114 : SK_ColorBLACK); | 97 : SK_ColorBLACK); |
| 115 } | 98 } |
| 116 } | 99 } |
| 117 | 100 |
| 118 void CastContentWindowAndroid::OnActivityStopped( | 101 void CastContentWindowAndroid::OnActivityStopped( |
| 119 JNIEnv* env, | 102 JNIEnv* env, |
| 120 const base::android::JavaParamRef<jobject>& jcaller) { | 103 const base::android::JavaParamRef<jobject>& jcaller) { |
| 121 delegate_->OnWindowDestroyed(); | 104 delegate_->OnWindowDestroyed(); |
| 122 } | 105 } |
| 123 | 106 |
| 124 void CastContentWindowAndroid::OnKeyDown( | 107 void CastContentWindowAndroid::OnKeyDown( |
| 125 JNIEnv* env, | 108 JNIEnv* env, |
| 126 const base::android::JavaParamRef<jobject>& jcaller, | 109 const base::android::JavaParamRef<jobject>& jcaller, |
| 127 int keycode) { | 110 int keycode) { |
| 128 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, | 111 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, |
| 129 ui::KeyboardCodeFromAndroidKeyCode(keycode), | 112 ui::KeyboardCodeFromAndroidKeyCode(keycode), |
| 130 ui::EF_NONE); | 113 ui::EF_NONE); |
| 131 delegate_->OnKeyEvent(key_event); | 114 delegate_->OnKeyEvent(key_event); |
| 132 } | 115 } |
| 133 | 116 |
| 134 } // namespace shell | 117 } // namespace shell |
| 135 } // namespace chromecast | 118 } // namespace chromecast |
| OLD | NEW |