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

Side by Side Diff: chrome/installer/util/legacy_firewall_manager_win.cc

Issue 2870263002: Rename ScopedComPtr::Receive to ScopedComPtr::GetAddressOf (Closed)
Patch Set: Rebase to 2a6f440 Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « chrome/installer/util/advanced_firewall_manager_win.cc ('k') | chrome/installer/util/wmi.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/scoped_bstr.h" 8 #include "base/win/scoped_bstr.h"
9 9
10 namespace installer { 10 namespace installer {
11 11
12 LegacyFirewallManager::LegacyFirewallManager() {} 12 LegacyFirewallManager::LegacyFirewallManager() {}
13 13
14 LegacyFirewallManager::~LegacyFirewallManager() {} 14 LegacyFirewallManager::~LegacyFirewallManager() {}
15 15
16 bool LegacyFirewallManager::Init(const base::string16& app_name, 16 bool LegacyFirewallManager::Init(const base::string16& app_name,
17 const base::FilePath& app_path) { 17 const base::FilePath& app_path) {
18 base::win::ScopedComPtr<INetFwMgr> firewall_manager; 18 base::win::ScopedComPtr<INetFwMgr> firewall_manager;
19 HRESULT hr = firewall_manager.CreateInstance(CLSID_NetFwMgr); 19 HRESULT hr = firewall_manager.CreateInstance(CLSID_NetFwMgr);
20 if (FAILED(hr)) { 20 if (FAILED(hr)) {
21 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); 21 DLOG(ERROR) << logging::SystemErrorCodeToString(hr);
22 return false; 22 return false;
23 } 23 }
24 24
25 base::win::ScopedComPtr<INetFwPolicy> firewall_policy; 25 base::win::ScopedComPtr<INetFwPolicy> firewall_policy;
26 hr = firewall_manager->get_LocalPolicy(firewall_policy.Receive()); 26 hr = firewall_manager->get_LocalPolicy(firewall_policy.GetAddressOf());
27 if (FAILED(hr)) { 27 if (FAILED(hr)) {
28 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); 28 DLOG(ERROR) << logging::SystemErrorCodeToString(hr);
29 return false; 29 return false;
30 } 30 }
31 31
32 hr = firewall_policy->get_CurrentProfile(current_profile_.Receive()); 32 hr = firewall_policy->get_CurrentProfile(current_profile_.GetAddressOf());
33 if (FAILED(hr)) { 33 if (FAILED(hr)) {
34 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); 34 DLOG(ERROR) << logging::SystemErrorCodeToString(hr);
35 current_profile_ = NULL; 35 current_profile_ = NULL;
36 return false; 36 return false;
37 } 37 }
38 38
39 app_name_ = app_name; 39 app_name_ = app_name;
40 app_path_ = app_path; 40 app_path_ = app_path;
41 return true; 41 return true;
42 } 42 }
43 43
44 bool LegacyFirewallManager::IsFirewallEnabled() { 44 bool LegacyFirewallManager::IsFirewallEnabled() {
45 VARIANT_BOOL is_enabled = VARIANT_TRUE; 45 VARIANT_BOOL is_enabled = VARIANT_TRUE;
46 HRESULT hr = current_profile_->get_FirewallEnabled(&is_enabled); 46 HRESULT hr = current_profile_->get_FirewallEnabled(&is_enabled);
47 return SUCCEEDED(hr) && is_enabled != VARIANT_FALSE; 47 return SUCCEEDED(hr) && is_enabled != VARIANT_FALSE;
48 } 48 }
49 49
50 bool LegacyFirewallManager::GetAllowIncomingConnection(bool* value) { 50 bool LegacyFirewallManager::GetAllowIncomingConnection(bool* value) {
51 // Otherwise, check to see if there is a rule either allowing or disallowing 51 // Otherwise, check to see if there is a rule either allowing or disallowing
52 // this chrome.exe. 52 // this chrome.exe.
53 base::win::ScopedComPtr<INetFwAuthorizedApplications> authorized_apps( 53 base::win::ScopedComPtr<INetFwAuthorizedApplications> authorized_apps(
54 GetAuthorizedApplications()); 54 GetAuthorizedApplications());
55 if (!authorized_apps.Get()) 55 if (!authorized_apps.Get())
56 return false; 56 return false;
57 57
58 base::win::ScopedComPtr<INetFwAuthorizedApplication> chrome_application; 58 base::win::ScopedComPtr<INetFwAuthorizedApplication> chrome_application;
59 HRESULT hr = authorized_apps->Item( 59 HRESULT hr =
60 base::win::ScopedBstr(app_path_.value().c_str()), 60 authorized_apps->Item(base::win::ScopedBstr(app_path_.value().c_str()),
61 chrome_application.Receive()); 61 chrome_application.GetAddressOf());
62 if (FAILED(hr)) 62 if (FAILED(hr))
63 return false; 63 return false;
64 VARIANT_BOOL is_enabled = VARIANT_FALSE; 64 VARIANT_BOOL is_enabled = VARIANT_FALSE;
65 hr = chrome_application->get_Enabled(&is_enabled); 65 hr = chrome_application->get_Enabled(&is_enabled);
66 if (FAILED(hr)) 66 if (FAILED(hr))
67 return false; 67 return false;
68 if (value) 68 if (value)
69 *value = (is_enabled == VARIANT_TRUE); 69 *value = (is_enabled == VARIANT_TRUE);
70 return true; 70 return true;
71 } 71 }
(...skipping 19 matching lines...) Expand all
91 base::win::ScopedComPtr<INetFwAuthorizedApplications> authorized_apps( 91 base::win::ScopedComPtr<INetFwAuthorizedApplications> authorized_apps(
92 GetAuthorizedApplications()); 92 GetAuthorizedApplications());
93 if (!authorized_apps.Get()) 93 if (!authorized_apps.Get())
94 return; 94 return;
95 authorized_apps->Remove(base::win::ScopedBstr(app_path_.value().c_str())); 95 authorized_apps->Remove(base::win::ScopedBstr(app_path_.value().c_str()));
96 } 96 }
97 97
98 base::win::ScopedComPtr<INetFwAuthorizedApplications> 98 base::win::ScopedComPtr<INetFwAuthorizedApplications>
99 LegacyFirewallManager::GetAuthorizedApplications() { 99 LegacyFirewallManager::GetAuthorizedApplications() {
100 base::win::ScopedComPtr<INetFwAuthorizedApplications> authorized_apps; 100 base::win::ScopedComPtr<INetFwAuthorizedApplications> authorized_apps;
101 HRESULT hr = 101 HRESULT hr = current_profile_->get_AuthorizedApplications(
102 current_profile_->get_AuthorizedApplications(authorized_apps.Receive()); 102 authorized_apps.GetAddressOf());
103 if (FAILED(hr)) { 103 if (FAILED(hr)) {
104 DLOG(ERROR) << logging::SystemErrorCodeToString(hr); 104 DLOG(ERROR) << logging::SystemErrorCodeToString(hr);
105 return base::win::ScopedComPtr<INetFwAuthorizedApplications>(); 105 return base::win::ScopedComPtr<INetFwAuthorizedApplications>();
106 } 106 }
107 107
108 return authorized_apps; 108 return authorized_apps;
109 } 109 }
110 110
111 base::win::ScopedComPtr<INetFwAuthorizedApplication> 111 base::win::ScopedComPtr<INetFwAuthorizedApplication>
112 LegacyFirewallManager::CreateChromeAuthorization(bool allow) { 112 LegacyFirewallManager::CreateChromeAuthorization(bool allow) {
(...skipping 11 matching lines...) Expand all
124 base::win::ScopedBstr(app_path_.value().c_str())); 124 base::win::ScopedBstr(app_path_.value().c_str()));
125 // IpVersion defaults to NET_FW_IP_VERSION_ANY. 125 // IpVersion defaults to NET_FW_IP_VERSION_ANY.
126 // Scope defaults to NET_FW_SCOPE_ALL. 126 // Scope defaults to NET_FW_SCOPE_ALL.
127 // RemoteAddresses defaults to "*". 127 // RemoteAddresses defaults to "*".
128 chrome_application->put_Enabled(allow ? VARIANT_TRUE : VARIANT_FALSE); 128 chrome_application->put_Enabled(allow ? VARIANT_TRUE : VARIANT_FALSE);
129 129
130 return chrome_application; 130 return chrome_application;
131 } 131 }
132 132
133 } // namespace installer 133 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/advanced_firewall_manager_win.cc ('k') | chrome/installer/util/wmi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698