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

Unified Diff: chrome/browser/android/service_tab_creator.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: s/NavigationUtils/ServiceTabCreator/g Created 5 years, 11 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
Index: chrome/browser/android/service_tab_creator.cc
diff --git a/chrome/browser/android/service_tab_creator.cc b/chrome/browser/android/service_tab_creator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8794a830d32236c237c4d5aa261e0fc45dae6001
--- /dev/null
+++ b/chrome/browser/android/service_tab_creator.cc
@@ -0,0 +1,49 @@
+// 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_creator.h"
+
+#include "base/android/jni_string.h"
+#include "base/callback.h"
+#include "content/public/browser/page_navigator.h"
+#include "jni/ServiceTabCreator_jni.h"
+
+using base::android::AttachCurrentThread;
+using base::android::ConvertUTF8ToJavaString;
+using base::android::GetApplicationContext;
+
+// static
+ServiceTabCreator* ServiceTabCreator::GetInstance() {
+ return Singleton<ServiceTabCreator>::get();
+}
+
+ServiceTabCreator::ServiceTabCreator() {
+ java_object_.Reset(
+ Java_ServiceTabCreator_create(
+ AttachCurrentThread(),
+ reinterpret_cast<intptr_t>(this),
+ GetApplicationContext()));
+}
+
+ServiceTabCreator::~ServiceTabCreator() {}
+
+void ServiceTabCreator::CreateTab(
+ content::BrowserContext* browser_context,
+ const content::OpenURLParams& params,
+ base::Callback<void(content::WebContents*)> callback) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> url = ConvertUTF8ToJavaString(
+ env, params.url.spec());
+
+ Java_ServiceTabCreator_createTab(env, java_object_.obj(), url.obj());
+
+ // 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 ServiceTabCreator::RegisterServiceTabCreator(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698