Commit 2a107111 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Video Tutorials : Modularized JNI bridge

This CL moves the VideoTutorialServiceFactory and the JNI bridge into
the internal target. A corresponding public factory class is generated
from the internal factory using android_library_factory function. The
JNI function lives in video_tutorial_service_bridge_factory.cc which is
included in chrome/browser target while still living in
chrome/browser/video_tutorials/internal.

Bug: 1120097
Change-Id: I4cbc7e2763012e3780a28f58bf14e3374464e20e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368474Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801312}
parent 23e45e8d
...@@ -336,6 +336,7 @@ android_library("chrome_java") { ...@@ -336,6 +336,7 @@ android_library("chrome_java") {
"//chrome/browser/ui/android/native_page:java", "//chrome/browser/ui/android/native_page:java",
"//chrome/browser/ui/messages/android:java", "//chrome/browser/ui/messages/android:java",
"//chrome/browser/util:java", "//chrome/browser/util:java",
"//chrome/browser/video_tutorials:factory_java",
"//chrome/browser/video_tutorials:java", "//chrome/browser/video_tutorials:java",
"//chrome/browser/webauthn/android:java", "//chrome/browser/webauthn/android:java",
"//chrome/browser/xsurface:java", "//chrome/browser/xsurface:java",
...@@ -618,6 +619,7 @@ java_group("chrome_all_java") { ...@@ -618,6 +619,7 @@ java_group("chrome_all_java") {
"//chrome/browser/test_dummy/internal:base_module_java", "//chrome/browser/test_dummy/internal:base_module_java",
"//chrome/browser/touch_to_fill/android/internal:java", "//chrome/browser/touch_to_fill/android/internal:java",
"//chrome/browser/ui/android/appmenu/internal:java", "//chrome/browser/ui/android/appmenu/internal:java",
"//chrome/browser/video_tutorials/internal:java",
"//components/browser_ui/android/bottomsheet/internal:java", "//components/browser_ui/android/bottomsheet/internal:java",
] ]
...@@ -3163,7 +3165,6 @@ generate_jni("chrome_jni_headers") { ...@@ -3163,7 +3165,6 @@ generate_jni("chrome_jni_headers") {
"java/src/org/chromium/chrome/browser/translate/TranslateBridge.java", "java/src/org/chromium/chrome/browser/translate/TranslateBridge.java",
"java/src/org/chromium/chrome/browser/usage_stats/NotificationSuspender.java", "java/src/org/chromium/chrome/browser/usage_stats/NotificationSuspender.java",
"java/src/org/chromium/chrome/browser/usage_stats/UsageStatsBridge.java", "java/src/org/chromium/chrome/browser/usage_stats/UsageStatsBridge.java",
"java/src/org/chromium/chrome/browser/video_tutorials/VideoTutorialServiceFactory.java",
"java/src/org/chromium/chrome/browser/webapps/WebApkHandlerDelegate.java", "java/src/org/chromium/chrome/browser/webapps/WebApkHandlerDelegate.java",
"java/src/org/chromium/chrome/browser/webapps/WebApkInstallService.java", "java/src/org/chromium/chrome/browser/webapps/WebApkInstallService.java",
"java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java", "java/src/org/chromium/chrome/browser/webapps/WebApkInstaller.java",
......
...@@ -1669,7 +1669,6 @@ chrome_java_sources = [ ...@@ -1669,7 +1669,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/user_education/IPHCommand.java", "java/src/org/chromium/chrome/browser/user_education/IPHCommand.java",
"java/src/org/chromium/chrome/browser/user_education/IPHCommandBuilder.java", "java/src/org/chromium/chrome/browser/user_education/IPHCommandBuilder.java",
"java/src/org/chromium/chrome/browser/user_education/UserEducationHelper.java", "java/src/org/chromium/chrome/browser/user_education/UserEducationHelper.java",
"java/src/org/chromium/chrome/browser/video_tutorials/VideoTutorialServiceFactory.java",
"java/src/org/chromium/chrome/browser/vr/ArDelegate.java", "java/src/org/chromium/chrome/browser/vr/ArDelegate.java",
"java/src/org/chromium/chrome/browser/vr/ArDelegateProvider.java", "java/src/org/chromium/chrome/browser/vr/ArDelegateProvider.java",
"java/src/org/chromium/chrome/browser/webapps/ActivateWebApkActivity.java", "java/src/org/chromium/chrome/browser/webapps/ActivateWebApkActivity.java",
......
...@@ -2947,7 +2947,7 @@ static_library("browser") { ...@@ -2947,7 +2947,7 @@ static_library("browser") {
"updates/update_notification_client.h", "updates/update_notification_client.h",
"updates/update_notification_service_bridge_android.cc", "updates/update_notification_service_bridge_android.cc",
"updates/update_notification_service_bridge_android.h", "updates/update_notification_service_bridge_android.h",
"video_tutorials/android/video_tutorial_service_bridge_factory.cc", "video_tutorials/internal/android/video_tutorial_service_bridge_factory.cc",
"webauthn/android/cable_module_android.cc", "webauthn/android/cable_module_android.cc",
] ]
public_deps += [ public_deps += [
......
...@@ -5,12 +5,7 @@ ...@@ -5,12 +5,7 @@
if (is_android) { if (is_android) {
import("//build/config/android/config.gni") import("//build/config/android/config.gni")
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
} import("//chrome/android/features/android_library_factory_tmpl.gni")
if (is_android) {
java_group("java") {
deps = [ ":public_java" ]
}
} }
group("video_tutorials") { group("video_tutorials") {
...@@ -38,17 +33,6 @@ source_set("public") { ...@@ -38,17 +33,6 @@ source_set("public") {
"//components/keyed_service/core", "//components/keyed_service/core",
"//url:url", "//url:url",
] ]
if (is_android) {
sources += [
"android/tutorial_conversion_bridge.cc",
"android/tutorial_conversion_bridge.h",
"android/video_tutorial_service_bridge.cc",
"android/video_tutorial_service_bridge.h",
]
deps += [ ":jni_headers" ]
}
} }
source_set("factory") { source_set("factory") {
...@@ -66,33 +50,19 @@ source_set("factory") { ...@@ -66,33 +50,19 @@ source_set("factory") {
} }
if (is_android) { if (is_android) {
android_library("public_java") { android_library("java") {
sources = [ sources = [
"android/java/src/org/chromium/chrome/browser/video_tutorials/Tutorial.java", "android/java/src/org/chromium/chrome/browser/video_tutorials/Tutorial.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/VideoTutorialService.java", "android/java/src/org/chromium/chrome/browser/video_tutorials/VideoTutorialService.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/TutorialConversionBridge.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceBridge.java",
] ]
deps = [ deps = [
"//base:base_java", "//base:base_java",
"//base:jni_java",
"//components/browser_ui/widget/android:java", "//components/browser_ui/widget/android:java",
"//third_party/android_deps:androidx_annotation_annotation_java", "//third_party/android_deps:androidx_annotation_annotation_java",
] ]
srcjar_deps = [ ":jni_enums" ] srcjar_deps = [ ":jni_enums" ]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
}
generate_jni("jni_headers") {
visibility = [ ":*" ]
sources = [
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/TutorialConversionBridge.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceBridge.java",
]
} }
java_cpp_enum("jni_enums") { java_cpp_enum("jni_enums") {
...@@ -100,6 +70,18 @@ if (is_android) { ...@@ -100,6 +70,18 @@ if (is_android) {
sources = [ "tutorial.h" ] sources = [ "tutorial.h" ]
} }
android_library_factory("factory_java") {
# These deps will be inherited by the resulting android_library target.
deps = [
":java",
"//chrome/browser/profiles/android:java",
]
# This internal file will be replaced by a generated file so the resulting
# android_library target does not actually depend on this internal file.
sources = [ "internal/android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceFactory.java" ]
}
} }
group("unit_tests") { group("unit_tests") {
......
...@@ -23,6 +23,52 @@ source_set("internal") { ...@@ -23,6 +23,52 @@ source_set("internal") {
"//chrome/browser/video_tutorials/proto", "//chrome/browser/video_tutorials/proto",
"//components/leveldb_proto", "//components/leveldb_proto",
] ]
if (is_android) {
sources += [
"android/tutorial_conversion_bridge.cc",
"android/tutorial_conversion_bridge.h",
"android/video_tutorial_service_bridge.cc",
"android/video_tutorial_service_bridge.h",
]
deps += [ ":jni_headers" ]
}
}
if (is_android) {
android_library("java") {
visibility = [
":*",
"//chrome/android:chrome_all_java",
]
sources = [
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/TutorialConversionBridge.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceBridge.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceFactory.java",
]
deps = [
"//base:base_java",
"//base:jni_java",
"//chrome/browser/profiles/android:java",
"//chrome/browser/video_tutorials:java",
"//third_party/android_deps:androidx_annotation_annotation_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
}
generate_jni("jni_headers") {
visibility = [ ":*" ]
sources = [
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/TutorialConversionBridge.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceBridge.java",
"android/java/src/org/chromium/chrome/browser/video_tutorials/bridges/VideoTutorialServiceFactory.java",
]
}
} }
source_set("unit_tests") { source_set("unit_tests") {
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.video_tutorials; package org.chromium.chrome.browser.video_tutorials.bridges;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.video_tutorials.VideoTutorialService;
/** /**
* Basic factory that creates and returns an {@link VideoTutorialService} that is attached * Basic factory that creates and returns an {@link VideoTutorialService} that is attached
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/video_tutorials/android/tutorial_conversion_bridge.h" #include "chrome/browser/video_tutorials/internal/android/tutorial_conversion_bridge.h"
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/android/jni_array.h" #include "base/android/jni_array.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "chrome/browser/video_tutorials/jni_headers/TutorialConversionBridge_jni.h" #include "chrome/browser/video_tutorials/internal/jni_headers/TutorialConversionBridge_jni.h"
namespace video_tutorials { namespace video_tutorials {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_VIDEO_TUTORIALS_ANDROID_TUTORIAL_CONVERSION_BRIDGE_H_ #ifndef CHROME_BROWSER_VIDEO_TUTORIALS_INTERNAL_ANDROID_TUTORIAL_CONVERSION_BRIDGE_H_
#define CHROME_BROWSER_VIDEO_TUTORIALS_ANDROID_TUTORIAL_CONVERSION_BRIDGE_H_ #define CHROME_BROWSER_VIDEO_TUTORIALS_INTERNAL_ANDROID_TUTORIAL_CONVERSION_BRIDGE_H_
#include <vector> #include <vector>
...@@ -25,4 +25,4 @@ class TutorialConversionBridge { ...@@ -25,4 +25,4 @@ class TutorialConversionBridge {
} // namespace video_tutorials } // namespace video_tutorials
#endif // CHROME_BROWSER_VIDEO_TUTORIALS_ANDROID_TUTORIAL_CONVERSION_BRIDGE_H_ #endif // CHROME_BROWSER_VIDEO_TUTORIALS_INTERNAL_ANDROID_TUTORIAL_CONVERSION_BRIDGE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/video_tutorials/android/video_tutorial_service_bridge.h" #include "chrome/browser/video_tutorials/internal/android/video_tutorial_service_bridge.h"
#include <memory> #include <memory>
#include <vector> #include <vector>
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_VIDEO_TUTORIALS_ANDROID_VIDEO_TUTORIAL_SERVICE_BRIDGE_H_ #ifndef CHROME_BROWSER_VIDEO_TUTORIALS_INTERNAL_ANDROID_VIDEO_TUTORIAL_SERVICE_BRIDGE_H_
#define CHROME_BROWSER_VIDEO_TUTORIALS_ANDROID_VIDEO_TUTORIAL_SERVICE_BRIDGE_H_ #define CHROME_BROWSER_VIDEO_TUTORIALS_INTERNAL_ANDROID_VIDEO_TUTORIAL_SERVICE_BRIDGE_H_
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
...@@ -42,4 +42,4 @@ class VideoTutorialServiceBridge : public base::SupportsUserData::Data { ...@@ -42,4 +42,4 @@ class VideoTutorialServiceBridge : public base::SupportsUserData::Data {
} // namespace video_tutorials } // namespace video_tutorials
#endif // CHROME_BROWSER_VIDEO_TUTORIALS_ANDROID_VIDEO_TUTORIAL_SERVICE_BRIDGE_H_ #endif // CHROME_BROWSER_VIDEO_TUTORIALS_INTERNAL_ANDROID_VIDEO_TUTORIAL_SERVICE_BRIDGE_H_
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "chrome/android/chrome_jni_headers/VideoTutorialServiceFactory_jni.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/video_tutorials/android/video_tutorial_service_bridge.h" #include "chrome/browser/video_tutorials/internal/android/video_tutorial_service_bridge.h"
#include "chrome/browser/video_tutorials/internal/jni_headers/VideoTutorialServiceFactory_jni.h"
#include "chrome/browser/video_tutorials/video_tutorial_service_factory.h" #include "chrome/browser/video_tutorials/video_tutorial_service_factory.h"
// Takes a Java Profile and returns a Java VideoTutorialService. // Takes a Java Profile and returns a Java VideoTutorialService.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment