Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/service_tab_launcher.h" | |
| 6 | |
| 7 #include "base/android/jni_string.h" | |
| 8 #include "base/callback.h" | |
| 9 #include "content/public/browser/browser_context.h" | |
| 10 #include "content/public/browser/page_navigator.h" | |
| 11 #include "jni/ServiceTabLauncher_jni.h" | |
| 12 | |
| 13 using base::android::AttachCurrentThread; | |
| 14 using base::android::ConvertUTF8ToJavaString; | |
| 15 using base::android::GetApplicationContext; | |
| 16 | |
| 17 namespace chrome { | |
| 18 namespace android { | |
| 19 | |
| 20 // static | |
| 21 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { | |
| 22 return Singleton<ServiceTabLauncher>::get(); | |
| 23 } | |
| 24 | |
| 25 ServiceTabLauncher::ServiceTabLauncher() { | |
| 26 java_object_.Reset( | |
| 27 Java_ServiceTabLauncher_create( | |
| 28 AttachCurrentThread(), | |
| 29 reinterpret_cast<intptr_t>(this), | |
| 30 GetApplicationContext())); | |
| 31 } | |
| 32 | |
| 33 ServiceTabLauncher::~ServiceTabLauncher() {} | |
| 34 | |
| 35 void ServiceTabLauncher::LaunchTab( | |
| 36 content::BrowserContext* browser_context, | |
| 37 const content::OpenURLParams& params, | |
| 38 base::Callback<void(content::WebContents*)> callback) { | |
|
mlamouri (slow - plz ping)
2015/02/11 20:49:52
ditto
Peter Beverloo
2015/02/11 21:12:13
Done.
| |
| 39 JNIEnv* env = AttachCurrentThread(); | |
| 40 ScopedJavaLocalRef<jstring> url = ConvertUTF8ToJavaString( | |
| 41 env, params.url.spec()); | |
| 42 | |
| 43 Java_ServiceTabLauncher_launchTab(env, | |
| 44 java_object_.obj(), | |
| 45 url.obj(), | |
| 46 params.disposition, | |
| 47 browser_context->IsOffTheRecord()); | |
| 48 | |
| 49 // TODO(peter): We need to wait for the Android Activity to reply to the | |
| 50 // launch intent with the ID of the launched Web Contents, so that the Java | |
| 51 // side can invoke a method on the native side with the request id and the | |
| 52 // WebContents enabling us to invoke |callback|. See https://crbug.com/454809. | |
| 53 } | |
| 54 | |
| 55 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { | |
| 56 return RegisterNativesImpl(env); | |
| 57 } | |
| 58 | |
| 59 } // namespace android | |
| 60 } // namespace chrome | |
| OLD | NEW |