| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Contains functions for determining the product's InstallDetails at runtime. | 5 // Contains functions for determining the product's InstallDetails at runtime. |
| 6 | 6 |
| 7 #ifndef CHROME_INSTALL_STATIC_PRODUCT_INSTALL_DETAILS_H_ | 7 #ifndef CHROME_INSTALL_STATIC_PRODUCT_INSTALL_DETAILS_H_ |
| 8 #define CHROME_INSTALL_STATIC_PRODUCT_INSTALL_DETAILS_H_ | 8 #define CHROME_INSTALL_STATIC_PRODUCT_INSTALL_DETAILS_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 namespace install_static { | 13 namespace install_static { |
| 14 | 14 |
| 15 struct InstallConstants; | 15 struct InstallConstants; |
| 16 class InstallDetails; |
| 16 class PrimaryInstallDetails; | 17 class PrimaryInstallDetails; |
| 17 | 18 |
| 18 // Creates product details for the current process and sets them as the global | 19 // Creates product details for the current process and sets them as the global |
| 19 // InstallDetails for the process. This is intended to be called early in | 20 // InstallDetails for the process. This is intended to be called early in |
| 20 // process startup. A process's "primary" module may be the executable itself or | 21 // process startup. A process's "primary" module may be the executable itself or |
| 21 // may be another DLL that is loaded and initialized prior to executing the | 22 // may be another DLL that is loaded and initialized prior to executing the |
| 22 // executable's entrypoint (i.e., chrome_elf.dll). | 23 // executable's entrypoint (i.e., chrome_elf.dll). |
| 23 void InitializeProductDetailsForPrimaryModule(); | 24 void InitializeProductDetailsForPrimaryModule(); |
| 24 | 25 |
| 25 // Returns true if |parent| is a parent of |path|. Path separators at the end of | 26 // Returns true if |parent| is a parent of |path|. Path separators at the end of |
| 26 // |parent| are ignored. Returns false if |parent| is empty. | 27 // |parent| are ignored. Returns false if |parent| is empty. |
| 27 bool IsPathParentOf(const wchar_t* parent, | 28 bool IsPathParentOf(const wchar_t* parent, |
| 28 size_t parent_len, | 29 size_t parent_len, |
| 29 const std::wstring& path); | 30 const std::wstring& path); |
| 30 | 31 |
| 31 // Returns true if |path| is within C:\Program Files{, (x86)}. | 32 // Returns true if |path| is within C:\Program Files{, (x86)}. |
| 32 bool PathIsInProgramFiles(const std::wstring& path); | 33 bool PathIsInProgramFiles(const std::wstring& path); |
| 33 | 34 |
| 34 // Returns the install suffix embedded in |exe_path| or an empty string if none | 35 // Returns the install suffix embedded in |exe_path| or an empty string if none |
| 35 // is found. |exe_path| is expected be something similar to | 36 // is found. |exe_path| is expected be something similar to |
| 36 // "...\[kProductName][suffix]\Application". | 37 // "...\[kProductName][suffix]\Application". |
| 37 std::wstring GetInstallSuffix(const std::wstring& exe_path); | 38 std::wstring GetInstallSuffix(const std::wstring& exe_path); |
| 38 | 39 |
| 39 // Returns true if the browser of |mode| at |system_level| is registered as | 40 // Returns true if the browser of |mode| at |system_level| is registered as |
| 40 // being multi-install. | 41 // being multi-install. |
| 41 bool IsMultiInstall(const InstallConstants& mode, bool system_level); | 42 bool IsMultiInstall(const InstallConstants& mode, bool system_level); |
| 42 | 43 |
| 44 // Populates |result| with the default User Data directory for the current |
| 45 // user. Returns false if all attempts at locating a User Data directory fail. |
| 46 // TODO(ananta) |
| 47 // http://crbug.com/604923 |
| 48 // Unify this with the Browser Distribution code. |
| 49 bool GetDefaultUserDataDirectory(const InstallDetails& details, |
| 50 std::wstring* result); |
| 51 |
| 52 // Populates |result| with the user data dir, respecting various overrides in |
| 53 // the manner of chrome_main_delegate.cc InitializeUserDataDir(). This includes |
| 54 // overrides on the command line, overrides by registry policy, and fallback to |
| 55 // the default User Data dir if the directory is invalid or unspecified. |
| 56 // |
| 57 // If a directory was given by the user (either on the command line, or by |
| 58 // registry policy), but it was invalid or unusable, then |
| 59 // |invalid_supplied_directory| will be filled with the value that was unusable |
| 60 // for reporting an error to the user. |
| 61 // |
| 62 // Other than in test situations, it is generally only appropriate to call this |
| 63 // function once on startup and use the result for subsequent callers, otherwise |
| 64 // there's a race with registry modification (which could cause a different |
| 65 // derivation) so different subsystems would see different values). In normal |
| 66 // usage, this will be called once at startup and saved into InstallDetails |
| 67 // from where it should be retrieved. |
| 68 bool GetUserDataDirectory(const std::wstring& user_data_dir_from_command_line, |
| 69 const InstallDetails& details, |
| 70 std::wstring* result, |
| 71 std::wstring* invalid_supplied_directory); |
| 72 |
| 43 // Creates product details for the process at |exe_path|. | 73 // Creates product details for the process at |exe_path|. |
| 44 std::unique_ptr<PrimaryInstallDetails> MakeProductDetails( | 74 std::unique_ptr<PrimaryInstallDetails> MakeProductDetails( |
| 45 const std::wstring& exe_path); | 75 const std::wstring& exe_path); |
| 46 | 76 |
| 47 } // namespace install_static | 77 } // namespace install_static |
| 48 | 78 |
| 49 #endif // CHROME_INSTALL_STATIC_PRODUCT_INSTALL_DETAILS_H_ | 79 #endif // CHROME_INSTALL_STATIC_PRODUCT_INSTALL_DETAILS_H_ |
| OLD | NEW |