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

Unified Diff: chrome/browser/local_discovery/wifi/credential_getter_win.cc

Issue 343053002: Credential passing for WifiManager in Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/local_discovery/wifi/credential_getter_win.cc
diff --git a/chrome/browser/local_discovery/wifi/credential_getter_win.cc b/chrome/browser/local_discovery/wifi/credential_getter_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bcf50228ffc624006e98823388fad5cba4db335d
--- /dev/null
+++ b/chrome/browser/local_discovery/wifi/credential_getter_win.cc
@@ -0,0 +1,74 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/local_discovery/wifi/credential_getter_win.h"
+#include "chrome/common/chrome_utility_messages.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/utility_process_host.h"
+
+namespace local_discovery {
+
+namespace wifi {
+
+CredentialGetterWin::CredentialGetterWin() {
+}
+
+CredentialGetterWin::~CredentialGetterWin() {
+}
+
+void CredentialGetterWin::StartGetCredentials(
+ const std::string& network_guid,
+ const CredentialsCallback& callback) {
+ callback_ = callback;
+ if (!callback_runner_)
+ callback_runner_ = base::MessageLoopProxy::current();
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&CredentialGetterWin::StartOnIOThread, this, network_guid));
+}
+
+void CredentialGetterWin::SetCallbackRunner(
+ const scoped_refptr<base::MessageLoopProxy>& callback_runner) {
+ callback_runner_ = callback_runner;
+}
+
+void CredentialGetterWin::StartOnIOThread(const std::string& network_guid) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ content::UtilityProcessHost* host = content::UtilityProcessHost::Create(
+ this, base::MessageLoopProxy::current());
+ host->ElevatePrivileges();
+ host->Send(new ChromeUtilityHostMsg_GetWiFiCredentials(network_guid));
+}
+
+bool CredentialGetterWin::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(CredentialGetterWin, message)
+ IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GotWiFiCredentials, OnGotCredentials)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void CredentialGetterWin::OnProcessCrashed(int exit_code) {
+ PostCallback(false, "");
stevenjb 2014/06/23 17:12:20 nit: comment args, e.g. PostCallback(false /* succ
Noam Samuel 2014/06/23 17:55:44 Done.
+}
+
+void CredentialGetterWin::OnProcessLaunchFailed() {
+ PostCallback(false, "");
+}
+
+void CredentialGetterWin::OnGotCredentials(const std::string& key_data,
+ bool success) {
+ PostCallback(success, key_data);
+}
+
+void CredentialGetterWin::PostCallback(bool success,
+ const std::string& key_data) {
+ callback_runner_->PostTask(FROM_HERE,
+ base::Bind(callback_, success, key_data));
+}
+
+} // namespace wifi
+} // namespace local_discovery

Powered by Google App Engine
This is Rietveld 408576698