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

Side by Side Diff: chrome/browser/google/google_update_win.cc

Issue 2792173003: Remove ScopedComPtr::iid() (Closed)
Patch Set: Created 3 years, 8 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 | « base/win/scoped_comptr_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/google/google_update_win.h" 5 #include "chrome/browser/google/google_update_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <objbase.h>
9 #include <stdint.h> 10 #include <stdint.h>
10 #include <string.h> 11 #include <string.h>
11 12
12 #include <string> 13 #include <string>
13 #include <utility> 14 #include <utility>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/bind.h" 17 #include "base/bind.h"
17 #include "base/callback.h" 18 #include "base/callback.h"
18 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 RPC_C_IMP_LEVEL_IMPERSONATE, 120 RPC_C_IMP_LEVEL_IMPERSONATE,
120 nullptr, 121 nullptr,
121 EOAC_DYNAMIC_CLOAKING); 122 EOAC_DYNAMIC_CLOAKING);
122 } 123 }
123 124
124 // Creates a class factory for a COM Local Server class using either plain 125 // Creates a class factory for a COM Local Server class using either plain
125 // vanilla CoGetClassObject, or using the Elevation moniker if running on 126 // vanilla CoGetClassObject, or using the Elevation moniker if running on
126 // Vista+. |hwnd| must refer to a foregound window in order to get the UAC 127 // Vista+. |hwnd| must refer to a foregound window in order to get the UAC
127 // prompt to appear in the foreground if running on Vista+. It can also be NULL 128 // prompt to appear in the foreground if running on Vista+. It can also be NULL
128 // if background UAC prompts are desired. 129 // if background UAC prompts are desired.
129 HRESULT CoGetClassObjectAsAdmin(REFCLSID class_id, 130 HRESULT CoGetClassObjectAsAdmin(gfx::AcceleratedWidget hwnd,
131 REFCLSID class_id,
130 REFIID interface_id, 132 REFIID interface_id,
131 gfx::AcceleratedWidget hwnd,
132 void** interface_ptr) { 133 void** interface_ptr) {
133 if (!interface_ptr) 134 if (!interface_ptr)
134 return E_POINTER; 135 return E_POINTER;
135 136
136 // For Vista+, need to instantiate the class factory via the elevation 137 // For Vista+, need to instantiate the class factory via the elevation
137 // moniker. This ensures that the UAC dialog shows up. 138 // moniker. This ensures that the UAC dialog shows up.
138 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 139 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
139 wchar_t class_id_as_string[MAX_PATH] = {}; 140 wchar_t class_id_as_string[MAX_PATH] = {};
140 StringFromGUID2(class_id, class_id_as_string, 141 StringFromGUID2(class_id, class_id_as_string,
141 arraysize(class_id_as_string)); 142 arraysize(class_id_as_string));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 // For a user-level install, update checks and updates can both be done by a 177 // For a user-level install, update checks and updates can both be done by a
177 // normal user with the UserClass. For a system-level install, update checks 178 // normal user with the UserClass. For a system-level install, update checks
178 // can be done by a normal user with the MachineClass. Newer versions of 179 // can be done by a normal user with the MachineClass. Newer versions of
179 // GoogleUpdate allow normal users to also install system-level updates 180 // GoogleUpdate allow normal users to also install system-level updates
180 // without requiring elevation. 181 // without requiring elevation.
181 if (!system_level_install || 182 if (!system_level_install ||
182 !install_update_if_possible || 183 !install_update_if_possible ||
183 !IsElevationRequiredForSystemLevelUpdates()) { 184 !IsElevationRequiredForSystemLevelUpdates()) {
184 hresult = ::CoGetClassObject(google_update_clsid, CLSCTX_ALL, nullptr, 185 hresult = ::CoGetClassObject(google_update_clsid, CLSCTX_ALL, nullptr,
185 base::win::ScopedComPtr<IClassFactory>::iid(), 186 IID_PPV_ARGS(&class_factory));
186 class_factory.ReceiveVoid());
187 } else { 187 } else {
188 // With older versions of GoogleUpdate, a system-level update requires Admin 188 // With older versions of GoogleUpdate, a system-level update requires Admin
189 // privileges. Elevate while instantiating the MachineClass. 189 // privileges. Elevate while instantiating the MachineClass.
190 hresult = CoGetClassObjectAsAdmin( 190 hresult = CoGetClassObjectAsAdmin(elevation_window, google_update_clsid,
191 google_update_clsid, base::win::ScopedComPtr<IClassFactory>::iid(), 191 IID_PPV_ARGS(&class_factory));
192 elevation_window, class_factory.ReceiveVoid());
193 } 192 }
194 if (FAILED(hresult)) 193 if (FAILED(hresult))
195 return hresult; 194 return hresult;
196 195
197 ConfigureProxyBlanket(class_factory.get()); 196 ConfigureProxyBlanket(class_factory.get());
198 197
199 return class_factory->CreateInstance( 198 return class_factory->CreateInstance(nullptr, IID_PPV_ARGS(google_update));
200 nullptr,
201 base::win::ScopedComPtr<IGoogleUpdate3Web>::iid(),
202 google_update->ReceiveVoid());
203 } 199 }
204 200
205 // UpdateCheckDriver ----------------------------------------------------------- 201 // UpdateCheckDriver -----------------------------------------------------------
206 202
207 // A driver that is created and destroyed on the caller's thread and drives 203 // A driver that is created and destroyed on the caller's thread and drives
208 // Google Update on another. 204 // Google Update on another.
209 class UpdateCheckDriver { 205 class UpdateCheckDriver {
210 public: 206 public:
211 // Runs an update check on |task_runner|, invoking methods of |delegate| on 207 // Runs an update check on |task_runner|, invoking methods of |delegate| on
212 // the caller's thread to report progress and final results. 208 // the caller's thread to report progress and final results.
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 const GoogleUpdate3ClassFactory& google_update_factory) { 883 const GoogleUpdate3ClassFactory& google_update_factory) {
888 if (g_google_update_factory) { 884 if (g_google_update_factory) {
889 delete g_google_update_factory; 885 delete g_google_update_factory;
890 g_google_update_factory = nullptr; 886 g_google_update_factory = nullptr;
891 } 887 }
892 if (!google_update_factory.is_null()) { 888 if (!google_update_factory.is_null()) {
893 g_google_update_factory = 889 g_google_update_factory =
894 new GoogleUpdate3ClassFactory(google_update_factory); 890 new GoogleUpdate3ClassFactory(google_update_factory);
895 } 891 }
896 } 892 }
OLDNEW
« no previous file with comments | « base/win/scoped_comptr_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698