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 "chrome/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 chrome::android::ServiceTabLauncher::GetInstance()->OnTabLaunched( | 21 service_tab_launcher::ServiceTabLauncher::GetInstance()->OnTabLaunched( |
22 request_id, | 22 request_id, |
23 content::WebContents::FromJavaWebContents(android_web_contents)); | 23 content::WebContents::FromJavaWebContents(android_web_contents)); |
24 } | 24 } |
25 | 25 |
26 namespace chrome { | 26 namespace service_tab_launcher { |
27 namespace android { | |
28 | 27 |
29 // static | 28 // static |
30 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { | 29 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { |
31 return Singleton<ServiceTabLauncher>::get(); | 30 return Singleton<ServiceTabLauncher>::get(); |
32 } | 31 } |
33 | 32 |
34 ServiceTabLauncher::ServiceTabLauncher() { | 33 ServiceTabLauncher::ServiceTabLauncher() { |
35 java_object_.Reset( | 34 java_object_.Reset( |
36 Java_ServiceTabLauncher_getInstance(AttachCurrentThread(), | 35 Java_ServiceTabLauncher_getInstance(AttachCurrentThread(), |
37 GetApplicationContext())); | 36 GetApplicationContext())); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (callback) | 91 if (callback) |
93 callback->Run(web_contents); | 92 callback->Run(web_contents); |
94 | 93 |
95 tab_launched_callbacks_.Remove(request_id); | 94 tab_launched_callbacks_.Remove(request_id); |
96 } | 95 } |
97 | 96 |
98 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { | 97 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { |
99 return RegisterNativesImpl(env); | 98 return RegisterNativesImpl(env); |
100 } | 99 } |
101 | 100 |
102 } // namespace android | 101 } // namespace service_tab_launcher |
103 } // namespace chrome | |
OLD | NEW |