-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Create module bridge for Telemetry API Client #4
base: tt135/develop
Are you sure you want to change the base?
[Android] Create module bridge for Telemetry API Client #4
Conversation
std::string profile_id = profile_->UniqueId(); | ||
dict.Set("v", profile_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly copy paste from cs_handler.cc
but set the unique ID from Profile
derived from BrowserContext
.
|
||
using web_request_helper::WebRequestResult; | ||
|
||
class CSApiClientService : public KeyedService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be a KeyedService
so that it can get BrowserContext
required to retrieve the unique ID. So, I cannot reuse the existing cs_api_client.cc
.
return instance.get(); | ||
} | ||
|
||
CSApiClientServiceFactory::CSApiClientServiceFactory() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the example of start_suggest_service_factory.cc
.
void CSApiClientModuleBridge::Handle( | ||
JNIEnv* env, | ||
const JavaParamRef<jobject>& obj, | ||
const JavaParamRef<jstring>& url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly copy paste from cs_handler.cc
but accept Java String as parameter. C++ GURL
and Java GURL
don't seem to be interoperable.
generate_jni("jni_headers") { | ||
sources = [ "java/src/org/chromium/chrome/browser/cs/CSApiClientModuleBridge.java" ] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autogenerated at out/Default/gen/jni_headers/chrome/browser/cs/android/CSApiClientModuleBridge_jni.h
.
@@ -275,6 +275,7 @@ | |||
#include "chrome/browser/android/webapk/webapk_sync_service_factory.h" | |||
#include "chrome/browser/auxiliary_search/auxiliary_search_provider.h" | |||
#include "chrome/browser/commerce/merchant_viewer/merchant_viewer_data_manager_factory.h" | |||
#include "chrome/browser/cs/android/cs_api_client_service_factory.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to get Service
class instance from Factory
within Profile
a.k.a BrowserContext
, this has to be included.
CSApiClientModuleBridge csApiClientModuleBridge = | ||
new CSApiClientModuleBridge(tab.getProfile()); | ||
csApiClientModuleBridge.handle(url.getSpec()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the place for listening to every URL load. There are other specific areas which invokes loadUrl
and onLoadUrl
etc. but are not universally triggered.
Although Chromium Android will be frozen for awhile, I think this PR is safe to merge because it does not affect the web client build, except perhaps the initial Ninja build taking some time to compile the Android files. I am just afraid that there might be conflicts to resolve if I leave this PR unmerged for weeks and months. Please take a look whenever you have the time! |
Hey @benedict-lim-ahrefs, Given that the Chromium Android project is currently on hold, I would recommend leaving the PR open instead of merging it into |
Or you create your own branch out of |
I see... That is a valid concern. In that case, I am fine to keep the PR open until further notice, and I will resolve the conflicts with the upstream branch when I return to the project. Since I will not develop more features for Android, I will not create an |
Background
Integrate telemetry API interface in Java for the Android Client
Details
Research notes