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