Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: chrome/browser/android/service_tab_launcher.cc

Issue 897673002: First step in enabling creating tabs without an Activity on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a-base-mounir
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/service_tab_launcher.h ('k') | chrome/browser/chrome_content_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/service_tab_launcher.cc
diff --git a/chrome/browser/android/service_tab_launcher.cc b/chrome/browser/android/service_tab_launcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7faab0dc32f24c59168dd492d98fe6712e9c290c
--- /dev/null
+++ b/chrome/browser/android/service_tab_launcher.cc
@@ -0,0 +1,60 @@
+// 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/service_tab_launcher.h"
+
+#include "base/android/jni_string.h"
+#include "base/callback.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/page_navigator.h"
+#include "jni/ServiceTabLauncher_jni.h"
+
+using base::android::AttachCurrentThread;
+using base::android::ConvertUTF8ToJavaString;
+using base::android::GetApplicationContext;
+
+namespace chrome {
+namespace android {
+
+// static
+ServiceTabLauncher* ServiceTabLauncher::GetInstance() {
+ return Singleton<ServiceTabLauncher>::get();
+}
+
+ServiceTabLauncher::ServiceTabLauncher() {
+ java_object_.Reset(
+ Java_ServiceTabLauncher_create(
+ AttachCurrentThread(),
+ reinterpret_cast<intptr_t>(this),
+ GetApplicationContext()));
+}
+
+ServiceTabLauncher::~ServiceTabLauncher() {}
+
+void ServiceTabLauncher::LaunchTab(
+ content::BrowserContext* browser_context,
+ const content::OpenURLParams& params,
+ const base::Callback<void(content::WebContents*)>& callback) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> url = ConvertUTF8ToJavaString(
+ env, params.url.spec());
+
+ Java_ServiceTabLauncher_launchTab(env,
+ java_object_.obj(),
+ url.obj(),
+ params.disposition,
+ browser_context->IsOffTheRecord());
+
+ // TODO(peter): We need to wait for the Android Activity to reply to the
+ // launch intent with the ID of the launched Web Contents, so that the Java
+ // side can invoke a method on the native side with the request id and the
+ // WebContents enabling us to invoke |callback|. See https://crbug.com/454809.
+}
+
+bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace android
+} // namespace chrome
« no previous file with comments | « chrome/browser/android/service_tab_launcher.h ('k') | chrome/browser/chrome_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698