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

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

Issue 616173003: Allow Registry Iterator functions to use a specified WOW64 mode when iterating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review comments Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/app_commands.h" 5 #include "chrome/installer/util/app_commands.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/win/registry.h" 8 #include "base/win/registry.h"
9 #include "chrome/installer/util/google_update_constants.h" 9 #include "chrome/installer/util/google_update_constants.h"
10 #include "chrome/installer/util/work_item_list.h" 10 #include "chrome/installer/util/work_item_list.h"
11 11
12 using base::win::RegKey; 12 using base::win::RegKey;
13 13
14 namespace installer { 14 namespace installer {
15 15
16 AppCommands::AppCommands() { 16 AppCommands::AppCommands() {
17 } 17 }
18 18
19 AppCommands::~AppCommands() { 19 AppCommands::~AppCommands() {
20 } 20 }
21 21
22 bool AppCommands::Initialize(const base::win::RegKey& key) { 22 bool AppCommands::Initialize(const base::win::RegKey& key, REGSAM wow64access) {
23 if (!key.Valid()) { 23 if (!key.Valid()) {
24 LOG(DFATAL) << "Cannot initialize AppCommands from an invalid key."; 24 LOG(DFATAL) << "Cannot initialize AppCommands from an invalid key.";
25 return false; 25 return false;
26 } 26 }
27 27
28 if (wow64access != 0 && wow64access != KEY_WOW64_32KEY &&
29 wow64access != KEY_WOW64_64KEY) {
30 LOG(DFATAL) << "Invalid wow64access supplied to AppCommands.";
31 return false;
32 }
33
28 using base::win::RegistryKeyIterator; 34 using base::win::RegistryKeyIterator;
29 static const wchar_t kEmptyString[] = L""; 35 static const wchar_t kEmptyString[] = L"";
30 36
31 commands_.clear(); 37 commands_.clear();
32 38
33 RegKey cmd_key; 39 RegKey cmd_key;
34 LONG result; 40 LONG result;
35 AppCommand command; 41 AppCommand command;
36 for (RegistryKeyIterator key_iterator(key.Handle(), kEmptyString); 42 for (RegistryKeyIterator key_iterator(
37 key_iterator.Valid(); ++key_iterator) { 43 key.Handle(), kEmptyString, wow64access);
44 key_iterator.Valid();
45 ++key_iterator) {
38 const wchar_t* name = key_iterator.Name(); 46 const wchar_t* name = key_iterator.Name();
39 result = cmd_key.Open(key.Handle(), name, KEY_QUERY_VALUE); 47 result = cmd_key.Open(key.Handle(), name, KEY_QUERY_VALUE);
40 if (result != ERROR_SUCCESS) { 48 if (result != ERROR_SUCCESS) {
41 LOG(ERROR) << "Failed to open key \"" << name 49 LOG(ERROR) << "Failed to open key \"" << name
42 << "\" with last-error code " << result; 50 << "\" with last-error code " << result;
43 } else if (command.Initialize(cmd_key)) { 51 } else if (command.Initialize(cmd_key)) {
44 commands_[name] = command; 52 commands_[name] = command;
45 } else { 53 } else {
46 VLOG(1) << "Skipping over key \"" << name 54 VLOG(1) << "Skipping over key \"" << name
47 << "\" as it does not appear to hold a product command."; 55 << "\" as it does not appear to hold a product command.";
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 90
83 bool AppCommands::Remove(const std::wstring& command_id) { 91 bool AppCommands::Remove(const std::wstring& command_id) {
84 return commands_.erase(command_id) != 0; 92 return commands_.erase(command_id) != 0;
85 } 93 }
86 94
87 AppCommands::CommandMapRange AppCommands::GetIterators() const { 95 AppCommands::CommandMapRange AppCommands::GetIterators() const {
88 return std::make_pair(commands_.begin(), commands_.end()); 96 return std::make_pair(commands_.begin(), commands_.end());
89 } 97 }
90 98
91 } // namespace installer 99 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698