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 #ifndef CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_ | 5 #ifndef CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_ |
6 #define CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_ | 6 #define CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_delegate.h" | 21 #include "content/public/browser/web_contents_delegate.h" |
21 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
23 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
25 | 26 |
26 class GURL; | 27 class GURL; |
27 | 28 |
(...skipping 10 matching lines...) Expand all Loading... |
38 public content::WebContentsObserver { | 39 public content::WebContentsObserver { |
39 public: | 40 public: |
40 // Creates a new window and immediately loads the given URL. | 41 // Creates a new window and immediately loads the given URL. |
41 static CastWindowAndroid* CreateNewWindow( | 42 static CastWindowAndroid* CreateNewWindow( |
42 content::BrowserContext* browser_context, | 43 content::BrowserContext* browser_context, |
43 const GURL& url); | 44 const GURL& url); |
44 | 45 |
45 virtual ~CastWindowAndroid(); | 46 virtual ~CastWindowAndroid(); |
46 | 47 |
47 void LoadURL(const GURL& url); | 48 void LoadURL(const GURL& url); |
| 49 // Calls RVH::ClosePage() and waits for acknowledgement before closing/ |
| 50 // deleting the window. |
48 void Close(); | 51 void Close(); |
| 52 // Destroys this window immediately. |
| 53 void Destroy(); |
49 | 54 |
50 // Registers the JNI methods for CastWindowAndroid. | 55 // Registers the JNI methods for CastWindowAndroid. |
51 static bool RegisterJni(JNIEnv* env); | 56 static bool RegisterJni(JNIEnv* env); |
52 | 57 |
53 // content::WebContentsDelegate implementation: | 58 // content::WebContentsDelegate implementation: |
54 virtual void AddNewContents(content::WebContents* source, | 59 virtual void AddNewContents(content::WebContents* source, |
55 content::WebContents* new_contents, | 60 content::WebContents* new_contents, |
56 WindowOpenDisposition disposition, | 61 WindowOpenDisposition disposition, |
57 const gfx::Rect& initial_pos, | 62 const gfx::Rect& initial_pos, |
58 bool user_gesture, | 63 bool user_gesture, |
(...skipping 15 matching lines...) Expand all Loading... |
74 explicit CastWindowAndroid(content::WebContents* web_contents); | 79 explicit CastWindowAndroid(content::WebContents* web_contents); |
75 | 80 |
76 // Helper to create a new CastWindowAndroid given a newly created WebContents. | 81 // Helper to create a new CastWindowAndroid given a newly created WebContents. |
77 static CastWindowAndroid* CreateCastWindowAndroid( | 82 static CastWindowAndroid* CreateCastWindowAndroid( |
78 content::WebContents* web_contents, | 83 content::WebContents* web_contents, |
79 const gfx::Size& initial_size); | 84 const gfx::Size& initial_size); |
80 | 85 |
81 base::android::ScopedJavaGlobalRef<jobject> java_object_; | 86 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
82 scoped_ptr<content::WebContents> web_contents_; | 87 scoped_ptr<content::WebContents> web_contents_; |
83 | 88 |
| 89 base::WeakPtrFactory<CastWindowAndroid> weak_factory_; |
| 90 |
84 DISALLOW_COPY_AND_ASSIGN(CastWindowAndroid); | 91 DISALLOW_COPY_AND_ASSIGN(CastWindowAndroid); |
85 }; | 92 }; |
86 | 93 |
87 } // namespace shell | 94 } // namespace shell |
88 } // namespace chromecast | 95 } // namespace chromecast |
89 | 96 |
90 #endif // CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_ | 97 #endif // CHROMECAST_SHELL_BROWSER_ANDROID_CAST_WINDOW_ANDROID_H_ |
OLD | NEW |