| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/local_discovery/wifi/credential_getter_win.h" | 5 #include "chrome/browser/local_discovery/wifi/credential_getter_win.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" |
| 7 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 8 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
| 8 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/utility_process_host.h" | 11 #include "content/public/browser/utility_process_host.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 12 | 13 |
| 13 namespace local_discovery { | 14 namespace local_discovery { |
| 14 | 15 |
| 15 namespace wifi { | 16 namespace wifi { |
| 16 | 17 |
| 17 CredentialGetterWin::CredentialGetterWin() { | 18 CredentialGetterWin::CredentialGetterWin() { |
| 18 } | 19 } |
| 19 | 20 |
| 20 void CredentialGetterWin::StartGetCredentials( | 21 void CredentialGetterWin::StartGetCredentials( |
| 21 const std::string& network_guid, | 22 const std::string& network_guid, |
| 22 const CredentialsCallback& callback) { | 23 const CredentialsCallback& callback) { |
| 23 callback_ = callback; | 24 callback_ = callback; |
| 24 callback_runner_ = base::MessageLoopProxy::current(); | 25 callback_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 25 content::BrowserThread::PostTask( | 26 content::BrowserThread::PostTask( |
| 26 content::BrowserThread::IO, | 27 content::BrowserThread::IO, |
| 27 FROM_HERE, | 28 FROM_HERE, |
| 28 base::Bind(&CredentialGetterWin::StartOnIOThread, this, network_guid)); | 29 base::Bind(&CredentialGetterWin::StartOnIOThread, this, network_guid)); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void CredentialGetterWin::StartOnIOThread(const std::string& network_guid) { | 32 void CredentialGetterWin::StartOnIOThread(const std::string& network_guid) { |
| 32 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 33 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 33 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( | 34 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( |
| 34 this, base::MessageLoopProxy::current()); | 35 this, base::ThreadTaskRunnerHandle::Get()); |
| 35 host->SetName(l10n_util::GetStringUTF16( | 36 host->SetName(l10n_util::GetStringUTF16( |
| 36 IDS_UTILITY_PROCESS_WIFI_CREDENTIALS_GETTER_NAME)); | 37 IDS_UTILITY_PROCESS_WIFI_CREDENTIALS_GETTER_NAME)); |
| 37 host->ElevatePrivileges(); | 38 host->ElevatePrivileges(); |
| 38 host->Send(new ChromeUtilityHostMsg_GetWiFiCredentials(network_guid)); | 39 host->Send(new ChromeUtilityHostMsg_GetWiFiCredentials(network_guid)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 CredentialGetterWin::~CredentialGetterWin() { | 42 CredentialGetterWin::~CredentialGetterWin() { |
| 42 } | 43 } |
| 43 | 44 |
| 44 bool CredentialGetterWin::OnMessageReceived(const IPC::Message& message) { | 45 bool CredentialGetterWin::OnMessageReceived(const IPC::Message& message) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 64 } | 65 } |
| 65 | 66 |
| 66 void CredentialGetterWin::PostCallback(bool success, | 67 void CredentialGetterWin::PostCallback(bool success, |
| 67 const std::string& key_data) { | 68 const std::string& key_data) { |
| 68 callback_runner_->PostTask(FROM_HERE, | 69 callback_runner_->PostTask(FROM_HERE, |
| 69 base::Bind(callback_, success, key_data)); | 70 base::Bind(callback_, success, key_data)); |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace wifi | 73 } // namespace wifi |
| 73 } // namespace local_discovery | 74 } // namespace local_discovery |
| OLD | NEW |