[bookmarks] Add bookmark_id to relevant navigations on Android

* Add a NavigationUIData member to UrlLoadParams which allows
  ui-data to be passed through the content layer.
* NavigationUIData is implemented as ChromeNavigationUIData which
  constructs a native object and passes it through java.

Bug: 1320950
Change-Id: I1951c8cd92e6614cd893570cb45a7b4907193b61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3682190
Reviewed-by: David Trainor <[email protected]>
Commit-Queue: Brandon Wylie <[email protected]>
Reviewed-by: Michael Thiessen <[email protected]>
Reviewed-by: Bo Liu <[email protected]>
Reviewed-by: bttk - <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1028472}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 8cc3f76..23962fe8 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -2796,6 +2796,7 @@
       "android/reading_list/reading_list_notification_service_factory.h",
       "android/recently_closed_tabs_bridge.cc",
       "android/recently_closed_tabs_bridge.h",
+      "android/renderer_host/chrome_navigation_ui_data_android.cc",
       "android/reparenting_task.cc",
       "android/resource_id.h",
       "android/resource_mapper.cc",
diff --git a/chrome/browser/android/renderer_host/DEPS b/chrome/browser/android/renderer_host/DEPS
new file mode 100644
index 0000000..5f805d3
--- /dev/null
+++ b/chrome/browser/android/renderer_host/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+    "+content/browser/android",
+]
\ No newline at end of file
diff --git a/chrome/browser/android/renderer_host/chrome_navigation_ui_data_android.cc b/chrome/browser/android/renderer_host/chrome_navigation_ui_data_android.cc
new file mode 100644
index 0000000..e072128
--- /dev/null
+++ b/chrome/browser/android/renderer_host/chrome_navigation_ui_data_android.cc
@@ -0,0 +1,18 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/android/jni_android.h"
+#include "chrome/android/chrome_jni_headers/ChromeNavigationUIData_jni.h"
+#include "chrome/browser/renderer_host/chrome_navigation_ui_data.h"
+#include "content/public/browser/navigation_ui_data.h"
+
+static jlong JNI_ChromeNavigationUIData_CreateUnownedNativeCopy(
+    JNIEnv* env,
+    const base::android::JavaParamRef<jobject>& obj,
+    jlong bookmark_id) {
+  ChromeNavigationUIData* ui_data = new ChromeNavigationUIData();
+  ui_data->set_bookmark_id(bookmark_id);
+  return reinterpret_cast<intptr_t>(
+      static_cast<content::NavigationUIData*>(ui_data));
+}
diff --git a/chrome/browser/renderer_host/chrome_navigation_ui_data.cc b/chrome/browser/renderer_host/chrome_navigation_ui_data.cc
index 517b4ea..c0a50f5 100644
--- a/chrome/browser/renderer_host/chrome_navigation_ui_data.cc
+++ b/chrome/browser/renderer_host/chrome_navigation_ui_data.cc
@@ -94,6 +94,7 @@
 
   copy->is_no_state_prefetching_ = is_no_state_prefetching_;
   copy->prerender_histogram_prefix_ = prerender_histogram_prefix_;
+  copy->bookmark_id_ = bookmark_id_;
 
   return std::move(copy);
 }