| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/media/router/media_route_provider_util_win.h" | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "base/location.h" | |
| 9 #include "base/logging.h" | |
| 10 #include "base/path_service.h" | |
| 11 #include "chrome/installer/util/browser_distribution.h" | |
| 12 #include "chrome/installer/util/firewall_manager_win.h" | |
| 13 #include "content/public/browser/browser_thread.h" | |
| 14 | |
| 15 namespace media_router { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 void DoCanFirewallUseLocalPorts(const base::Callback<void(bool)>& callback) { | |
| 20 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | |
| 21 base::FilePath exe_path; | |
| 22 bool can_use_local_ports = false; | |
| 23 if (!base::PathService::Get(base::FILE_EXE, &exe_path)) { | |
| 24 LOG(WARNING) << "Couldn't get path of current executable."; | |
| 25 return; | |
| 26 } | |
| 27 auto firewall_manager = installer::FirewallManager::Create( | |
| 28 BrowserDistribution::GetDistribution(), exe_path); | |
| 29 if (!firewall_manager) { | |
| 30 LOG(WARNING) << "Couldn't get FirewallManager instance."; | |
| 31 return; | |
| 32 } | |
| 33 can_use_local_ports = firewall_manager->CanUseLocalPorts(); | |
| 34 content::BrowserThread::PostTask( | |
| 35 content::BrowserThread::UI, FROM_HERE, | |
| 36 base::Bind(callback, can_use_local_ports)); | |
| 37 } | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 void CanFirewallUseLocalPorts(const base::Callback<void(bool)>& callback) { | |
| 42 content::BrowserThread::PostTask( | |
| 43 content::BrowserThread::FILE, FROM_HERE, | |
| 44 base::Bind(&DoCanFirewallUseLocalPorts, callback)); | |
| 45 } | |
| 46 | |
| 47 } // namespace media_router | |
| OLD | NEW |