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 "chrome/browser/android/service_tab_launcher.h" |
6 | 6 |
7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ConvertUTF8ToJavaString(env, params.referrer.url.spec()); | 57 ConvertUTF8ToJavaString(env, params.referrer.url.spec()); |
58 ScopedJavaLocalRef<jstring> headers = ConvertUTF8ToJavaString( | 58 ScopedJavaLocalRef<jstring> headers = ConvertUTF8ToJavaString( |
59 env, params.extra_headers); | 59 env, params.extra_headers); |
60 | 60 |
61 ScopedJavaLocalRef<jobject> post_data; | 61 ScopedJavaLocalRef<jobject> post_data; |
62 | 62 |
63 int request_id = tab_launched_callbacks_.Add( | 63 int request_id = tab_launched_callbacks_.Add( |
64 new TabLaunchedCallback(callback)); | 64 new TabLaunchedCallback(callback)); |
65 DCHECK_GE(request_id, 1); | 65 DCHECK_GE(request_id, 1); |
66 | 66 |
67 Java_ServiceTabLauncher_launchTab(env, | 67 Java_ServiceTabLauncher_launchTab(env, GetApplicationContext(), request_id, |
68 GetApplicationContext(), | 68 browser_context->IsOffTheRecord(), url, |
69 request_id, | 69 disposition, referrer_url, |
70 browser_context->IsOffTheRecord(), | 70 params.referrer.policy, headers, post_data); |
71 url.obj(), | |
72 disposition, | |
73 referrer_url.obj(), | |
74 params.referrer.policy, | |
75 headers.obj(), | |
76 post_data.obj()); | |
77 } | 71 } |
78 | 72 |
79 void ServiceTabLauncher::OnTabLaunched(int request_id, | 73 void ServiceTabLauncher::OnTabLaunched(int request_id, |
80 content::WebContents* web_contents) { | 74 content::WebContents* web_contents) { |
81 TabLaunchedCallback* callback = tab_launched_callbacks_.Lookup(request_id); | 75 TabLaunchedCallback* callback = tab_launched_callbacks_.Lookup(request_id); |
82 DCHECK(callback); | 76 DCHECK(callback); |
83 | 77 |
84 if (callback) | 78 if (callback) |
85 callback->Run(web_contents); | 79 callback->Run(web_contents); |
86 | 80 |
87 tab_launched_callbacks_.Remove(request_id); | 81 tab_launched_callbacks_.Remove(request_id); |
88 } | 82 } |
89 | 83 |
90 bool ServiceTabLauncher::Register(JNIEnv* env) { | 84 bool ServiceTabLauncher::Register(JNIEnv* env) { |
91 return RegisterNativesImpl(env); | 85 return RegisterNativesImpl(env); |
92 } | 86 } |
OLD | NEW |