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 #ifndef CHROMECAST_BROWSER_ANDROID_CAST_CONTENT_WINDOW_ANDROID_H_ | 5 #ifndef CHROMECAST_BROWSER_ANDROID_CAST_CONTENT_WINDOW_ANDROID_H_ |
6 #define CHROMECAST_BROWSER_ANDROID_CAST_CONTENT_WINDOW_ANDROID_H_ | 6 #define CHROMECAST_BROWSER_ANDROID_CAST_CONTENT_WINDOW_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chromecast/browser/cast_content_window.h" | 14 #include "chromecast/browser/cast_content_window.h" |
15 #include "content/public/browser/web_contents_observer.h" | |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 class BrowserContext; | |
19 class WebContents; | 17 class WebContents; |
20 } | 18 } |
21 | 19 |
22 namespace chromecast { | 20 namespace chromecast { |
23 namespace shell { | 21 namespace shell { |
24 | 22 |
25 // Android implementation of CastContentWindow, which displays WebContents in | 23 // Android implementation of CastContentWindow, which displays WebContents in |
26 // CastWebContentsActivity. | 24 // CastWebContentsActivity. |
27 class CastContentWindowAndroid : public CastContentWindow, | 25 class CastContentWindowAndroid : public CastContentWindow { |
28 public content::WebContentsObserver { | |
29 public: | 26 public: |
30 static bool RegisterJni(JNIEnv* env); | 27 static bool RegisterJni(JNIEnv* env); |
31 | 28 |
32 ~CastContentWindowAndroid() override; | 29 ~CastContentWindowAndroid() override; |
33 | 30 |
34 // CastContentWindow implementation: | 31 // CastContentWindow implementation: |
35 void SetTransparent() override; | 32 void SetTransparent() override; |
36 void ShowWebContents(content::WebContents* web_contents) override; | 33 void ShowWebContents(content::WebContents* web_contents) override; |
37 std::unique_ptr<content::WebContents> CreateWebContents( | |
38 content::BrowserContext* browser_context) override; | |
39 | |
40 // content::WebContentsObserver implementation: | |
41 void DidFirstVisuallyNonEmptyPaint() override; | |
42 void MediaStartedPlaying(const MediaPlayerInfo& media_info, | |
43 const MediaPlayerId& id) override; | |
44 void MediaStoppedPlaying(const MediaPlayerInfo& media_info, | |
45 const MediaPlayerId& id) override; | |
46 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | |
47 | 34 |
48 // Called through JNI. | 35 // Called through JNI. |
49 void OnActivityStopped(JNIEnv* env, | 36 void OnActivityStopped(JNIEnv* env, |
50 const base::android::JavaParamRef<jobject>& jcaller); | 37 const base::android::JavaParamRef<jobject>& jcaller); |
51 void OnKeyDown(JNIEnv* env, | 38 void OnKeyDown(JNIEnv* env, |
52 const base::android::JavaParamRef<jobject>& jcaller, | 39 const base::android::JavaParamRef<jobject>& jcaller, |
53 int keycode); | 40 int keycode); |
54 | 41 |
55 private: | 42 private: |
56 friend class CastContentWindow; | 43 friend class CastContentWindow; |
57 | 44 |
58 // This class should only be instantiated by CastContentWindow::Create. | 45 // This class should only be instantiated by CastContentWindow::Create. |
59 explicit CastContentWindowAndroid(CastContentWindow::Delegate* delegate); | 46 explicit CastContentWindowAndroid(CastContentWindow::Delegate* delegate); |
60 | 47 |
61 CastContentWindow::Delegate* const delegate_; | 48 CastContentWindow::Delegate* const delegate_; |
62 bool transparent_; | |
63 base::android::ScopedJavaGlobalRef<jobject> java_window_; | 49 base::android::ScopedJavaGlobalRef<jobject> java_window_; |
64 | 50 |
65 DISALLOW_COPY_AND_ASSIGN(CastContentWindowAndroid); | 51 DISALLOW_COPY_AND_ASSIGN(CastContentWindowAndroid); |
66 }; | 52 }; |
67 | 53 |
68 } // namespace shell | 54 } // namespace shell |
69 } // namespace chromecast | 55 } // namespace chromecast |
70 | 56 |
71 #endif // CHROMECAST_BROWSER_ANDROID_CAST_CONTENT_WINDOW_ANDROID_H_ | 57 #endif // CHROMECAST_BROWSER_ANDROID_CAST_CONTENT_WINDOW_ANDROID_H_ |
OLD | NEW |