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/advanced_firewall_manager_win.h" | 5 #include "chrome/installer/util/advanced_firewall_manager_win.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // same "rule identifier". It's not clear what is "rule identifier", but it | 73 // same "rule identifier". It's not clear what is "rule identifier", but it |
74 // can successfully create many rule with same name. | 74 // can successfully create many rule with same name. |
75 DeleteRuleByName(rule_name); | 75 DeleteRuleByName(rule_name); |
76 | 76 |
77 // Create the rule and add it to the rule set (only succeeds if elevated). | 77 // Create the rule and add it to the rule set (only succeeds if elevated). |
78 base::win::ScopedComPtr<INetFwRule> udp_rule = | 78 base::win::ScopedComPtr<INetFwRule> udp_rule = |
79 CreateUDPRule(rule_name, description, port); | 79 CreateUDPRule(rule_name, description, port); |
80 if (!udp_rule.get()) | 80 if (!udp_rule.get()) |
81 return false; | 81 return false; |
82 | 82 |
83 HRESULT hr = firewall_rules_->Add(udp_rule); | 83 HRESULT hr = firewall_rules_->Add(udp_rule.get()); |
84 DLOG_IF(ERROR, FAILED(hr)) << logging::SystemErrorCodeToString(hr); | 84 DLOG_IF(ERROR, FAILED(hr)) << logging::SystemErrorCodeToString(hr); |
85 return SUCCEEDED(hr); | 85 return SUCCEEDED(hr); |
86 } | 86 } |
87 | 87 |
88 void AdvancedFirewallManager::DeleteRuleByName( | 88 void AdvancedFirewallManager::DeleteRuleByName( |
89 const base::string16& rule_name) { | 89 const base::string16& rule_name) { |
90 std::vector<base::win::ScopedComPtr<INetFwRule> > rules; | 90 std::vector<base::win::ScopedComPtr<INetFwRule> > rules; |
91 GetAllRules(&rules); | 91 GetAllRules(&rules); |
92 for (size_t i = 0; i < rules.size(); ++i) { | 92 for (size_t i = 0; i < rules.size(); ++i) { |
93 base::win::ScopedBstr name; | 93 base::win::ScopedBstr name; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void AdvancedFirewallManager::GetAllRules( | 148 void AdvancedFirewallManager::GetAllRules( |
149 std::vector<base::win::ScopedComPtr<INetFwRule> >* rules) { | 149 std::vector<base::win::ScopedComPtr<INetFwRule> >* rules) { |
150 base::win::ScopedComPtr<IUnknown> rules_enum_unknown; | 150 base::win::ScopedComPtr<IUnknown> rules_enum_unknown; |
151 HRESULT hr = firewall_rules_->get__NewEnum(rules_enum_unknown.Receive()); | 151 HRESULT hr = firewall_rules_->get__NewEnum(rules_enum_unknown.Receive()); |
152 if (FAILED(hr)) { | 152 if (FAILED(hr)) { |
153 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 153 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
154 return; | 154 return; |
155 } | 155 } |
156 | 156 |
157 base::win::ScopedComPtr<IEnumVARIANT> rules_enum; | 157 base::win::ScopedComPtr<IEnumVARIANT> rules_enum; |
158 hr = rules_enum.QueryFrom(rules_enum_unknown); | 158 hr = rules_enum.QueryFrom(rules_enum_unknown.get()); |
159 if (FAILED(hr)) { | 159 if (FAILED(hr)) { |
160 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); | 160 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); |
161 return; | 161 return; |
162 } | 162 } |
163 | 163 |
164 for (;;) { | 164 for (;;) { |
165 base::win::ScopedVariant rule_var; | 165 base::win::ScopedVariant rule_var; |
166 hr = rules_enum->Next(1, rule_var.Receive(), NULL); | 166 hr = rules_enum->Next(1, rule_var.Receive(), NULL); |
167 DLOG_IF(ERROR, FAILED(hr)) << logging::SystemErrorCodeToString(hr); | 167 DLOG_IF(ERROR, FAILED(hr)) << logging::SystemErrorCodeToString(hr); |
168 if (hr != S_OK) | 168 if (hr != S_OK) |
(...skipping 21 matching lines...) Expand all Loading... |
190 !base::FilePath::CompareEqualIgnoreCase(static_cast<BSTR>(path), | 190 !base::FilePath::CompareEqualIgnoreCase(static_cast<BSTR>(path), |
191 app_path_.value())) { | 191 app_path_.value())) { |
192 continue; | 192 continue; |
193 } | 193 } |
194 | 194 |
195 rules->push_back(rule); | 195 rules->push_back(rule); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 } // namespace installer | 199 } // namespace installer |
OLD | NEW |