OLD | NEW |
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" |
11 | 11 |
12 #include <windows.h> | 12 #include <windows.h> |
13 #include <shlobj.h> | 13 #include <shlobj.h> |
14 #include <shobjidl.h> | 14 #include <shobjidl.h> |
15 | 15 |
16 #include <limits> | 16 #include <limits> |
17 #include <memory> | 17 #include <memory> |
18 #include <string> | 18 #include <string> |
19 | 19 |
| 20 #include "base/base32.h" |
20 #include "base/bind.h" | 21 #include "base/bind.h" |
21 #include "base/command_line.h" | 22 #include "base/command_line.h" |
22 #include "base/files/file_enumerator.h" | 23 #include "base/files/file_enumerator.h" |
23 #include "base/files/file_path.h" | 24 #include "base/files/file_path.h" |
24 #include "base/files/file_util.h" | 25 #include "base/files/file_util.h" |
25 #include "base/lazy_instance.h" | 26 #include "base/lazy_instance.h" |
26 #include "base/logging.h" | 27 #include "base/logging.h" |
27 #include "base/macros.h" | 28 #include "base/macros.h" |
28 #include "base/md5.h" | 29 #include "base/md5.h" |
29 #include "base/memory/scoped_vector.h" | 30 #include "base/memory/scoped_vector.h" |
(...skipping 20 matching lines...) Expand all Loading... |
50 #include "chrome/installer/util/browser_distribution.h" | 51 #include "chrome/installer/util/browser_distribution.h" |
51 #include "chrome/installer/util/install_util.h" | 52 #include "chrome/installer/util/install_util.h" |
52 #include "chrome/installer/util/installer_util_strings.h" | 53 #include "chrome/installer/util/installer_util_strings.h" |
53 #include "chrome/installer/util/l10n_string_util.h" | 54 #include "chrome/installer/util/l10n_string_util.h" |
54 #include "chrome/installer/util/master_preferences.h" | 55 #include "chrome/installer/util/master_preferences.h" |
55 #include "chrome/installer/util/master_preferences_constants.h" | 56 #include "chrome/installer/util/master_preferences_constants.h" |
56 #include "chrome/installer/util/registry_entry.h" | 57 #include "chrome/installer/util/registry_entry.h" |
57 #include "chrome/installer/util/scoped_user_protocol_entry.h" | 58 #include "chrome/installer/util/scoped_user_protocol_entry.h" |
58 #include "chrome/installer/util/util_constants.h" | 59 #include "chrome/installer/util/util_constants.h" |
59 #include "chrome/installer/util/work_item.h" | 60 #include "chrome/installer/util/work_item.h" |
60 #include "components/base32/base32.h" | |
61 | 61 |
62 using base::win::RegKey; | 62 using base::win::RegKey; |
63 | 63 |
64 namespace { | 64 namespace { |
65 | 65 |
66 // An enum used to tell QuickIsChromeRegistered() which level of registration | 66 // An enum used to tell QuickIsChromeRegistered() which level of registration |
67 // the caller wants to confirm. | 67 // the caller wants to confirm. |
68 enum RegistrationConfirmationLevel { | 68 enum RegistrationConfirmationLevel { |
69 // Only look for Chrome's ProgIds. | 69 // Only look for Chrome's ProgIds. |
70 // This is sufficient when we are trying to determine the suffix of the | 70 // This is sufficient when we are trying to determine the suffix of the |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 UserSpecificRegistrySuffix::UserSpecificRegistrySuffix() { | 130 UserSpecificRegistrySuffix::UserSpecificRegistrySuffix() { |
131 base::string16 user_sid; | 131 base::string16 user_sid; |
132 if (!base::win::GetUserSidString(&user_sid)) { | 132 if (!base::win::GetUserSidString(&user_sid)) { |
133 NOTREACHED(); | 133 NOTREACHED(); |
134 return; | 134 return; |
135 } | 135 } |
136 static_assert(sizeof(base::MD5Digest) == 16, "size of MD5 not as expected"); | 136 static_assert(sizeof(base::MD5Digest) == 16, "size of MD5 not as expected"); |
137 base::MD5Digest md5_digest; | 137 base::MD5Digest md5_digest; |
138 std::string user_sid_ascii(base::UTF16ToASCII(user_sid)); | 138 std::string user_sid_ascii(base::UTF16ToASCII(user_sid)); |
139 base::MD5Sum(user_sid_ascii.c_str(), user_sid_ascii.length(), &md5_digest); | 139 base::MD5Sum(user_sid_ascii.c_str(), user_sid_ascii.length(), &md5_digest); |
140 std::string base32_md5 = base32::Base32Encode( | 140 std::string base32_md5 = base::Base32Encode( |
141 base::StringPiece(reinterpret_cast<char*>(md5_digest.a), | 141 base::StringPiece(reinterpret_cast<char*>(md5_digest.a), |
142 arraysize(md5_digest.a)), | 142 arraysize(md5_digest.a)), |
143 base32::Base32EncodePolicy::OMIT_PADDING); | 143 base::Base32EncodePolicy::OMIT_PADDING); |
144 // The value returned by the base32 algorithm above must never change. | 144 // The value returned by the base32 algorithm above must never change. |
145 DCHECK_EQ(base32_md5.length(), 26U); | 145 DCHECK_EQ(base32_md5.length(), 26U); |
146 suffix_.reserve(base32_md5.length() + 1); | 146 suffix_.reserve(base32_md5.length() + 1); |
147 suffix_.assign(1, L'.'); | 147 suffix_.assign(1, L'.'); |
148 suffix_.append(base::ASCIIToUTF16(base32_md5)); | 148 suffix_.append(base::ASCIIToUTF16(base32_md5)); |
149 } | 149 } |
150 | 150 |
151 bool UserSpecificRegistrySuffix::GetSuffix(base::string16* suffix) { | 151 bool UserSpecificRegistrySuffix::GetSuffix(base::string16* suffix) { |
152 if (suffix_.empty()) { | 152 if (suffix_.empty()) { |
153 NOTREACHED(); | 153 NOTREACHED(); |
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 itr != entries.end(); ++itr) | 2331 itr != entries.end(); ++itr) |
2332 (*itr)->AddToWorkItemList(root, items.get()); | 2332 (*itr)->AddToWorkItemList(root, items.get()); |
2333 | 2333 |
2334 // Apply all the registry changes and if there is a problem, rollback | 2334 // Apply all the registry changes and if there is a problem, rollback |
2335 if (!items->Do()) { | 2335 if (!items->Do()) { |
2336 items->Rollback(); | 2336 items->Rollback(); |
2337 return false; | 2337 return false; |
2338 } | 2338 } |
2339 return true; | 2339 return true; |
2340 } | 2340 } |
OLD | NEW |