diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 05:26:34 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 05:26:34 +0000 |
commit | 3b38479db517949e91631dc5a61454a657a4c66b (patch) | |
tree | 5df27b29fe440ab2352f39c284a66dac9e6fcede /remoting/client | |
parent | 14402581dbb7319c44515d9adb5fcbccd581e5dd (diff) | |
download | chromium_src-3b38479db517949e91631dc5a61454a657a4c66b.zip chromium_src-3b38479db517949e91631dc5a61454a657a4c66b.tar.gz chromium_src-3b38479db517949e91631dc5a61454a657a4c66b.tar.bz2 |
Show Android device name in paired clients list
This replaces the hard-coded "Android" string with a more descriptive
identifier such as "Nexus 7".
BUG=330899
Review URL: https://codereview.chromium.org/177313007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.cc | 20 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.h | 10 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_runtime.cc | 6 |
3 files changed, 31 insertions, 5 deletions
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc index 96f0d35..92b7615 100644 --- a/remoting/client/jni/chromoting_jni_instance.cc +++ b/remoting/client/jni/chromoting_jni_instance.cc @@ -103,12 +103,16 @@ void ChromotingJniInstance::Cleanup() { } void ChromotingJniInstance::ProvideSecret(const std::string& pin, - bool create_pairing) { + bool create_pairing, + const std::string& device_name) { DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); DCHECK(!pin_callback_.is_null()); create_pairing_ = create_pairing; + if (create_pairing) + SetDeviceName(device_name); + jni_runtime_->network_task_runner()->PostTask(FROM_HERE, base::Bind(pin_callback_, pin)); } @@ -201,7 +205,8 @@ void ChromotingJniInstance::OnConnectionState( if (create_pairing_ && state == protocol::ConnectionToHost::CONNECTED) { protocol::PairingRequest request; - request.set_client_name("Android"); + DCHECK(!device_name_.empty()); + request.set_client_name(device_name_); connection_->host_stub()->RequestPairing(request); } @@ -363,6 +368,17 @@ void ChromotingJniInstance::FetchSecret( jni_runtime_->DisplayAuthenticationPrompt(pairable); } +void ChromotingJniInstance::SetDeviceName(const std::string& device_name) { + if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->network_task_runner()->PostTask( + FROM_HERE, base::Bind(&ChromotingJniInstance::SetDeviceName, this, + device_name)); + return; + } + + device_name_ = device_name; +} + void ChromotingJniInstance::EnableStatsLogging(bool enabled) { DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); diff --git a/remoting/client/jni/chromoting_jni_instance.h b/remoting/client/jni/chromoting_jni_instance.h index fdb5a4f..64be741 100644 --- a/remoting/client/jni/chromoting_jni_instance.h +++ b/remoting/client/jni/chromoting_jni_instance.h @@ -57,7 +57,8 @@ class ChromotingJniInstance // Provides the user's PIN and resumes the host authentication attempt. Call // on the UI thread once the user has finished entering this PIN into the UI, // but only after the UI has been asked to provide a PIN (via FetchSecret()). - void ProvideSecret(const std::string& pin, bool create_pair); + void ProvideSecret(const std::string& pin, bool create_pair, + const std::string& device_name); // Schedules a redraw on the display thread. May be called from any thread. void RedrawDesktop(); @@ -115,6 +116,9 @@ class ChromotingJniInstance void FetchSecret(bool pairable, const protocol::SecretFetchedCallback& callback); + // Sets the device name. Can be called on any thread. + void SetDeviceName(const std::string& device_name); + // Enables or disables periodic logging of performance statistics. Called on // the network thread. void EnableStatsLogging(bool enabled); @@ -154,6 +158,10 @@ class ChromotingJniInstance // once per run, and always before any reference to this flag.) bool create_pairing_; + // The device name to appear in the paired-clients list. Accessed on the + // network thread. + std::string device_name_; + // If this is true, performance statistics will be periodically written to // the Android log. Used on the network thread. bool stats_logging_enabled_; diff --git a/remoting/client/jni/chromoting_jni_runtime.cc b/remoting/client/jni/chromoting_jni_runtime.cc index 22f4e47..7a23487 100644 --- a/remoting/client/jni/chromoting_jni_runtime.cc +++ b/remoting/client/jni/chromoting_jni_runtime.cc @@ -92,9 +92,11 @@ static void Disconnect(JNIEnv* env, jclass clazz) { static void AuthenticationResponse(JNIEnv* env, jclass clazz, jstring pin, - jboolean createPair) { + jboolean createPair, + jstring deviceName) { remoting::ChromotingJniRuntime::GetInstance()->session()->ProvideSecret( - ConvertJavaStringToUTF8(env, pin).c_str(), createPair); + ConvertJavaStringToUTF8(env, pin).c_str(), createPair, + ConvertJavaStringToUTF8(env, deviceName)); } static void ScheduleRedraw(JNIEnv* env, jclass clazz) { |