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

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

Issue 2801033002: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: 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"
7 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
8 #include "base/callback.h" 9 #include "base/callback.h"
9 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
10 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/page_navigator.h" 12 #include "content/public/browser/page_navigator.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 #include "jni/ServiceTabLauncher_jni.h" 14 #include "jni/ServiceTabLauncher_jni.h"
14 15
15 using base::android::AttachCurrentThread; 16 using base::android::AttachCurrentThread;
16 using base::android::ConvertUTF8ToJavaString; 17 using base::android::ConvertUTF8ToJavaString;
18 using base::android::GetApplicationContext;
17 using base::android::JavaParamRef; 19 using base::android::JavaParamRef;
18 using base::android::ScopedJavaLocalRef; 20 using base::android::ScopedJavaLocalRef;
19 21
20 // Called by Java when the WebContents instance for a request Id is available. 22 // Called by Java when the WebContents instance for a request Id is available.
21 void OnWebContentsForRequestAvailable( 23 void OnWebContentsForRequestAvailable(
22 JNIEnv* env, 24 JNIEnv* env,
23 const JavaParamRef<jclass>& clazz, 25 const JavaParamRef<jclass>& clazz,
24 jint request_id, 26 jint request_id,
25 const JavaParamRef<jobject>& android_web_contents) { 27 const JavaParamRef<jobject>& android_web_contents) {
26 ServiceTabLauncher::GetInstance()->OnTabLaunched( 28 ServiceTabLauncher::GetInstance()->OnTabLaunched(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ConvertUTF8ToJavaString(env, params.referrer.url.spec()); 60 ConvertUTF8ToJavaString(env, params.referrer.url.spec());
59 ScopedJavaLocalRef<jstring> headers = ConvertUTF8ToJavaString( 61 ScopedJavaLocalRef<jstring> headers = ConvertUTF8ToJavaString(
60 env, params.extra_headers); 62 env, params.extra_headers);
61 63
62 ScopedJavaLocalRef<jobject> post_data; 64 ScopedJavaLocalRef<jobject> post_data;
63 65
64 int request_id = tab_launched_callbacks_.Add( 66 int request_id = tab_launched_callbacks_.Add(
65 base::MakeUnique<TabLaunchedCallback>(callback)); 67 base::MakeUnique<TabLaunchedCallback>(callback));
66 DCHECK_GE(request_id, 1); 68 DCHECK_GE(request_id, 1);
67 69
68 Java_ServiceTabLauncher_launchTab(env, request_id, 70 Java_ServiceTabLauncher_launchTab(env, GetApplicationContext(), request_id,
69 browser_context->IsOffTheRecord(), url, 71 browser_context->IsOffTheRecord(), url,
70 static_cast<int>(disposition), referrer_url, 72 static_cast<int>(disposition), referrer_url,
71 params.referrer.policy, headers, post_data); 73 params.referrer.policy, headers, post_data);
72 } 74 }
73 75
74 void ServiceTabLauncher::OnTabLaunched(int request_id, 76 void ServiceTabLauncher::OnTabLaunched(int request_id,
75 content::WebContents* web_contents) { 77 content::WebContents* web_contents) {
76 TabLaunchedCallback* callback = tab_launched_callbacks_.Lookup(request_id); 78 TabLaunchedCallback* callback = tab_launched_callbacks_.Lookup(request_id);
77 DCHECK(callback); 79 DCHECK(callback);
78 80
79 if (callback) 81 if (callback)
80 callback->Run(web_contents); 82 callback->Run(web_contents);
81 83
82 tab_launched_callbacks_.Remove(request_id); 84 tab_launched_callbacks_.Remove(request_id);
83 } 85 }
84 86
85 bool ServiceTabLauncher::Register(JNIEnv* env) { 87 bool ServiceTabLauncher::Register(JNIEnv* env) {
86 return RegisterNativesImpl(env); 88 return RegisterNativesImpl(env);
87 } 89 }
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