Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/android/service_tab_launcher.cc

Issue 2784353002: Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Fix tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
9 #include "base/callback.h" 8 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
11 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/page_navigator.h" 11 #include "content/public/browser/page_navigator.h"
13 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
14 #include "jni/ServiceTabLauncher_jni.h" 13 #include "jni/ServiceTabLauncher_jni.h"
15 14
16 using base::android::AttachCurrentThread; 15 using base::android::AttachCurrentThread;
17 using base::android::ConvertUTF8ToJavaString; 16 using base::android::ConvertUTF8ToJavaString;
18 using base::android::GetApplicationContext;
19 using base::android::JavaParamRef; 17 using base::android::JavaParamRef;
20 using base::android::ScopedJavaLocalRef; 18 using base::android::ScopedJavaLocalRef;
21 19
22 // Called by Java when the WebContents instance for a request Id is available. 20 // Called by Java when the WebContents instance for a request Id is available.
23 void OnWebContentsForRequestAvailable( 21 void OnWebContentsForRequestAvailable(
24 JNIEnv* env, 22 JNIEnv* env,
25 const JavaParamRef<jclass>& clazz, 23 const JavaParamRef<jclass>& clazz,
26 jint request_id, 24 jint request_id,
27 const JavaParamRef<jobject>& android_web_contents) { 25 const JavaParamRef<jobject>& android_web_contents) {
28 ServiceTabLauncher::GetInstance()->OnTabLaunched( 26 ServiceTabLauncher::GetInstance()->OnTabLaunched(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ConvertUTF8ToJavaString(env, params.referrer.url.spec()); 58 ConvertUTF8ToJavaString(env, params.referrer.url.spec());
61 ScopedJavaLocalRef<jstring> headers = ConvertUTF8ToJavaString( 59 ScopedJavaLocalRef<jstring> headers = ConvertUTF8ToJavaString(
62 env, params.extra_headers); 60 env, params.extra_headers);
63 61
64 ScopedJavaLocalRef<jobject> post_data; 62 ScopedJavaLocalRef<jobject> post_data;
65 63
66 int request_id = tab_launched_callbacks_.Add( 64 int request_id = tab_launched_callbacks_.Add(
67 base::MakeUnique<TabLaunchedCallback>(callback)); 65 base::MakeUnique<TabLaunchedCallback>(callback));
68 DCHECK_GE(request_id, 1); 66 DCHECK_GE(request_id, 1);
69 67
70 Java_ServiceTabLauncher_launchTab(env, GetApplicationContext(), request_id, 68 Java_ServiceTabLauncher_launchTab(env, request_id,
71 browser_context->IsOffTheRecord(), url, 69 browser_context->IsOffTheRecord(), url,
72 static_cast<int>(disposition), referrer_url, 70 static_cast<int>(disposition), referrer_url,
73 params.referrer.policy, headers, post_data); 71 params.referrer.policy, headers, post_data);
74 } 72 }
75 73
76 void ServiceTabLauncher::OnTabLaunched(int request_id, 74 void ServiceTabLauncher::OnTabLaunched(int request_id,
77 content::WebContents* web_contents) { 75 content::WebContents* web_contents) {
78 TabLaunchedCallback* callback = tab_launched_callbacks_.Lookup(request_id); 76 TabLaunchedCallback* callback = tab_launched_callbacks_.Lookup(request_id);
79 DCHECK(callback); 77 DCHECK(callback);
80 78
81 if (callback) 79 if (callback)
82 callback->Run(web_contents); 80 callback->Run(web_contents);
83 81
84 tab_launched_callbacks_.Remove(request_id); 82 tab_launched_callbacks_.Remove(request_id);
85 } 83 }
86 84
87 bool ServiceTabLauncher::Register(JNIEnv* env) { 85 bool ServiceTabLauncher::Register(JNIEnv* env) {
88 return RegisterNativesImpl(env); 86 return RegisterNativesImpl(env);
89 } 87 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_launcher.cc ('k') | chrome/browser/android/signin/account_management_screen_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698