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

Side by Side Diff: chrome/browser/signin/android_profile_oauth2_token_service.cc

Issue 67573003: Android: moves chrome/ to use long for JNI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/signin/android_profile_oauth2_token_service.h" 5 #include "chrome/browser/signin/android_profile_oauth2_token_service.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // time is unknown. 46 // time is unknown.
47 typedef base::Callback<void( 47 typedef base::Callback<void(
48 const GoogleServiceAuthError&, const std::string&, const base::Time&)> 48 const GoogleServiceAuthError&, const std::string&, const base::Time&)>
49 FetchOAuth2TokenCallback; 49 FetchOAuth2TokenCallback;
50 50
51 } // namespace 51 } // namespace
52 52
53 AndroidProfileOAuth2TokenService::AndroidProfileOAuth2TokenService() { 53 AndroidProfileOAuth2TokenService::AndroidProfileOAuth2TokenService() {
54 JNIEnv* env = AttachCurrentThread(); 54 JNIEnv* env = AttachCurrentThread();
55 base::android::ScopedJavaLocalRef<jobject> local_java_ref = 55 base::android::ScopedJavaLocalRef<jobject> local_java_ref =
56 Java_OAuth2TokenService_create(env, reinterpret_cast<int>(this)); 56 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this));
57 java_ref_.Reset(env, local_java_ref.obj()); 57 java_ref_.Reset(env, local_java_ref.obj());
58 } 58 }
59 59
60 AndroidProfileOAuth2TokenService::~AndroidProfileOAuth2TokenService() {} 60 AndroidProfileOAuth2TokenService::~AndroidProfileOAuth2TokenService() {}
61 61
62 // static 62 // static
63 jobject AndroidProfileOAuth2TokenService::GetForProfile( 63 jobject AndroidProfileOAuth2TokenService::GetForProfile(
64 JNIEnv* env, jclass clazz, jobject j_profile_android) { 64 JNIEnv* env, jclass clazz, jobject j_profile_android) {
65 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile_android); 65 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile_android);
66 AndroidProfileOAuth2TokenService* service = 66 AndroidProfileOAuth2TokenService* service =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // It will be passed back to OAuth2TokenFetched(), where it will be freed. 122 // It will be passed back to OAuth2TokenFetched(), where it will be freed.
123 scoped_ptr<FetchOAuth2TokenCallback> heap_callback( 123 scoped_ptr<FetchOAuth2TokenCallback> heap_callback(
124 new FetchOAuth2TokenCallback(base::Bind(&RequestImpl::InformConsumer, 124 new FetchOAuth2TokenCallback(base::Bind(&RequestImpl::InformConsumer,
125 request->AsWeakPtr()))); 125 request->AsWeakPtr())));
126 126
127 // Call into Java to get a new token. 127 // Call into Java to get a new token.
128 Java_OAuth2TokenService_getOAuth2AuthToken( 128 Java_OAuth2TokenService_getOAuth2AuthToken(
129 env, base::android::GetApplicationContext(), 129 env, base::android::GetApplicationContext(),
130 j_username.obj(), 130 j_username.obj(),
131 j_scope.obj(), 131 j_scope.obj(),
132 reinterpret_cast<int>(heap_callback.release())); 132 reinterpret_cast<intptr_t>(heap_callback.release()));
133 } 133 }
134 134
135 void AndroidProfileOAuth2TokenService::InvalidateOAuth2Token( 135 void AndroidProfileOAuth2TokenService::InvalidateOAuth2Token(
136 const std::string& account_id, 136 const std::string& account_id,
137 const std::string& client_id, 137 const std::string& client_id,
138 const ScopeSet& scopes, 138 const ScopeSet& scopes,
139 const std::string& access_token) { 139 const std::string& access_token) {
140 OAuth2TokenService::InvalidateOAuth2Token(account_id, 140 OAuth2TokenService::InvalidateOAuth2Token(account_id,
141 client_id, 141 client_id,
142 scopes, 142 scopes,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 JNIEnv* env = AttachCurrentThread(); 228 JNIEnv* env = AttachCurrentThread();
229 Java_OAuth2TokenService_notifyRefreshTokensLoaded( 229 Java_OAuth2TokenService_notifyRefreshTokensLoaded(
230 env, java_ref_.obj()); 230 env, java_ref_.obj());
231 } 231 }
232 232
233 // Called from Java when fetching of an OAuth2 token is finished. The 233 // Called from Java when fetching of an OAuth2 token is finished. The
234 // |authToken| param is only valid when |result| is true. 234 // |authToken| param is only valid when |result| is true.
235 void OAuth2TokenFetched(JNIEnv* env, jclass clazz, 235 void OAuth2TokenFetched(JNIEnv* env, jclass clazz,
236 jstring authToken, 236 jstring authToken,
237 jboolean result, 237 jboolean result,
238 jint nativeCallback) { 238 jlong nativeCallback) {
239 std::string token = ConvertJavaStringToUTF8(env, authToken); 239 std::string token = ConvertJavaStringToUTF8(env, authToken);
240 scoped_ptr<FetchOAuth2TokenCallback> heap_callback( 240 scoped_ptr<FetchOAuth2TokenCallback> heap_callback(
241 reinterpret_cast<FetchOAuth2TokenCallback*>(nativeCallback)); 241 reinterpret_cast<FetchOAuth2TokenCallback*>(nativeCallback));
242 // Android does not provide enough information to know if the credentials are 242 // Android does not provide enough information to know if the credentials are
243 // wrong, so assume any error is transient by using CONNECTION_FAILED. 243 // wrong, so assume any error is transient by using CONNECTION_FAILED.
244 GoogleServiceAuthError err(result ? 244 GoogleServiceAuthError err(result ?
245 GoogleServiceAuthError::NONE : 245 GoogleServiceAuthError::NONE :
246 GoogleServiceAuthError::CONNECTION_FAILED); 246 GoogleServiceAuthError::CONNECTION_FAILED);
247 heap_callback->Run(err, token, base::Time()); 247 heap_callback->Run(err, token, base::Time());
248 } 248 }
249 249
250 // static 250 // static
251 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { 251 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) {
252 return RegisterNativesImpl(env); 252 return RegisterNativesImpl(env);
253 } 253 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_android.cc ('k') | chrome/browser/speech/tts_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698