Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/android/chrome_http_auth_handler.h" | 5 #include "chrome/browser/ui/android/chrome_http_auth_handler.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/utf_string_conversions.h" | |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "jni/ChromeHttpAuthHandler_jni.h" | 16 #include "jni/ChromeHttpAuthHandler_jni.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 | 18 |
| 18 using base::android::AttachCurrentThread; | 19 using base::android::AttachCurrentThread; |
| 19 using base::android::CheckException; | 20 using base::android::CheckException; |
| 20 using base::android::ConvertJavaStringToUTF16; | 21 using base::android::ConvertJavaStringToUTF16; |
| 21 using base::android::ConvertUTF16ToJavaString; | 22 using base::android::ConvertUTF16ToJavaString; |
| 22 using base::android::ScopedJavaLocalRef; | 23 using base::android::ScopedJavaLocalRef; |
| 23 | 24 |
| 24 ChromeHttpAuthHandler::ChromeHttpAuthHandler(const base::string16& explanation) | 25 ChromeHttpAuthHandler::ChromeHttpAuthHandler(const base::string16& authority, |
| 25 : observer_(NULL), | 26 const base::string16& explanation) |
| 26 explanation_(explanation) { | 27 : observer_(nullptr), authority_(authority), explanation_(explanation) {} |
| 27 } | |
| 28 | 28 |
| 29 ChromeHttpAuthHandler::~ChromeHttpAuthHandler() {} | 29 ChromeHttpAuthHandler::~ChromeHttpAuthHandler() {} |
| 30 | 30 |
| 31 void ChromeHttpAuthHandler::Init() { | 31 void ChromeHttpAuthHandler::Init() { |
| 32 DCHECK(java_chrome_http_auth_handler_.is_null()); | 32 DCHECK(java_chrome_http_auth_handler_.is_null()); |
| 33 JNIEnv* env = AttachCurrentThread(); | 33 JNIEnv* env = AttachCurrentThread(); |
| 34 java_chrome_http_auth_handler_.Reset( | 34 java_chrome_http_auth_handler_.Reset( |
| 35 Java_ChromeHttpAuthHandler_create(env, reinterpret_cast<intptr_t>(this))); | 35 Java_ChromeHttpAuthHandler_create(env, reinterpret_cast<intptr_t>(this))); |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ChromeHttpAuthHandler::CancelAuth(JNIEnv* env, jobject) { | 75 void ChromeHttpAuthHandler::CancelAuth(JNIEnv* env, jobject) { |
| 76 if (observer_) | 76 if (observer_) |
| 77 observer_->CancelAuth(); | 77 observer_->CancelAuth(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ScopedJavaLocalRef<jstring> ChromeHttpAuthHandler::GetMessageBody( | 80 ScopedJavaLocalRef<jstring> ChromeHttpAuthHandler::GetMessageBody( |
| 81 JNIEnv* env, jobject) { | 81 JNIEnv* env, jobject) { |
| 82 return ConvertUTF16ToJavaString(env, explanation_); | 82 if (explanation_.empty()) |
| 83 return ConvertUTF16ToJavaString(env, authority_); | |
| 84 return ConvertUTF16ToJavaString( | |
| 85 env, authority_ + base::ASCIIToUTF16(" ") + explanation_); | |
|
Yaron
2015/11/23 16:56:14
You may want to put this into another TextView. Ot
palmer
2015/11/24 00:15:42
Well, there's not much vertical room to spare. You
Yaron
2015/11/24 16:01:28
hmm. I suppose that's reasonable.
+newt in case h
newt (away)
2015/11/24 16:57:28
A space between sentences doesn't localize especia
| |
| 83 } | 86 } |
| 84 | 87 |
| 85 // static | 88 // static |
| 86 bool ChromeHttpAuthHandler::RegisterChromeHttpAuthHandler(JNIEnv* env) { | 89 bool ChromeHttpAuthHandler::RegisterChromeHttpAuthHandler(JNIEnv* env) { |
| 87 return RegisterNativesImpl(env); | 90 return RegisterNativesImpl(env); |
| 88 } | 91 } |
| OLD | NEW |