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 service_tab_launcher::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 service_tab_launcher { | 26 namespace service_tab_launcher { |
27 | 27 |
28 // static | 28 // static |
29 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { | 29 ServiceTabLauncher* ServiceTabLauncher::GetInstance() { |
30 return Singleton<ServiceTabLauncher>::get(); | 30 return base::Singleton<ServiceTabLauncher>::get(); |
31 } | 31 } |
32 | 32 |
33 ServiceTabLauncher::ServiceTabLauncher() { | 33 ServiceTabLauncher::ServiceTabLauncher() { |
34 java_object_.Reset( | 34 java_object_.Reset( |
35 Java_ServiceTabLauncher_getInstance(AttachCurrentThread(), | 35 Java_ServiceTabLauncher_getInstance(AttachCurrentThread(), |
36 GetApplicationContext())); | 36 GetApplicationContext())); |
37 } | 37 } |
38 | 38 |
39 ServiceTabLauncher::~ServiceTabLauncher() {} | 39 ServiceTabLauncher::~ServiceTabLauncher() {} |
40 | 40 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 callback->Run(web_contents); | 92 callback->Run(web_contents); |
93 | 93 |
94 tab_launched_callbacks_.Remove(request_id); | 94 tab_launched_callbacks_.Remove(request_id); |
95 } | 95 } |
96 | 96 |
97 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { | 97 bool ServiceTabLauncher::RegisterServiceTabLauncher(JNIEnv* env) { |
98 return RegisterNativesImpl(env); | 98 return RegisterNativesImpl(env); |
99 } | 99 } |
100 | 100 |
101 } // namespace service_tab_launcher | 101 } // namespace service_tab_launcher |
OLD | NEW |