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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 251 |
247 const std::string& GetWebappManifestScope() const { | 252 const std::string& GetWebappManifestScope() const { |
248 return webapp_manifest_scope_; | 253 return webapp_manifest_scope_; |
249 } | 254 } |
250 | 255 |
251 void EnableEmbeddedMediaExperience( | 256 void EnableEmbeddedMediaExperience( |
252 JNIEnv* env, | 257 JNIEnv* env, |
253 const base::android::JavaParamRef<jobject>& obj, | 258 const base::android::JavaParamRef<jobject>& obj, |
254 jboolean enabled); | 259 jboolean enabled); |
255 | 260 |
| 261 void MediaDownloadInProductHelpDismissed( |
| 262 JNIEnv* env, |
| 263 const base::android::JavaParamRef<jobject>& obj); |
| 264 |
256 bool ShouldEnableEmbeddedMediaExperience() const; | 265 bool ShouldEnableEmbeddedMediaExperience() const; |
257 | 266 |
258 scoped_refptr<content::DevToolsAgentHost> GetDevToolsAgentHost(); | 267 scoped_refptr<content::DevToolsAgentHost> GetDevToolsAgentHost(); |
259 | 268 |
260 void SetDevToolsAgentHost(scoped_refptr<content::DevToolsAgentHost> host); | 269 void SetDevToolsAgentHost(scoped_refptr<content::DevToolsAgentHost> host); |
261 | 270 |
262 void AttachDetachedTab(JNIEnv* env, | 271 void AttachDetachedTab(JNIEnv* env, |
263 const base::android::JavaParamRef<jobject>& obj); | 272 const base::android::JavaParamRef<jobject>& obj); |
264 | 273 |
265 // Register the Tab's native methods through JNI. | 274 // Register the Tab's native methods through JNI. |
266 static bool RegisterTabAndroid(JNIEnv* env); | 275 static bool RegisterTabAndroid(JNIEnv* env); |
267 | 276 |
| 277 // content::WebContents implementation. |
| 278 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
| 279 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 280 |
268 private: | 281 private: |
| 282 class MediaDownloadInProductHelp; |
| 283 |
269 prerender::PrerenderManager* GetPrerenderManager() const; | 284 prerender::PrerenderManager* GetPrerenderManager() const; |
270 | 285 |
| 286 // methods used by MediaDownloadInProductHelp. |
| 287 void CreateInProductHelpService( |
| 288 content::RenderFrameHost* render_frame_host, |
| 289 const service_manager::BindSourceInfo& source_info, |
| 290 blink::mojom::MediaDownloadInProductHelpRequest request); |
| 291 void ShowMediaDownloadInProductHelp(const gfx::Rect& rect_in_frame); |
| 292 void DismissMediaDownloadInProductHelp(); |
| 293 void OnMediaDownloadInProductHelpConnectionError(); |
| 294 |
271 JavaObjectWeakGlobalRef weak_java_tab_; | 295 JavaObjectWeakGlobalRef weak_java_tab_; |
272 | 296 |
273 // The identifier used by session restore for this tab. | 297 // The identifier used by session restore for this tab. |
274 SessionID session_tab_id_; | 298 SessionID session_tab_id_; |
275 | 299 |
276 // Identifier of the window the tab is in. | 300 // Identifier of the window the tab is in. |
277 SessionID session_window_id_; | 301 SessionID session_window_id_; |
278 | 302 |
279 content::NotificationRegistrar notification_registrar_; | 303 content::NotificationRegistrar notification_registrar_; |
280 | 304 |
281 scoped_refptr<cc::Layer> content_layer_; | 305 scoped_refptr<cc::Layer> content_layer_; |
282 android::TabContentManager* tab_content_manager_; | 306 android::TabContentManager* tab_content_manager_; |
283 | 307 |
284 std::unique_ptr<content::WebContents> web_contents_; | 308 std::unique_ptr<content::WebContents> web_contents_; |
285 std::unique_ptr<android::TabWebContentsDelegateAndroid> | 309 std::unique_ptr<android::TabWebContentsDelegateAndroid> |
286 web_contents_delegate_; | 310 web_contents_delegate_; |
287 scoped_refptr<content::DevToolsAgentHost> devtools_host_; | 311 scoped_refptr<content::DevToolsAgentHost> devtools_host_; |
288 std::unique_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_; | 312 std::unique_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_; |
289 | 313 |
290 std::string webapp_manifest_scope_; | 314 std::string webapp_manifest_scope_; |
291 bool embedded_media_experience_enabled_; | 315 bool embedded_media_experience_enabled_; |
292 | 316 |
| 317 std::unique_ptr<MediaDownloadInProductHelp> media_in_product_help_; |
| 318 |
| 319 base::WeakPtrFactory<TabAndroid> weak_factory_; |
| 320 |
293 DISALLOW_COPY_AND_ASSIGN(TabAndroid); | 321 DISALLOW_COPY_AND_ASSIGN(TabAndroid); |
294 }; | 322 }; |
295 | 323 |
296 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 324 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
OLD | NEW |