Each page has a favicon, which is required for the history to be saved. In the content directory, this is not implemented.
Here's my implementation process:
There are methods in the web_contents_impl.cc file: Webcontentsimpl::onupdatefaviconurl
This method is the response method of browser process after the kernel resolves to favicon, after giving feedback to Chromium's browser process.
The implementation of this method is as follows:
For_each_observer (Webcontentsobserver, Observers_,
Didupdatefaviconurl (page_id, candidates));
The observer here is shell.cc.
I add the following method in shell.cc:
void Shell::D Idupdatefaviconurl (Int32 page_id,
Const std::vector<faviconurl>& candidates) {
Updatefaviconurl (page_id, candidates);
}
Then, add the following method in the shell_android.cc file:
void Shell::updatefaviconurl (Int32 page_id,
Const std::vector<faviconurl>& candidates) {
jnienv* env = Attachcurrentthread ();
Gurl Favicon_url = Candidates.back (). Icon_url;
scopedjavalocalref<jstring> J_favicon_url = base::android::convertutf8tojavastring (env, Favicon_url.spec ());
Return Java_shell_updateshellfaviconurl (env, Java_object_.obj (), j_favicon_url.obj ());
}
That way, Shell.java can get Faviicon.
@CalledByNative
private void Updateshellfaviconurl (String faviconurl) {
Mshellfaviconurl = Faviconurl;
}