| 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 #include "chrome/installer/util/product.h" | 5 #include "chrome/installer/util/product.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/process/launch.h" | 11 #include "base/process/launch.h" |
| 12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
| 13 #include "chrome/installer/util/browser_distribution.h" | 13 #include "chrome/installer/util/browser_distribution.h" |
| 14 #include "chrome/installer/util/chrome_browser_operations.h" | 14 #include "chrome/installer/util/chrome_browser_operations.h" |
| 15 #include "chrome/installer/util/chrome_browser_sxs_operations.h" | 15 #include "chrome/installer/util/chrome_browser_sxs_operations.h" |
| 16 #include "chrome/installer/util/google_update_constants.h" | 16 #include "chrome/installer/util/google_update_constants.h" |
| 17 #include "chrome/installer/util/install_util.h" | 17 #include "chrome/installer/util/install_util.h" |
| 18 #include "chrome/installer/util/master_preferences.h" | |
| 19 #include "chrome/installer/util/master_preferences_constants.h" | |
| 20 #include "chrome/installer/util/product_operations.h" | 18 #include "chrome/installer/util/product_operations.h" |
| 21 | 19 |
| 22 using base::win::RegKey; | 20 using base::win::RegKey; |
| 23 using installer::MasterPreferences; | |
| 24 | 21 |
| 25 namespace installer { | 22 namespace installer { |
| 26 | 23 |
| 27 Product::Product(BrowserDistribution* distribution) | 24 Product::Product(BrowserDistribution* distribution) |
| 28 : distribution_(distribution), | 25 : distribution_(distribution), |
| 29 operations_(InstallUtil::IsChromeSxSProcess() | 26 operations_(InstallUtil::IsChromeSxSProcess() |
| 30 ? new ChromeBrowserSxSOperations() | 27 ? new ChromeBrowserSxSOperations() |
| 31 : new ChromeBrowserOperations()) {} | 28 : new ChromeBrowserOperations()) {} |
| 32 | 29 |
| 33 Product::~Product() { | 30 Product::~Product() { |
| 34 } | 31 } |
| 35 | 32 |
| 36 void Product::InitializeFromPreferences(const MasterPreferences& prefs) { | |
| 37 operations_->ReadOptions(prefs, &options_); | |
| 38 } | |
| 39 | |
| 40 void Product::InitializeFromUninstallCommand( | |
| 41 const base::CommandLine& uninstall_command) { | |
| 42 operations_->ReadOptions(uninstall_command, &options_); | |
| 43 } | |
| 44 | |
| 45 bool Product::LaunchChrome(const base::FilePath& application_path) const { | 33 bool Product::LaunchChrome(const base::FilePath& application_path) const { |
| 46 bool success = !application_path.empty(); | 34 bool success = !application_path.empty(); |
| 47 if (success) { | 35 if (success) { |
| 48 base::CommandLine cmd(application_path.Append(installer::kChromeExe)); | 36 base::CommandLine cmd(application_path.Append(installer::kChromeExe)); |
| 49 success = base::LaunchProcess(cmd, base::LaunchOptions()).IsValid(); | 37 success = base::LaunchProcess(cmd, base::LaunchOptions()).IsValid(); |
| 50 } | 38 } |
| 51 return success; | 39 return success; |
| 52 } | 40 } |
| 53 | 41 |
| 54 bool Product::LaunchChromeAndWait(const base::FilePath& application_path, | 42 bool Product::LaunchChromeAndWait(const base::FilePath& application_path, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { | 93 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) { |
| 106 LOG(ERROR) | 94 LOG(ERROR) |
| 107 << "Failed to Open or Write MSI value to client state key. error: " | 95 << "Failed to Open or Write MSI value to client state key. error: " |
| 108 << result; | 96 << result; |
| 109 return false; | 97 return false; |
| 110 } | 98 } |
| 111 return true; | 99 return true; |
| 112 } | 100 } |
| 113 | 101 |
| 114 void Product::AddKeyFiles(std::vector<base::FilePath>* key_files) const { | 102 void Product::AddKeyFiles(std::vector<base::FilePath>* key_files) const { |
| 115 operations_->AddKeyFiles(options_, key_files); | 103 operations_->AddKeyFiles(key_files); |
| 116 } | 104 } |
| 117 | 105 |
| 118 void Product::AppendProductFlags(base::CommandLine* command_line) const { | 106 void Product::AppendProductFlags(base::CommandLine* command_line) const { |
| 119 operations_->AppendProductFlags(options_, command_line); | 107 operations_->AppendProductFlags(command_line); |
| 120 } | 108 } |
| 121 | 109 |
| 122 void Product::AppendRenameFlags(base::CommandLine* command_line) const { | 110 void Product::AppendRenameFlags(base::CommandLine* command_line) const { |
| 123 operations_->AppendRenameFlags(options_, command_line); | 111 operations_->AppendRenameFlags(command_line); |
| 124 } | |
| 125 | |
| 126 bool Product::SetChannelFlags(bool set, ChannelInfo* channel_info) const { | |
| 127 return operations_->SetChannelFlags(options_, set, channel_info); | |
| 128 } | 112 } |
| 129 | 113 |
| 130 void Product::AddDefaultShortcutProperties( | 114 void Product::AddDefaultShortcutProperties( |
| 131 const base::FilePath& target_exe, | 115 const base::FilePath& target_exe, |
| 132 ShellUtil::ShortcutProperties* properties) const { | 116 ShellUtil::ShortcutProperties* properties) const { |
| 133 return operations_->AddDefaultShortcutProperties( | 117 return operations_->AddDefaultShortcutProperties( |
| 134 distribution_, target_exe, properties); | 118 distribution_, target_exe, properties); |
| 135 } | 119 } |
| 136 | 120 |
| 137 void Product::LaunchUserExperiment(const base::FilePath& setup_path, | 121 void Product::LaunchUserExperiment(const base::FilePath& setup_path, |
| 138 InstallStatus status, | 122 InstallStatus status, |
| 139 bool system_level) const { | 123 bool system_level) const { |
| 140 if (distribution_->HasUserExperiments()) { | 124 if (distribution_->HasUserExperiments()) { |
| 141 VLOG(1) << "LaunchUserExperiment status: " << status << " product: " | 125 VLOG(1) << "LaunchUserExperiment status: " << status << " product: " |
| 142 << distribution_->GetDisplayName() | 126 << distribution_->GetDisplayName() |
| 143 << " system_level: " << system_level; | 127 << " system_level: " << system_level; |
| 144 operations_->LaunchUserExperiment( | 128 operations_->LaunchUserExperiment(setup_path, status, system_level); |
| 145 setup_path, options_, status, system_level); | |
| 146 } | 129 } |
| 147 } | 130 } |
| 148 | 131 |
| 149 } // namespace installer | 132 } // namespace installer |
| OLD | NEW |