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

Side by Side Diff: chrome/installer/util/fake_installation_state.h

Issue 2618583005: Remove support for non-browser products from InstallationState and ProductState. (Closed)
Patch Set: fix Created 3 years, 11 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 #ifndef CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_ 5 #ifndef CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
6 #define CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_ 6 #define CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "chrome/installer/util/fake_product_state.h" 10 #include "chrome/installer/util/fake_product_state.h"
11 #include "chrome/installer/util/helper.h" 11 #include "chrome/installer/util/helper.h"
12 #include "chrome/installer/util/installation_state.h" 12 #include "chrome/installer/util/installation_state.h"
13 #include "chrome/installer/util/util_constants.h" 13 #include "chrome/installer/util/util_constants.h"
14 14
15 namespace installer { 15 namespace installer {
16 16
17 // An InstallationState helper for use by unit tests. 17 // An InstallationState helper for use by unit tests.
18 class FakeInstallationState : public InstallationState { 18 class FakeInstallationState : public InstallationState {
19 public: 19 public:
20 // Takes ownership of |version|. 20 // Takes ownership of |version|.
21 void AddChrome(bool system_install, bool multi_install, 21 void AddChrome(bool system_install, base::Version* version) {
22 base::Version* version) {
23 FakeProductState chrome_state; 22 FakeProductState chrome_state;
24 chrome_state.set_version(version); 23 chrome_state.set_version(version);
25 chrome_state.set_multi_install(multi_install); 24 base::FilePath setup_exe(GetChromeInstallPath(
26 base::FilePath setup_exe( 25 system_install, BrowserDistribution::GetDistribution()));
27 GetChromeInstallPath(system_install,
28 BrowserDistribution::GetSpecificDistribution(
29 BrowserDistribution::CHROME_BROWSER)));
30 setup_exe = setup_exe 26 setup_exe = setup_exe
31 .AppendASCII(version->GetString()) 27 .AppendASCII(version->GetString())
32 .Append(kInstallerDir) 28 .Append(kInstallerDir)
33 .Append(kSetupExe); 29 .Append(kSetupExe);
34 chrome_state.SetUninstallProgram(setup_exe); 30 chrome_state.SetUninstallProgram(setup_exe);
35 chrome_state.AddUninstallSwitch(switches::kUninstall); 31 chrome_state.AddUninstallSwitch(switches::kUninstall);
36 if (multi_install) { 32 SetProductState(system_install, chrome_state);
37 chrome_state.AddUninstallSwitch(switches::kMultiInstall);
38 chrome_state.AddUninstallSwitch(switches::kChrome);
39 }
40 SetProductState(system_install, BrowserDistribution::CHROME_BROWSER,
41 chrome_state);
42 } 33 }
43 34
44 void SetProductState(bool system_install, 35 void SetProductState(bool system_install, const ProductState& product_state) {
45 BrowserDistribution::Type type, 36 ProductState& target = GetProduct(system_install);
huangs 2017/01/09 09:09:10 May as well combine into 1 line.
grt (UTC plus 2) 2017/01/09 10:11:45 Done.
46 const ProductState& product_state) {
47 ProductState& target = GetProducts(system_install)[IndexFromDistType(type)];
48 target.CopyFrom(product_state); 37 target.CopyFrom(product_state);
49 } 38 }
50 39
51 protected: 40 protected:
52 ProductState* GetProducts(bool system_install) { 41 ProductState& GetProduct(bool system_install) {
huangs 2017/01/09 09:09:10 For mutation, I think style requires ProductState*
grt (UTC plus 2) 2017/01/09 10:11:45 Done.
53 return system_install ? system_products_ : user_products_; 42 return system_install ? system_chrome_ : user_chrome_;
54 } 43 }
55 }; 44 };
56 45
57 } // namespace installer 46 } // namespace installer
58 47
59 #endif // CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_ 48 #endif // CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698