Skip to content
Permalink
Browse files

[WebLayer M79] Merge weblayer changes since f1f38b7

his merges all changes that touched the weblayer/ directory since
f1f38b7. http://crrev.com/c/1890984 was
not merged since it changes a lot of code outside weblayer/. If this is
needed, it can be merged separately.

Bug: 1023618
Change-Id: I89a2e5ba7382696fdf57bf4ec707005f8fd115bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1910799
Reviewed-by: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/branch-heads/3945@{#639}
Cr-Branched-From: e4635ff-refs/heads/master@{#706915}
  • Loading branch information
clarkduvall committed Nov 14, 2019
1 parent 00b1dae commit c61d085800466a358a5d077685cd4c6338fa78de
Showing with 3,752 additions and 1,635 deletions.
  1. +3 −3 PRESUBMIT.py
  2. +1 −0 android_webview/variables.gni
  3. +1 −0 build/android/pylib/gtest/gtest_test_instance.py
  4. +1 −7 content/browser/frame_host/render_frame_host_impl.cc
  5. +2 −4 content/public/browser/render_frame_host.h
  6. +10 −7 weblayer/BUILD.gn
  7. +1 −1 weblayer/LAST_MERGED_REVISION
  8. +1 −1 weblayer/PRESUBMIT.py
  9. +8 −0 weblayer/README.md
  10. +0 −51 weblayer/browser/browser_callback_proxy.cc
  11. +0 −39 weblayer/browser/browser_callback_proxy.h
  12. +6 −9 weblayer/browser/content_browser_client_impl.cc
  13. +8 −12 weblayer/browser/download_callback_proxy.cc
  14. +3 −5 weblayer/browser/download_callback_proxy.h
  15. +10 −12 weblayer/browser/fullscreen_callback_proxy.cc
  16. +4 −6 weblayer/browser/fullscreen_callback_proxy.h
  17. +44 −35 weblayer/browser/java/BUILD.gn
  18. +63 −0 weblayer/browser/java/org/chromium/weblayer_private/ActionModeCallback.java
  19. +0 −45 weblayer/browser/java/org/chromium/weblayer_private/BrowserCallbackProxy.java
  20. +0 −149 weblayer/browser/java/org/chromium/weblayer_private/BrowserFragmentControllerImpl.java
  21. +22 −22 weblayer/browser/java/org/chromium/weblayer_private/BrowserFragmentImpl.java
  22. +192 −0 weblayer/browser/java/org/chromium/weblayer_private/BrowserImpl.java
  23. +21 −19 ...a/org/chromium/weblayer_private/{BrowserFragmentViewController.java → BrowserViewController.java}
  24. +3 −3 weblayer/browser/java/org/chromium/weblayer_private/ChildProcessServiceImpl.java
  25. +16 −6 weblayer/browser/java/org/chromium/weblayer_private/ContentView.java
  26. +88 −34 weblayer/browser/java/org/chromium/weblayer_private/ContentViewRenderView.java
  27. +4 −4 weblayer/browser/java/org/chromium/weblayer_private/DownloadCallbackProxy.java
  28. +5 −6 weblayer/browser/java/org/chromium/weblayer_private/FullscreenCallbackProxy.java
  29. +8 −9 weblayer/browser/java/org/chromium/weblayer_private/NavigationControllerImpl.java
  30. +64 −7 weblayer/browser/java/org/chromium/weblayer_private/NavigationImpl.java
  31. +65 −0 weblayer/browser/java/org/chromium/weblayer_private/NewTabCallbackProxy.java
  32. +4 −4 weblayer/browser/java/org/chromium/weblayer_private/ProfileImpl.java
  33. +5 −5 weblayer/browser/java/org/chromium/weblayer_private/RemoteFragmentImpl.java
  34. +44 −0 weblayer/browser/java/org/chromium/weblayer_private/TabCallbackProxy.java
  35. +106 −64 weblayer/browser/java/org/chromium/weblayer_private/{BrowserControllerImpl.java → TabImpl.java}
  36. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/TopControlsContainerView.java
  37. +55 −15 weblayer/browser/java/org/chromium/weblayer_private/WebLayerImpl.java
  38. +0 −22 weblayer/browser/java/org/chromium/weblayer_private/aidl/IBrowserController.aidl
  39. +0 −13 weblayer/browser/java/org/chromium/weblayer_private/aidl/IBrowserControllerClient.aidl
  40. +0 −19 weblayer/browser/java/org/chromium/weblayer_private/aidl/IBrowserFragmentController.aidl
  41. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/APICallException.java
  42. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/BrowserFragmentArgs.java
  43. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/BrowsingDataType.java
  44. +33 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/IBrowser.aidl
  45. +13 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/IBrowserClient.aidl
  46. +4 −4 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IBrowserFragment.aidl
  47. +3 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IChildProcessService.aidl
  48. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IClientNavigation.aidl
  49. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IDownloadCallbackClient.aidl
  50. +2 −2 ...yer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IFullscreenCallbackClient.aidl
  51. +5 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/INavigation.aidl
  52. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/INavigationController.aidl
  53. +4 −1 ...r/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/INavigationControllerClient.aidl
  54. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IObjectWrapper.aidl
  55. +3 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IProfile.aidl
  56. +2 −2 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IRemoteFragment.aidl
  57. +3 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IRemoteFragmentClient.aidl
  58. +31 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/ITab.aidl
  59. +15 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/ITabClient.aidl
  60. +6 −8 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/IWebLayer.aidl
  61. +22 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/LoadError.java
  62. +20 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/NavigationState.java
  63. +20 −0 weblayer/browser/java/org/chromium/weblayer_private/interfaces/NewTabType.java
  64. +1 −1 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/ObjectWrapper.java
  65. +2 −2 weblayer/browser/java/org/chromium/weblayer_private/{aidl → interfaces}/WebLayerVersion.java
  66. +137 −0 weblayer/browser/navigation_browsertest.cc
  67. +6 −9 weblayer/browser/navigation_controller_impl.cc
  68. +2 −2 weblayer/browser/navigation_controller_impl.h
  69. +30 −3 weblayer/browser/navigation_impl.cc
  70. +12 −2 weblayer/browser/navigation_impl.h
  71. +49 −0 weblayer/browser/new_tab_callback_proxy.cc
  72. +37 −0 weblayer/browser/new_tab_callback_proxy.h
  73. +4 −4 weblayer/browser/profile_impl.cc
  74. +6 −0 weblayer/browser/safe_browsing/safe_browsing_service.cc
  75. +4 −0 weblayer/browser/safe_browsing/safe_browsing_service.h
  76. +6 −1 weblayer/browser/safe_browsing/url_checker_delegate_impl.cc
  77. +111 −0 weblayer/browser/ssl_browsertest.cc
  78. +47 −0 weblayer/browser/tab_callback_proxy.cc
  79. +37 −0 weblayer/browser/tab_callback_proxy.h
  80. +93 −88 weblayer/browser/{browser_controller_impl.cc → tab_impl.cc}
  81. +30 −30 weblayer/browser/{browser_controller_impl.h → tab_impl.h}
  82. +2 −1 weblayer/browser/webui/webui_browsertest.cc
  83. +9 −8 weblayer/public/java/BUILD.gn
  84. +277 −0 weblayer/public/java/org/chromium/weblayer/Browser.java
  85. +21 −21 weblayer/public/java/org/chromium/weblayer/BrowserFragment.java
  86. +0 −114 weblayer/public/java/org/chromium/weblayer/BrowserFragmentController.java
  87. +5 −2 weblayer/public/java/org/chromium/weblayer/BrowsingDataType.java
  88. +3 −3 weblayer/public/java/org/chromium/weblayer/ChildProcessService.java
  89. +1 −1 weblayer/public/java/org/chromium/weblayer/DownloadCallback.java
  90. +2 −2 weblayer/public/java/org/chromium/weblayer/FullscreenCallback.java
  91. +44 −0 weblayer/public/java/org/chromium/weblayer/LoadError.java
  92. +33 −27 weblayer/public/java/org/chromium/weblayer/Navigation.java
  93. +15 −15 weblayer/public/java/org/chromium/weblayer/NavigationCallback.java
  94. +16 −17 weblayer/public/java/org/chromium/weblayer/NavigationController.java
  95. +26 −0 weblayer/public/java/org/chromium/weblayer/NavigationState.java
  96. +15 −0 weblayer/public/java/org/chromium/weblayer/NewTabCallback.java
  97. +41 −0 weblayer/public/java/org/chromium/weblayer/NewTabType.java
  98. +3 −3 weblayer/public/java/org/chromium/weblayer/Profile.java
  99. +109 −30 weblayer/public/java/org/chromium/weblayer/{BrowserController.java → Tab.java}
  100. +3 −3 weblayer/public/java/org/chromium/weblayer/{BrowserCallback.java → TabCallback.java}
  101. +34 −0 weblayer/public/java/org/chromium/weblayer/TabListCallback.java
  102. +102 −62 weblayer/public/java/org/chromium/weblayer/WebLayer.java
  103. +16 −0 weblayer/public/javatests/BUILD.gn
  104. +332 −0 weblayer/public/javatests/org/chromium/weblayer/ObserverListTest.java
  105. +32 −10 weblayer/public/navigation.h
  106. +8 −8 weblayer/public/navigation_observer.h
  107. +12 −10 weblayer/public/{new_browser_delegate.h → new_tab_delegate.h}
  108. +22 −13 weblayer/public/{browser_controller.h → tab.h}
  109. +7 −6 weblayer/public/{browser_observer.h → tab_observer.h}
  110. +22 −31 weblayer/shell/android/BUILD.gn
  111. +11 −11 ...oid/browsertests_apk/src/org/chromium/weblayer_browsertests_apk/WebLayerBrowserTestsActivity.java
  112. +7 −10 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/BrowserFragmentLifecycleTest.java
  113. +5 −7 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/DataClearingTest.java
  114. +5 −17 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/DownloadCallbackTest.java
  115. +26 −13 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/ExecuteScriptTest.java
  116. +40 −0 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/FragmentRestoreTest.java
  117. +5 −20 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/FullscreenCallbackTest.java
  118. +5 −12 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/InputTypesTest.java
  119. +41 −19 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/InstrumentationActivityTestRule.java
  120. +144 −24 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NavigationTest.java
  121. +32 −0 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NewTabCallbackImpl.java
  122. +51 −0 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NewTabCallbackTest.java
  123. +1 −1 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/ProfileTest.java
  124. +15 −20 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/RenderingTest.java
  125. +40 −6 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/SmokeTest.java
  126. +8 −9 ...ndroid/javatests/src/org/chromium/weblayer/test/{BrowserCallbackTest.java → TabCallbackTest.java}
  127. +151 −0 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/TabListCallbackTest.java
  128. +9 −21 weblayer/shell/android/javatests/src/org/chromium/weblayer/test/TopControlsTest.java
  129. +4 −2 weblayer/shell/android/shell_apk/AndroidManifest.xml
  130. +21 −17 weblayer/shell/android/shell_apk/src/org/chromium/weblayer/shell/InstrumentationActivity.java
  131. +30 −32 weblayer/shell/android/shell_apk/src/org/chromium/weblayer/shell/WebLayerShellActivity.java
  132. +3 −0 weblayer/shell/app/shell_main_params.cc
  133. +24 −26 weblayer/shell/browser/shell.cc
  134. +9 −10 weblayer/shell/browser/shell.h
  135. +4 −6 weblayer/shell/browser/shell_views.cc
  136. +3 −0 weblayer/shell/common/shell_switches.cc
  137. +1 −0 weblayer/shell/common/shell_switches.h
  138. +8 −1 weblayer/test/BUILD.gn
  139. +10 −0 weblayer/test/data/new_browser.html
  140. +10 −11 weblayer/test/interstitial_utils.cc
  141. +5 −5 weblayer/test/interstitial_utils.h
  142. +0 −62 weblayer/test/ssl_browsertest.cc
  143. +54 −0 weblayer/test/test_navigation_observer.cc
  144. +54 −0 weblayer/test/test_navigation_observer.h
  145. +2 −0 weblayer/test/weblayer_browser_test.cc
  146. +17 −76 weblayer/test/weblayer_browser_test_utils.cc
  147. +3 −1 weblayer/test/weblayer_browser_test_utils.h
  148. +6 −0 weblayer/tools/run_weblayer_shell.py
@@ -2831,9 +2831,9 @@ def _GetOwnersFilesToCheckForIpcOwners(input_api):
'third_party/protobuf/benchmarks/python/*',
'third_party/third_party/blink/renderer/platform/bindings/*',
'third_party/win_build_output/*',
# These aidl files are just used to communicate between class loaders
# running in the same process.
'weblayer/browser/java/org/chromium/weblayer_private/aidl/*',
# These files are just used to communicate between class loaders running
# in the same process.
'weblayer/browser/java/org/chromium/weblayer_private/interfaces/*',
]

# Dictionary mapping an OWNERS file path to Patterns.
@@ -10,6 +10,7 @@ trichrome_webview_android_manifest =
upstream_only_webview_deps = [
"//android_webview:platform_service_bridge_upstream_implementation_java",
"//android_webview:system_webview_resources",
"//weblayer/browser/java:gms_bridge_upstream_impl_java",
]

webview_locale_config_java_package = "org.chromium.android_webview"
@@ -26,6 +26,7 @@
'android_browsertests',
'components_browsertests',
'content_browsertests',
'weblayer_browsertests',
]

RUN_IN_SUB_THREAD_TEST_SUITES = [
@@ -241,11 +241,9 @@ const void* const kRenderFrameHostAndroidKey = &kRenderFrameHostAndroidKey;
// The next value to use for the accessibility reset token.
int g_next_accessibility_reset_token = 1;

#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(IS_CHROMECAST)
// Whether to allow injecting javascript into any kind of frame, for Android
// WebView, Fuchsia web.ContextProvider and CastOS content shell.
// WebView, WebLayer, Fuchsia web.ContextProvider and CastOS content shell.
bool g_allow_injecting_javascript = false;
#endif

typedef std::unordered_map<GlobalFrameRoutingId,
RenderFrameHostImpl*,
@@ -797,12 +795,10 @@ RenderFrameHost* RenderFrameHost::FromID(int render_process_id,
GlobalFrameRoutingId(render_process_id, render_frame_id));
}

#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(IS_CHROMECAST)
// static
void RenderFrameHost::AllowInjectingJavaScript() {
g_allow_injecting_javascript = true;
}
#endif // defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(IS_CHROMECAST)

// static
RenderFrameHostImpl* RenderFrameHostImpl::FromID(int render_process_id,
@@ -6233,10 +6229,8 @@ bool RenderFrameHostImpl::CreateNetworkServiceDefaultFactoryInternal(
}

bool RenderFrameHostImpl::CanExecuteJavaScript() {
#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(IS_CHROMECAST)
if (g_allow_injecting_javascript)
return true;
#endif
return !frame_tree_node_->current_url().is_valid() ||
frame_tree_node_->current_url().SchemeIs(kChromeDevToolsScheme) ||
ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
@@ -79,12 +79,10 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
// Returns nullptr if the IDs do not correspond to a live RenderFrameHost.
static RenderFrameHost* FromID(int render_process_id, int render_frame_id);

#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(IS_CHROMECAST)
// Globally allows for injecting JavaScript into the main world. This feature
// is present only to support Android WebView, Fuchsia web.Contexts, and
// CastOS content shell. It must not be used in other configurations.
// is present only to support Android WebView, WebLayer, Fuchsia web.Contexts,
// and CastOS content shell. It must not be used in other configurations.
static void AllowInjectingJavaScript();
#endif

// Returns a RenderFrameHost given its accessibility tree ID.
static RenderFrameHost* FromAXTreeID(ui::AXTreeID ax_tree_id);
@@ -38,8 +38,6 @@ jumbo_static_library("weblayer_lib") {
"app/content_main_delegate_impl.cc",
"app/content_main_delegate_impl.h",
"app/main.cc",
"browser/browser_controller_impl.cc",
"browser/browser_controller_impl.h",
"browser/browser_main_parts_impl.cc",
"browser/browser_main_parts_impl.h",
"browser/content_browser_client_impl.cc",
@@ -59,6 +57,8 @@ jumbo_static_library("weblayer_lib") {
"browser/ssl_error_handler.h",
"browser/ssl_host_state_delegate_impl.cc",
"browser/ssl_host_state_delegate_impl.h",
"browser/tab_impl.cc",
"browser/tab_impl.h",
"browser/weblayer_content_browser_overlay_manifest.cc",
"browser/weblayer_content_browser_overlay_manifest.h",
"browser/webui/web_ui_controller_factory.cc",
@@ -71,16 +71,16 @@ jumbo_static_library("weblayer_lib") {
"common/features.h",
"common/weblayer_paths.cc",
"common/weblayer_paths.h",
"public/browser_controller.h",
"public/browser_observer.h",
"public/download_delegate.h",
"public/fullscreen_delegate.h",
"public/main.h",
"public/navigation.h",
"public/navigation_controller.h",
"public/navigation_observer.h",
"public/new_browser_delegate.h",
"public/new_tab_delegate.h",
"public/profile.h",
"public/tab.h",
"public/tab_observer.h",
"renderer/content_renderer_client_impl.cc",
"renderer/content_renderer_client_impl.h",
"renderer/ssl_error_helper.cc",
@@ -169,6 +169,7 @@ jumbo_static_library("weblayer_lib") {
"//components/crash/android:crashpad_main",
"//components/safe_browsing",
"//components/safe_browsing/android:remote_database_manager",
"//components/safe_browsing/android:safe_browsing_api_handler",
"//components/safe_browsing/browser",
"//components/safe_browsing/browser:network_context",
"//components/safe_browsing/db:database_manager",
@@ -210,14 +211,16 @@ jumbo_static_library("weblayer_lib") {
sources += [
"app/jni_onload.cc",
"app/jni_onload.h",
"browser/browser_callback_proxy.cc",
"browser/browser_callback_proxy.h",
"browser/content_view_render_view.cc",
"browser/content_view_render_view.h",
"browser/download_callback_proxy.cc",
"browser/download_callback_proxy.h",
"browser/fullscreen_callback_proxy.cc",
"browser/fullscreen_callback_proxy.h",
"browser/new_tab_callback_proxy.cc",
"browser/new_tab_callback_proxy.h",
"browser/tab_callback_proxy.cc",
"browser/tab_callback_proxy.h",
"browser/top_controls_container_view.cc",
"browser/top_controls_container_view.h",
]
@@ -1 +1 @@
f1f38b7457ea082250c2a1bfef26b7e738535370
92763f8044de2849ff587d8bffb8e620abf33331
@@ -9,7 +9,7 @@
import re

WEBLAYER_VERSION_PATH = (
'weblayer/browser/java/org/chromium/weblayer_private/aidl/' +
'weblayer/browser/java/org/chromium/weblayer_private/interfaces/' +
'WebLayerVersion.java')


@@ -23,12 +23,20 @@ Bug tracker: [Internals>WebLayer](https://bugs.chromium.org/p/chromium/issues/li

`shell` sample app

'test' test harnesses and test-only helper code

'tools' helper scripts

'app' internal code which runs at the beginning of each process

`browser` internal code which runs in the browser process

`common` internal code which runs in the browser and child processes

`renderer` internal code which runs in the renderer process

`utility` internal code which runs in the utility process

## Setting Up Your Build Environment

If you haven't done this already, you first need to set up an Android build. If

This file was deleted.

This file was deleted.

@@ -29,9 +29,9 @@
#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "weblayer/browser/browser_controller_impl.h"
#include "weblayer/browser/browser_main_parts_impl.h"
#include "weblayer/browser/ssl_error_handler.h"
#include "weblayer/browser/tab_impl.h"
#include "weblayer/browser/weblayer_content_browser_overlay_manifest.h"
#include "weblayer/common/features.h"
#include "weblayer/public/fullscreen_delegate.h"
@@ -141,10 +141,8 @@ void ContentBrowserClientImpl::OverrideWebkitPrefs(
content::WebContents::FromRenderViewHost(render_view_host);
if (!web_contents)
return;
BrowserControllerImpl* browser_controller =
BrowserControllerImpl::FromWebContents(web_contents);
prefs->fullscreen_supported =
browser_controller && browser_controller->fullscreen_delegate();
TabImpl* tab = TabImpl::FromWebContents(web_contents);
prefs->fullscreen_supported = tab && tab->fullscreen_delegate();
}

mojo::Remote<network::mojom::NetworkContext>
@@ -223,10 +221,9 @@ bool ContentBrowserClientImpl::CanCreateWindow(
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(opener);

// Block popups if there is no NewBrowserDelegate.
BrowserControllerImpl* browser =
BrowserControllerImpl::FromWebContents(web_contents);
if (!browser || !browser->has_new_browser_delegate())
// Block popups if there is no NewTabDelegate.
TabImpl* tab = TabImpl::FromWebContents(web_contents);
if (!tab || !tab->has_new_tab_delegate())
return false;

if (container_type == content::mojom::WindowContainerType::BACKGROUND) {
@@ -6,25 +6,22 @@

#include "base/android/jni_string.h"
#include "url/gurl.h"
#include "weblayer/browser/browser_controller_impl.h"
#include "weblayer/browser/java/jni/DownloadCallbackProxy_jni.h"
#include "weblayer/browser/tab_impl.h"

using base::android::AttachCurrentThread;
using base::android::ConvertUTF8ToJavaString;
using base::android::ScopedJavaLocalRef;

namespace weblayer {

DownloadCallbackProxy::DownloadCallbackProxy(
JNIEnv* env,
jobject obj,
BrowserController* browser_controller)
: browser_controller_(browser_controller), java_delegate_(env, obj) {
browser_controller_->SetDownloadDelegate(this);
DownloadCallbackProxy::DownloadCallbackProxy(JNIEnv* env, jobject obj, Tab* tab)
: tab_(tab), java_delegate_(env, obj) {
tab_->SetDownloadDelegate(this);
}

DownloadCallbackProxy::~DownloadCallbackProxy() {
browser_controller_->SetDownloadDelegate(nullptr);
tab_->SetDownloadDelegate(nullptr);
}

void DownloadCallbackProxy::DownloadRequested(
@@ -50,10 +47,9 @@ void DownloadCallbackProxy::DownloadRequested(
static jlong JNI_DownloadCallbackProxy_CreateDownloadCallbackProxy(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& proxy,
jlong browser_controller) {
return reinterpret_cast<jlong>(new DownloadCallbackProxy(
env, proxy,
reinterpret_cast<BrowserControllerImpl*>(browser_controller)));
jlong tab) {
return reinterpret_cast<jlong>(
new DownloadCallbackProxy(env, proxy, reinterpret_cast<TabImpl*>(tab)));
}

static void JNI_DownloadCallbackProxy_DeleteDownloadCallbackProxy(JNIEnv* env,
@@ -14,14 +14,12 @@

namespace weblayer {

class BrowserController;
class Tab;

// Forwards DownloadDelegate calls to the java-side DownloadCallbackProxy.
class DownloadCallbackProxy : public DownloadDelegate {
public:
DownloadCallbackProxy(JNIEnv* env,
jobject obj,
BrowserController* browser_controller);
DownloadCallbackProxy(JNIEnv* env, jobject obj, Tab* tab);
~DownloadCallbackProxy() override;

// DownloadDelegate:
@@ -32,7 +30,7 @@ class DownloadCallbackProxy : public DownloadDelegate {
int64_t content_length) override;

private:
BrowserController* browser_controller_;
Tab* tab_;
base::android::ScopedJavaGlobalRef<jobject> java_delegate_;

DISALLOW_COPY_AND_ASSIGN(DownloadCallbackProxy);

0 comments on commit c61d085

Please sign in to comment.
You can’t perform that action at this time.