summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 01:49:18 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 01:49:18 +0000
commit77ff3b0e41d02834ea1f57d04d5cc3fd1b34dfda (patch)
tree2692ab3bfe03829d2e84a6fa7ead6b551d9dc521
parent9c0991fb61244d17082aa86eb98756c660bba08e (diff)
downloadchromium_src-77ff3b0e41d02834ea1f57d04d5cc3fd1b34dfda.zip
chromium_src-77ff3b0e41d02834ea1f57d04d5cc3fd1b34dfda.tar.gz
chromium_src-77ff3b0e41d02834ea1f57d04d5cc3fd1b34dfda.tar.bz2
Chromoting: Implemented GetVersion for Windows.
BUG=125998 TEST=Manual Review URL: https://chromiumcodereview.appspot.com/10310154 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137050 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/elevated_controller_win.cc21
-rw-r--r--remoting/host/plugin/daemon_controller_win.cc33
2 files changed, 50 insertions, 4 deletions
diff --git a/remoting/host/elevated_controller_win.cc b/remoting/host/elevated_controller_win.cc
index 484955e..7ca42dd 100644
--- a/remoting/host/elevated_controller_win.cc
+++ b/remoting/host/elevated_controller_win.cc
@@ -7,11 +7,13 @@
#include <sddl.h>
#include "base/file_util.h"
+#include "base/file_version_info.h"
#include "base/logging.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
+#include "base/process_util.h"
#include "base/stringize_macros.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
@@ -327,7 +329,24 @@ STDMETHODIMP ElevatedControllerWin::GetConfig(BSTR* config_out) {
}
STDMETHODIMP ElevatedControllerWin::GetVersion(BSTR* version_out) {
- return E_NOTIMPL;
+ // Report the product version number of the daemon controller binary as
+ // the host version.
+ HMODULE binary = base::GetModuleFromAddress(
+ reinterpret_cast<void*>(&ReadConfig));
+ scoped_ptr<FileVersionInfo> version_info(
+ FileVersionInfo::CreateFileVersionInfoForModule(binary));
+
+ string16 version;
+ if (version_info.get()) {
+ version = version_info->product_version();
+ }
+
+ *version_out = ::SysAllocString(version.c_str());
+ if (version_out == NULL) {
+ return E_OUTOFMEMORY;
+ }
+
+ return S_OK;
}
STDMETHODIMP ElevatedControllerWin::SetConfig(BSTR config) {
diff --git a/remoting/host/plugin/daemon_controller_win.cc b/remoting/host/plugin/daemon_controller_win.cc
index 864b4f8..101118d 100644
--- a/remoting/host/plugin/daemon_controller_win.cc
+++ b/remoting/host/plugin/daemon_controller_win.cc
@@ -123,6 +123,7 @@ class DaemonControllerWin : public remoting::DaemonController {
const CompletionCallback& done_callback);
void DoStop(const CompletionCallback& done_callback);
void DoSetWindow(void* window_handle);
+ void DoGetVersion(const GetVersionCallback& callback);
// |control_| holds a reference to an instance of the daemon controller
// to prevent a UAC prompt on every operation.
@@ -246,9 +247,11 @@ void DaemonControllerWin::SetWindow(void* window_handle) {
window_handle));
}
-void DaemonControllerWin::GetVersion(const GetVersionCallback& done_callback) {
- NOTIMPLEMENTED();
- done_callback.Run("");
+void DaemonControllerWin::GetVersion(const GetVersionCallback& callback) {
+ worker_thread_.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&DaemonControllerWin::DoGetVersion,
+ base::Unretained(this), callback));
}
HRESULT DaemonControllerWin::ActivateController() {
@@ -561,6 +564,30 @@ void DaemonControllerWin::DoSetWindow(void* window_handle) {
window_handle_ = reinterpret_cast<HWND>(window_handle);
}
+void DaemonControllerWin::DoGetVersion(const GetVersionCallback& callback) {
+ DCHECK(worker_thread_.message_loop_proxy()->BelongsToCurrentThread());
+
+ std::string version_null;
+
+ // Configure and start the Daemon Controller if it is installed already.
+ HRESULT hr = ActivateController();
+ if (FAILED(hr)) {
+ callback.Run(version_null);
+ return;
+ }
+
+ // Get the version string.
+ ScopedBstr version;
+ hr = control_->GetVersion(version.Receive());
+ if (FAILED(hr)) {
+ callback.Run(version_null);
+ return;
+ }
+
+ callback.Run(UTF16ToUTF8(
+ string16(static_cast<BSTR>(version), version.Length())));
+}
+
} // namespace
scoped_ptr<DaemonController> remoting::DaemonController::Create() {