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/installer/util/legacy_firewall_manager_win.h" | 5 #include "chrome/installer/util/legacy_firewall_manager_win.h" |
6 | 6 |
| 7 #include <objbase.h> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/win/scoped_bstr.h" | 10 #include "base/win/scoped_bstr.h" |
9 | 11 |
10 namespace installer { | 12 namespace installer { |
11 | 13 |
12 LegacyFirewallManager::LegacyFirewallManager() {} | 14 LegacyFirewallManager::LegacyFirewallManager() {} |
13 | 15 |
14 LegacyFirewallManager::~LegacyFirewallManager() {} | 16 LegacyFirewallManager::~LegacyFirewallManager() {} |
15 | 17 |
16 bool LegacyFirewallManager::Init(const base::string16& app_name, | 18 bool LegacyFirewallManager::Init(const base::string16& app_name, |
17 const base::FilePath& app_path) { | 19 const base::FilePath& app_path) { |
18 base::win::ScopedComPtr<INetFwMgr> firewall_manager; | 20 base::win::ScopedComPtr<INetFwMgr> firewall_manager; |
19 HRESULT hr = firewall_manager.CreateInstance(CLSID_NetFwMgr); | 21 HRESULT hr = ::CoCreateInstance(CLSID_NetFwMgr, nullptr, CLSCTX_ALL, |
| 22 IID_PPV_ARGS(&firewall_manager)); |
20 if (FAILED(hr)) { | 23 if (FAILED(hr)) { |
21 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 24 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
22 return false; | 25 return false; |
23 } | 26 } |
24 | 27 |
25 base::win::ScopedComPtr<INetFwPolicy> firewall_policy; | 28 base::win::ScopedComPtr<INetFwPolicy> firewall_policy; |
26 hr = firewall_manager->get_LocalPolicy(firewall_policy.GetAddressOf()); | 29 hr = firewall_manager->get_LocalPolicy(firewall_policy.GetAddressOf()); |
27 if (FAILED(hr)) { | 30 if (FAILED(hr)) { |
28 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 31 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
29 return false; | 32 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 109 } |
107 | 110 |
108 return authorized_apps; | 111 return authorized_apps; |
109 } | 112 } |
110 | 113 |
111 base::win::ScopedComPtr<INetFwAuthorizedApplication> | 114 base::win::ScopedComPtr<INetFwAuthorizedApplication> |
112 LegacyFirewallManager::CreateChromeAuthorization(bool allow) { | 115 LegacyFirewallManager::CreateChromeAuthorization(bool allow) { |
113 base::win::ScopedComPtr<INetFwAuthorizedApplication> chrome_application; | 116 base::win::ScopedComPtr<INetFwAuthorizedApplication> chrome_application; |
114 | 117 |
115 HRESULT hr = | 118 HRESULT hr = |
116 chrome_application.CreateInstance(CLSID_NetFwAuthorizedApplication); | 119 ::CoCreateInstance(CLSID_NetFwAuthorizedApplication, nullptr, CLSCTX_ALL, |
| 120 IID_PPV_ARGS(&chrome_application)); |
117 if (FAILED(hr)) { | 121 if (FAILED(hr)) { |
118 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 122 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
119 return base::win::ScopedComPtr<INetFwAuthorizedApplication>(); | 123 return base::win::ScopedComPtr<INetFwAuthorizedApplication>(); |
120 } | 124 } |
121 | 125 |
122 chrome_application->put_Name(base::win::ScopedBstr(app_name_.c_str())); | 126 chrome_application->put_Name(base::win::ScopedBstr(app_name_.c_str())); |
123 chrome_application->put_ProcessImageFileName( | 127 chrome_application->put_ProcessImageFileName( |
124 base::win::ScopedBstr(app_path_.value().c_str())); | 128 base::win::ScopedBstr(app_path_.value().c_str())); |
125 // IpVersion defaults to NET_FW_IP_VERSION_ANY. | 129 // IpVersion defaults to NET_FW_IP_VERSION_ANY. |
126 // Scope defaults to NET_FW_SCOPE_ALL. | 130 // Scope defaults to NET_FW_SCOPE_ALL. |
127 // RemoteAddresses defaults to "*". | 131 // RemoteAddresses defaults to "*". |
128 chrome_application->put_Enabled(allow ? VARIANT_TRUE : VARIANT_FALSE); | 132 chrome_application->put_Enabled(allow ? VARIANT_TRUE : VARIANT_FALSE); |
129 | 133 |
130 return chrome_application; | 134 return chrome_application; |
131 } | 135 } |
132 | 136 |
133 } // namespace installer | 137 } // namespace installer |
OLD | NEW |