| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" | 5 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/page_navigator.h" | 10 #include "content/public/browser/page_navigator.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "jni/ServiceTabLauncher_jni.h" | 12 #include "jni/ServiceTabLauncher_jni.h" |
| 13 | 13 |
| 14 using base::android::AttachCurrentThread; | 14 using base::android::AttachCurrentThread; |
| 15 using base::android::ConvertUTF8ToJavaString; | 15 using base::android::ConvertUTF8ToJavaString; |
| 16 using base::android::GetApplicationContext; | 16 using base::android::GetApplicationContext; |
| 17 | 17 |
| 18 // Called by Java when the WebContents instance for a request Id is available. | 18 // Called by Java when the WebContents instance for a request Id is available. |
| 19 void OnWebContentsForRequestAvailable( | 19 void OnWebContentsForRequestAvailable( |
| 20 JNIEnv* env, jclass clazz, jint request_id, jobject android_web_contents) { | 20 JNIEnv* env, jclass clazz, jint request_id, jobject android_web_contents) { |
| 21 #if !defined(USE_AURA) |
| 21 service_tab_launcher::ServiceTabLauncher::GetInstance()->OnTabLaunched( | 22 service_tab_launcher::ServiceTabLauncher::GetInstance()->OnTabLaunched( |
| 22 request_id, | 23 request_id, |
| 23 content::WebContents::FromJavaWebContents(android_web_contents)); | 24 content::WebContents::FromJavaWebContents(android_web_contents)); |
| 25 #endif |
| 24 } | 26 } |
| 25 | 27 |
| 26 namespace service_tab_launcher { | 28 namespace service_tab_launcher { |
| 27 | 29 |
| 28 // static | 30 // static |
| 29 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { | 31 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { |
| 30 return Singleton<ServiceTabLauncher>::get(); | 32 return Singleton<ServiceTabLauncher>::get(); |
| 31 } | 33 } |
| 32 | 34 |
| 33 ServiceTabLauncher::ServiceTabLauncher() { | 35 ServiceTabLauncher::ServiceTabLauncher() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 callback->Run(web_contents); | 94 callback->Run(web_contents); |
| 93 | 95 |
| 94 tab_launched_callbacks_.Remove(request_id); | 96 tab_launched_callbacks_.Remove(request_id); |
| 95 } | 97 } |
| 96 | 98 |
| 97 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { | 99 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { |
| 98 return RegisterNativesImpl(env); | 100 return RegisterNativesImpl(env); |
| 99 } | 101 } |
| 100 | 102 |
| 101 } // namespace service_tab_launcher | 103 } // namespace service_tab_launcher |
| OLD | NEW |