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

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

Issue 282363003: Add WOW64 support to the installer registry work items (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: add wow64 logic to installer_util. mini_installer tests. Created 6 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
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 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
(...skipping 30 matching lines...) Expand all
41 #include "base/win/win_util.h" 41 #include "base/win/win_util.h"
42 #include "base/win/windows_version.h" 42 #include "base/win/windows_version.h"
43 #include "chrome/common/chrome_constants.h" 43 #include "chrome/common/chrome_constants.h"
44 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
45 #include "chrome/installer/util/browser_distribution.h" 45 #include "chrome/installer/util/browser_distribution.h"
46 #include "chrome/installer/util/install_util.h" 46 #include "chrome/installer/util/install_util.h"
47 #include "chrome/installer/util/l10n_string_util.h" 47 #include "chrome/installer/util/l10n_string_util.h"
48 #include "chrome/installer/util/master_preferences.h" 48 #include "chrome/installer/util/master_preferences.h"
49 #include "chrome/installer/util/master_preferences_constants.h" 49 #include "chrome/installer/util/master_preferences_constants.h"
50 #include "chrome/installer/util/util_constants.h" 50 #include "chrome/installer/util/util_constants.h"
51 #include "chrome/installer/util/work_item.h"
51 52
52 #include "installer_util_strings.h" // NOLINT 53 #include "installer_util_strings.h" // NOLINT
53 54
54 using base::win::RegKey; 55 using base::win::RegKey;
55 56
56 namespace { 57 namespace {
57 58
58 // An enum used to tell QuickIsChromeRegistered() which level of registration 59 // An enum used to tell QuickIsChromeRegistered() which level of registration
59 // the caller wants to confirm. 60 // the caller wants to confirm.
60 enum RegistrationConfirmationLevel { 61 enum RegistrationConfirmationLevel {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 525
525 // start->Internet shortcut. 526 // start->Internet shortcut.
526 base::string16 start_menu(ShellUtil::kRegStartMenuInternet); 527 base::string16 start_menu(ShellUtil::kRegStartMenuInternet);
527 base::string16 app_name = dist->GetBaseAppName() + suffix; 528 base::string16 app_name = dist->GetBaseAppName() + suffix;
528 entries->push_back(new RegistryEntry(start_menu, app_name)); 529 entries->push_back(new RegistryEntry(start_menu, app_name));
529 } 530 }
530 531
531 // Generate work_item tasks required to create current registry entry and 532 // Generate work_item tasks required to create current registry entry and
532 // add them to the given work item list. 533 // add them to the given work item list.
533 void AddToWorkItemList(HKEY root, WorkItemList *items) const { 534 void AddToWorkItemList(HKEY root, WorkItemList *items) const {
534 items->AddCreateRegKeyWorkItem(root, key_path_); 535 items->AddCreateRegKeyWorkItem(root, key_path_, wow64_access_);
535 if (is_string_) { 536 if (is_string_) {
536 items->AddSetRegValueWorkItem(root, key_path_, name_, value_, true); 537 items->AddSetRegValueWorkItem(
538 root, key_path_, name_, value_, true, wow64_access_);
537 } else { 539 } else {
538 items->AddSetRegValueWorkItem(root, key_path_, name_, int_value_, true); 540 items->AddSetRegValueWorkItem(
541 root, key_path_, name_, int_value_, true, wow64_access_);
539 } 542 }
540 } 543 }
541 544
542 // Checks if the current registry entry exists in HKCU\|key_path_|\|name_| 545 // Checks if the current registry entry exists in HKCU\|key_path_|\|name_|
543 // and value is |value_|. If the key does NOT exist in HKCU, checks for 546 // and value is |value_|. If the key does NOT exist in HKCU, checks for
544 // the correct name and value in HKLM. 547 // the correct name and value in HKLM.
545 // |look_for_in| specifies roots (HKCU and/or HKLM) in which to look for the 548 // |look_for_in| specifies roots (HKCU and/or HKLM) in which to look for the
546 // key, unspecified roots are not looked into (i.e. the the key is assumed not 549 // key, unspecified roots are not looked into (i.e. the the key is assumed not
547 // to exist in them). 550 // to exist in them).
548 // |look_for_in| must at least specify one root to look into. 551 // |look_for_in| must at least specify one root to look into.
(...skipping 19 matching lines...) Expand all
568 // |name_| does not exist in the registry 571 // |name_| does not exist in the registry
569 DOES_NOT_EXIST, 572 DOES_NOT_EXIST,
570 // |name_| exists, but its value != |value_| 573 // |name_| exists, but its value != |value_|
571 DIFFERENT_VALUE, 574 DIFFERENT_VALUE,
572 // |name_| exists and its value is |value_| 575 // |name_| exists and its value is |value_|
573 SAME_VALUE, 576 SAME_VALUE,
574 }; 577 };
575 578
576 // Create a object that represent default value of a key 579 // Create a object that represent default value of a key
577 RegistryEntry(const base::string16& key_path, const base::string16& value) 580 RegistryEntry(const base::string16& key_path, const base::string16& value)
578 : key_path_(key_path), name_(), 581 : key_path_(key_path),
579 is_string_(true), value_(value), int_value_(0) { 582 name_(),
580 } 583 wow64_access_(0), // TODO(wfh): Add support for WOW64 registry view.
grt (UTC plus 2) 2014/05/21 16:41:05 i don't know that this class will ever need to ove
Will Harris 2014/05/21 23:23:16 Done. I think 64-bit installers will have to remo
grt (UTC plus 2) 2014/05/22 01:37:44 Ah, good point. I'd forgotten about deleting the o
584 is_string_(true),
585 value_(value),
586 int_value_(0) {}
581 587
582 // Create a object that represent a key of type REG_SZ 588 // Create a object that represent a key of type REG_SZ
583 RegistryEntry(const base::string16& key_path, const base::string16& name, 589 RegistryEntry(const base::string16& key_path,
590 const base::string16& name,
584 const base::string16& value) 591 const base::string16& value)
585 : key_path_(key_path), name_(name), 592 : key_path_(key_path),
586 is_string_(true), value_(value), int_value_(0) { 593 name_(name),
587 } 594 wow64_access_(0),
595 is_string_(true),
596 value_(value),
597 int_value_(0) {}
588 598
589 // Create a object that represent a key of integer type 599 // Create a object that represent a key of integer type
590 RegistryEntry(const base::string16& key_path, const base::string16& name, 600 RegistryEntry(const base::string16& key_path,
601 const base::string16& name,
591 DWORD value) 602 DWORD value)
592 : key_path_(key_path), name_(name), 603 : key_path_(key_path),
593 is_string_(false), value_(), int_value_(value) { 604 name_(name),
594 } 605 wow64_access_(0),
606 is_string_(false),
607 value_(),
608 int_value_(value) {}
595 609
596 base::string16 key_path_; // key path for the registry entry 610 base::string16 key_path_; // key path for the registry entry
597 base::string16 name_; // name of the registry entry 611 base::string16 name_; // name of the registry entry
612 // Which view of the registry to use.
613 REGSAM wow64_access_;
598 bool is_string_; // true if current registry entry is of type REG_SZ 614 bool is_string_; // true if current registry entry is of type REG_SZ
599 base::string16 value_; // string value (useful if is_string_ = true) 615 base::string16 value_; // string value (useful if is_string_ = true)
600 DWORD int_value_; // integer value (useful if is_string_ = false) 616 DWORD int_value_; // integer value (useful if is_string_ = false)
601 617
602 // Helper function for ExistsInRegistry(). 618 // Helper function for ExistsInRegistry().
603 // Returns the RegistryStatus of the current registry entry in 619 // Returns the RegistryStatus of the current registry entry in
604 // |root|\|key_path_|\|name_|. 620 // |root|\|key_path_|\|name_|.
605 RegistryStatus StatusInRegistryUnderRoot(HKEY root) const { 621 RegistryStatus StatusInRegistryUnderRoot(HKEY root) const {
606 RegKey key(root, key_path_.c_str(), KEY_QUERY_VALUE); 622 RegKey key(root, key_path_.c_str(), KEY_QUERY_VALUE);
607 bool found = false; 623 bool found = false;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 // There's no need to rollback, so forgo the usual work item lists and just 1029 // There's no need to rollback, so forgo the usual work item lists and just
1014 // remove the key from the registry. 1030 // remove the key from the registry.
1015 base::string16 run_verb_key(ShellUtil::kRegClasses); 1031 base::string16 run_verb_key(ShellUtil::kRegClasses);
1016 run_verb_key.push_back(base::FilePath::kSeparators[0]); 1032 run_verb_key.push_back(base::FilePath::kSeparators[0]);
1017 run_verb_key.append(ShellUtil::GetBrowserModelId( 1033 run_verb_key.append(ShellUtil::GetBrowserModelId(
1018 dist, is_per_user_install)); 1034 dist, is_per_user_install));
1019 run_verb_key.append(ShellUtil::kRegExePath); 1035 run_verb_key.append(ShellUtil::kRegExePath);
1020 run_verb_key.append(ShellUtil::kRegShellPath); 1036 run_verb_key.append(ShellUtil::kRegShellPath);
1021 run_verb_key.push_back(base::FilePath::kSeparators[0]); 1037 run_verb_key.push_back(base::FilePath::kSeparators[0]);
1022 run_verb_key.append(ShellUtil::kRegVerbRun); 1038 run_verb_key.append(ShellUtil::kRegVerbRun);
1023 InstallUtil::DeleteRegistryKey(root_key, run_verb_key); 1039 InstallUtil::DeleteRegistryKey(root_key, run_verb_key,
1040 WorkItem::kWow64Default);
1024 } 1041 }
1025 } 1042 }
1026 1043
1027 // Gets the short (8.3) form of |path|, putting the result in |short_path| and 1044 // Gets the short (8.3) form of |path|, putting the result in |short_path| and
1028 // returning true on success. |short_path| is not modified on failure. 1045 // returning true on success. |short_path| is not modified on failure.
1029 bool ShortNameFromPath(const base::FilePath& path, base::string16* short_path) { 1046 bool ShortNameFromPath(const base::FilePath& path, base::string16* short_path) {
1030 DCHECK(short_path); 1047 DCHECK(short_path);
1031 base::string16 result(MAX_PATH, L'\0'); 1048 base::string16 result(MAX_PATH, L'\0');
1032 DWORD short_length = GetShortPathName(path.value().c_str(), &result[0], 1049 DWORD short_length = GetShortPathName(path.value().c_str(), &result[0],
1033 result.size()); 1050 result.size());
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 // are any left...). 2281 // are any left...).
2265 if (free_bits >= 8 && next_byte_index < size) { 2282 if (free_bits >= 8 && next_byte_index < size) {
2266 free_bits -= 8; 2283 free_bits -= 8;
2267 bit_stream += bytes[next_byte_index++] << free_bits; 2284 bit_stream += bytes[next_byte_index++] << free_bits;
2268 } 2285 }
2269 } 2286 }
2270 2287
2271 DCHECK_EQ(ret.length(), encoded_length); 2288 DCHECK_EQ(ret.length(), encoded_length);
2272 return ret; 2289 return ret;
2273 } 2290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698