summaryrefslogtreecommitdiffstats
path: root/chrome/browser/android/sessions
diff options
context:
space:
mode:
authormegjablon <megjablon@chromium.org>2015-11-02 14:57:42 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-02 22:58:41 +0000
commitb31dc8c17c278ac2f72720a9e99e5404b873b954 (patch)
tree22d812cc31081457124dbb9f1e47e271337c0358 /chrome/browser/android/sessions
parent4819b0855b95f5f91afce699cbd072c914f89e97 (diff)
downloadchromium_src-b31dc8c17c278ac2f72720a9e99e5404b873b954.zip
chromium_src-b31dc8c17c278ac2f72720a9e99e5404b873b954.tar.gz
chromium_src-b31dc8c17c278ac2f72720a9e99e5404b873b954.tar.bz2
Create a Java SessionTabHelper
Create a Java SessionTabHelper with idForTab so that the DataUseTabUIManager in Java can get the C++ notion of a tab ID from a Java tab. TBR=thestig@chromium.org BUG=547256 Review URL: https://codereview.chromium.org/1423933002 Cr-Commit-Position: refs/heads/master@{#357462}
Diffstat (limited to 'chrome/browser/android/sessions')
-rw-r--r--chrome/browser/android/sessions/session_tab_helper_android.cc24
-rw-r--r--chrome/browser/android/sessions/session_tab_helper_android.h13
2 files changed, 37 insertions, 0 deletions
diff --git a/chrome/browser/android/sessions/session_tab_helper_android.cc b/chrome/browser/android/sessions/session_tab_helper_android.cc
new file mode 100644
index 0000000..7411543
--- /dev/null
+++ b/chrome/browser/android/sessions/session_tab_helper_android.cc
@@ -0,0 +1,24 @@
+// Copyright 2015 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 "chrome/browser/android/sessions/session_tab_helper_android.h"
+
+#include "base/android/jni_android.h"
+#include "chrome/browser/sessions/session_tab_helper.h"
+#include "content/public/browser/web_contents.h"
+#include "jni/SessionTabHelper_jni.h"
+
+// static
+jint IdForTab(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jobject>& java_web_contents) {
+ content::WebContents* web_contents =
+ content::WebContents::FromJavaWebContents(java_web_contents);
+ CHECK(web_contents);
+ return SessionTabHelper::IdForTab(web_contents);
+}
+
+bool RegisterSessionTabHelper(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
diff --git a/chrome/browser/android/sessions/session_tab_helper_android.h b/chrome/browser/android/sessions/session_tab_helper_android.h
new file mode 100644
index 0000000..e73fa71
--- /dev/null
+++ b/chrome/browser/android/sessions/session_tab_helper_android.h
@@ -0,0 +1,13 @@
+// Copyright 2015 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.
+
+#ifndef CHROME_BROWSER_ANDROID_SESSIONS_SESSION_TAB_HELPER_ANDROID_H_
+#define CHROME_BROWSER_ANDROID_SESSIONS_SESSION_TAB_HELPER_ANDROID_H_
+
+#include <jni.h>
+
+// Registers the SessionTabHelper's native methods through JNI.
+bool RegisterSessionTabHelper(JNIEnv* env);
+
+#endif // CHROME_BROWSER_ANDROID_SESSIONS_SESSION_TAB_HELPER_ANDROID_H_