OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
6 #define CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/android/jni_weak_ref.h" | 13 #include "base/android/jni_weak_ref.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
15 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" |
17 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
18 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" | 19 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" |
19 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 20 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
20 #include "components/favicon/core/favicon_driver_observer.h" | 21 #include "components/favicon/core/favicon_driver_observer.h" |
21 #include "components/infobars/core/infobar_manager.h" | 22 #include "components/infobars/core/infobar_manager.h" |
22 #include "components/sessions/core/session_id.h" | 23 #include "components/sessions/core/session_id.h" |
23 #include "components/toolbar/toolbar_model.h" | 24 #include "components/toolbar/toolbar_model.h" |
24 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
25 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "content/public/browser/web_contents_observer.h" |
| 28 #include "services/service_manager/public/cpp/binder_registry.h" |
| 29 #include "third_party/WebKit/public/platform/media_download_in_product_help.mojo
m.h" |
26 | 30 |
27 class GURL; | 31 class GURL; |
28 class Profile; | 32 class Profile; |
29 | 33 |
30 namespace cc { | 34 namespace cc { |
31 class Layer; | 35 class Layer; |
32 } | 36 } |
33 | 37 |
34 namespace chrome { | 38 namespace chrome { |
35 struct NavigateParams; | 39 struct NavigateParams; |
36 } | 40 } |
37 | 41 |
38 namespace android { | 42 namespace android { |
39 class TabWebContentsDelegateAndroid; | 43 class TabWebContentsDelegateAndroid; |
40 class TabContentManager; | 44 class TabContentManager; |
41 } | 45 } |
42 | 46 |
43 namespace content { | 47 namespace content { |
44 class DevToolsAgentHost; | 48 class DevToolsAgentHost; |
45 class WebContents; | 49 class WebContents; |
46 } | 50 } |
47 | 51 |
48 namespace prerender { | 52 namespace prerender { |
49 class PrerenderManager; | 53 class PrerenderManager; |
50 } | 54 } |
51 | 55 |
52 class TabAndroid : public CoreTabHelperDelegate, | 56 class TabAndroid : public CoreTabHelperDelegate, |
53 public content::NotificationObserver, | 57 public content::NotificationObserver, |
54 public favicon::FaviconDriverObserver { | 58 public favicon::FaviconDriverObserver, |
| 59 public content::WebContentsObserver { |
55 public: | 60 public: |
56 // A Java counterpart will be generated for this enum. | 61 // A Java counterpart will be generated for this enum. |
57 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser | 62 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser |
58 enum TabLoadStatus { | 63 enum TabLoadStatus { |
59 PAGE_LOAD_FAILED = 0, | 64 PAGE_LOAD_FAILED = 0, |
60 DEFAULT_PAGE_LOAD = 1, | 65 DEFAULT_PAGE_LOAD = 1, |
61 PARTIAL_PRERENDERED_PAGE_LOAD = 2, | 66 PARTIAL_PRERENDERED_PAGE_LOAD = 2, |
62 FULL_PRERENDERED_PAGE_LOAD = 3, | 67 FULL_PRERENDERED_PAGE_LOAD = 3, |
63 }; | 68 }; |
64 | 69 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 253 |
249 const std::string& GetWebappManifestScope() const { | 254 const std::string& GetWebappManifestScope() const { |
250 return webapp_manifest_scope_; | 255 return webapp_manifest_scope_; |
251 } | 256 } |
252 | 257 |
253 void EnableEmbeddedMediaExperience( | 258 void EnableEmbeddedMediaExperience( |
254 JNIEnv* env, | 259 JNIEnv* env, |
255 const base::android::JavaParamRef<jobject>& obj, | 260 const base::android::JavaParamRef<jobject>& obj, |
256 jboolean enabled); | 261 jboolean enabled); |
257 | 262 |
| 263 void MediaDownloadInProductHelpDismissed( |
| 264 JNIEnv* env, |
| 265 const base::android::JavaParamRef<jobject>& obj); |
| 266 |
258 bool ShouldEnableEmbeddedMediaExperience() const; | 267 bool ShouldEnableEmbeddedMediaExperience() const; |
259 | 268 |
260 scoped_refptr<content::DevToolsAgentHost> GetDevToolsAgentHost(); | 269 scoped_refptr<content::DevToolsAgentHost> GetDevToolsAgentHost(); |
261 | 270 |
262 void SetDevToolsAgentHost(scoped_refptr<content::DevToolsAgentHost> host); | 271 void SetDevToolsAgentHost(scoped_refptr<content::DevToolsAgentHost> host); |
263 | 272 |
264 void AttachDetachedTab(JNIEnv* env, | 273 void AttachDetachedTab(JNIEnv* env, |
265 const base::android::JavaParamRef<jobject>& obj); | 274 const base::android::JavaParamRef<jobject>& obj); |
266 | 275 |
| 276 // Register the Tab's native methods through JNI. |
| 277 static bool RegisterTabAndroid(JNIEnv* env); |
| 278 |
| 279 // content::WebContents implementation. |
| 280 void OnInterfaceRequestFromFrame( |
| 281 content::RenderFrameHost* render_frame_host, |
| 282 const std::string& interface_name, |
| 283 mojo::ScopedMessagePipeHandle* interface_pipe) override; |
| 284 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 285 |
267 private: | 286 private: |
| 287 class MediaDownloadInProductHelp; |
| 288 |
268 prerender::PrerenderManager* GetPrerenderManager() const; | 289 prerender::PrerenderManager* GetPrerenderManager() const; |
269 | 290 |
| 291 // methods used by MediaDownloadInProductHelp. |
| 292 void CreateInProductHelpService( |
| 293 blink::mojom::MediaDownloadInProductHelpRequest request, |
| 294 content::RenderFrameHost* render_frame_host); |
| 295 void ShowMediaDownloadInProductHelp(const gfx::Rect& rect_in_frame); |
| 296 void DismissMediaDownloadInProductHelp(); |
| 297 void OnMediaDownloadInProductHelpConnectionError(); |
| 298 |
270 JavaObjectWeakGlobalRef weak_java_tab_; | 299 JavaObjectWeakGlobalRef weak_java_tab_; |
271 | 300 |
272 // The identifier used by session restore for this tab. | 301 // The identifier used by session restore for this tab. |
273 SessionID session_tab_id_; | 302 SessionID session_tab_id_; |
274 | 303 |
275 // Identifier of the window the tab is in. | 304 // Identifier of the window the tab is in. |
276 SessionID session_window_id_; | 305 SessionID session_window_id_; |
277 | 306 |
278 content::NotificationRegistrar notification_registrar_; | 307 content::NotificationRegistrar notification_registrar_; |
279 | 308 |
280 scoped_refptr<cc::Layer> content_layer_; | 309 scoped_refptr<cc::Layer> content_layer_; |
281 android::TabContentManager* tab_content_manager_; | 310 android::TabContentManager* tab_content_manager_; |
282 | 311 |
283 std::unique_ptr<content::WebContents> web_contents_; | 312 std::unique_ptr<content::WebContents> web_contents_; |
284 std::unique_ptr<android::TabWebContentsDelegateAndroid> | 313 std::unique_ptr<android::TabWebContentsDelegateAndroid> |
285 web_contents_delegate_; | 314 web_contents_delegate_; |
286 scoped_refptr<content::DevToolsAgentHost> devtools_host_; | 315 scoped_refptr<content::DevToolsAgentHost> devtools_host_; |
287 std::unique_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_; | 316 std::unique_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_; |
288 | 317 |
289 std::string webapp_manifest_scope_; | 318 std::string webapp_manifest_scope_; |
290 bool embedded_media_experience_enabled_; | 319 bool embedded_media_experience_enabled_; |
291 | 320 |
| 321 std::unique_ptr<MediaDownloadInProductHelp> media_in_product_help_; |
| 322 |
| 323 service_manager::BinderRegistryWithArgs<content::RenderFrameHost*> |
| 324 frame_interfaces_; |
| 325 |
| 326 base::WeakPtrFactory<TabAndroid> weak_factory_; |
| 327 |
292 DISALLOW_COPY_AND_ASSIGN(TabAndroid); | 328 DISALLOW_COPY_AND_ASSIGN(TabAndroid); |
293 }; | 329 }; |
294 | 330 |
295 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 331 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
OLD | NEW |