OLD | NEW |
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 // This file defines a class that contains various method related to branding. | 5 // This file defines a class that contains various method related to branding. |
6 // It provides only default implementations of these methods. Usually to add | 6 // It provides only default implementations of these methods. Usually to add |
7 // specific branding, we will need to extend this class with a custom | 7 // specific branding, we will need to extend this class with a custom |
8 // implementation. | 8 // implementation. |
9 | 9 |
10 #include "chrome/installer/util/browser_distribution.h" | 10 #include "chrome/installer/util/browser_distribution.h" |
11 | 11 |
12 #include "base/atomicops.h" | 12 #include "base/atomicops.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/lock.h" | 16 #include "base/lock.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/win/registry.h" | 18 #include "base/win/registry.h" |
19 #include "chrome/common/env_vars.h" | 19 #include "chrome/common/env_vars.h" |
20 #include "chrome/installer/util/chrome_frame_distribution.h" | 20 #include "chrome/installer/util/chrome_frame_distribution.h" |
| 21 #include "chrome/installer/util/chromium_binaries_distribution.h" |
21 #include "chrome/installer/util/google_chrome_distribution.h" | 22 #include "chrome/installer/util/google_chrome_distribution.h" |
| 23 #include "chrome/installer/util/google_chrome_binaries_distribution.h" |
22 #include "chrome/installer/util/google_chrome_sxs_distribution.h" | 24 #include "chrome/installer/util/google_chrome_sxs_distribution.h" |
23 #include "chrome/installer/util/install_util.h" | 25 #include "chrome/installer/util/install_util.h" |
24 #include "chrome/installer/util/l10n_string_util.h" | 26 #include "chrome/installer/util/l10n_string_util.h" |
25 #include "chrome/installer/util/master_preferences.h" | 27 #include "chrome/installer/util/master_preferences.h" |
26 | 28 |
27 #include "installer_util_strings.h" // NOLINT | 29 #include "installer_util_strings.h" // NOLINT |
28 | 30 |
29 using installer::MasterPreferences; | 31 using installer::MasterPreferences; |
30 | 32 |
31 namespace { | 33 namespace { |
32 // The BrowserDistribution objects are never freed. | 34 // The BrowserDistribution objects are never freed. |
33 BrowserDistribution* g_browser_distribution = NULL; | 35 BrowserDistribution* g_browser_distribution = NULL; |
34 BrowserDistribution* g_chrome_frame_distribution = NULL; | 36 BrowserDistribution* g_chrome_frame_distribution = NULL; |
| 37 BrowserDistribution* g_binaries_distribution = NULL; |
35 | 38 |
36 // Returns true if currently running in npchrome_frame.dll | 39 // Returns true if currently running in npchrome_frame.dll |
37 bool IsChromeFrameModule() { | 40 bool IsChromeFrameModule() { |
38 FilePath module_path; | 41 FilePath module_path; |
39 PathService::Get(base::FILE_MODULE, &module_path); | 42 PathService::Get(base::FILE_MODULE, &module_path); |
40 return FilePath::CompareEqualIgnoreCase(module_path.BaseName().value(), | 43 return FilePath::CompareEqualIgnoreCase(module_path.BaseName().value(), |
41 installer::kChromeFrameDll); | 44 installer::kChromeFrameDll); |
42 } | 45 } |
43 | 46 |
44 // Returns true if currently running in ceee_broker.exe | 47 // Returns true if currently running in ceee_broker.exe |
45 bool IsCeeeBrokerProcess() { | 48 bool IsCeeeBrokerProcess() { |
46 FilePath exe_path; | 49 FilePath exe_path; |
47 PathService::Get(base::FILE_EXE, &exe_path); | 50 PathService::Get(base::FILE_EXE, &exe_path); |
48 return FilePath::CompareEqualIgnoreCase(exe_path.BaseName().value(), | 51 return FilePath::CompareEqualIgnoreCase(exe_path.BaseName().value(), |
49 installer::kCeeeBrokerExe); | 52 installer::kCeeeBrokerExe); |
50 } | 53 } |
51 | 54 |
52 BrowserDistribution::Type GetCurrentDistributionType() { | 55 BrowserDistribution::Type GetCurrentDistributionType() { |
53 static BrowserDistribution::Type type = | 56 static BrowserDistribution::Type type = |
54 (MasterPreferences::ForCurrentProcess().install_chrome_frame() || | 57 (MasterPreferences::ForCurrentProcess().install_chrome_frame() || |
55 IsChromeFrameModule()) ? | 58 IsChromeFrameModule()) ? |
56 BrowserDistribution::CHROME_FRAME : | 59 BrowserDistribution::CHROME_FRAME : |
57 BrowserDistribution::CHROME_BROWSER; | 60 BrowserDistribution::CHROME_BROWSER; |
58 return type; | 61 return type; |
59 } | 62 } |
60 | 63 |
61 } // end namespace | 64 } // end namespace |
62 | 65 |
63 BrowserDistribution::BrowserDistribution( | 66 BrowserDistribution::BrowserDistribution() |
64 const installer::MasterPreferences& prefs) | 67 : type_(CHROME_BROWSER) { |
65 : type_(BrowserDistribution::CHROME_BROWSER) { | 68 } |
| 69 |
| 70 BrowserDistribution::BrowserDistribution(Type type) |
| 71 : type_(type) { |
66 } | 72 } |
67 | 73 |
68 template<class DistributionClass> | 74 template<class DistributionClass> |
69 BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution( | 75 BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution( |
70 const installer::MasterPreferences& prefs, | |
71 BrowserDistribution** dist) { | 76 BrowserDistribution** dist) { |
72 if (!*dist) { | 77 if (!*dist) { |
73 DistributionClass* temp = new DistributionClass(prefs); | 78 DistributionClass* temp = new DistributionClass(); |
74 if (base::subtle::NoBarrier_CompareAndSwap( | 79 if (base::subtle::NoBarrier_CompareAndSwap( |
75 reinterpret_cast<base::subtle::AtomicWord*>(dist), NULL, | 80 reinterpret_cast<base::subtle::AtomicWord*>(dist), NULL, |
76 reinterpret_cast<base::subtle::AtomicWord>(temp)) != NULL) | 81 reinterpret_cast<base::subtle::AtomicWord>(temp)) != NULL) |
77 delete temp; | 82 delete temp; |
78 } | 83 } |
79 | 84 |
80 return *dist; | 85 return *dist; |
81 } | 86 } |
82 | 87 |
83 BrowserDistribution* BrowserDistribution::GetDistribution() { | 88 BrowserDistribution* BrowserDistribution::GetDistribution() { |
84 const installer::MasterPreferences& prefs = | 89 return GetSpecificDistribution(GetCurrentDistributionType()); |
85 installer::MasterPreferences::ForCurrentProcess(); | |
86 return GetSpecificDistribution(GetCurrentDistributionType(), prefs); | |
87 } | 90 } |
88 | 91 |
89 // static | 92 // static |
90 BrowserDistribution* BrowserDistribution::GetSpecificDistribution( | 93 BrowserDistribution* BrowserDistribution::GetSpecificDistribution( |
91 BrowserDistribution::Type type, | 94 BrowserDistribution::Type type) { |
92 const installer::MasterPreferences& prefs) { | |
93 BrowserDistribution* dist = NULL; | 95 BrowserDistribution* dist = NULL; |
94 | 96 |
95 if (type == CHROME_FRAME) { | 97 switch (type) { |
96 dist = GetOrCreateBrowserDistribution<ChromeFrameDistribution>( | 98 case CHROME_BROWSER: |
97 prefs, &g_chrome_frame_distribution); | |
98 } else { | |
99 DCHECK_EQ(CHROME_BROWSER, type); | |
100 #if defined(GOOGLE_CHROME_BUILD) | 99 #if defined(GOOGLE_CHROME_BUILD) |
101 if (InstallUtil::IsChromeSxSProcess()) { | 100 if (InstallUtil::IsChromeSxSProcess()) { |
102 dist = GetOrCreateBrowserDistribution<GoogleChromeSxSDistribution>( | 101 dist = GetOrCreateBrowserDistribution<GoogleChromeSxSDistribution>( |
103 prefs, &g_browser_distribution); | 102 &g_browser_distribution); |
104 } else { | 103 } else { |
105 dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>( | 104 dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>( |
106 prefs, &g_browser_distribution); | 105 &g_browser_distribution); |
107 } | 106 } |
108 #else | 107 #else |
109 dist = GetOrCreateBrowserDistribution<BrowserDistribution>( | 108 dist = GetOrCreateBrowserDistribution<BrowserDistribution>( |
110 prefs, &g_browser_distribution); | 109 &g_browser_distribution); |
| 110 #endif |
| 111 break; |
| 112 |
| 113 case CHROME_FRAME: |
| 114 dist = GetOrCreateBrowserDistribution<ChromeFrameDistribution>( |
| 115 &g_chrome_frame_distribution); |
| 116 break; |
| 117 |
| 118 default: |
| 119 DCHECK_EQ(CHROME_BINARIES, type); |
| 120 #if defined(GOOGLE_CHROME_BUILD) |
| 121 dist = GetOrCreateBrowserDistribution<GoogleChromeBinariesDistribution>( |
| 122 &g_binaries_distribution); |
| 123 #else |
| 124 dist = GetOrCreateBrowserDistribution<ChromiumBinariesDistribution>( |
| 125 &g_binaries_distribution); |
111 #endif | 126 #endif |
112 } | 127 } |
113 | 128 |
114 return dist; | 129 return dist; |
115 } | 130 } |
116 | 131 |
117 void BrowserDistribution::DoPostUninstallOperations( | 132 void BrowserDistribution::DoPostUninstallOperations( |
118 const Version& version, const FilePath& local_data_path, | 133 const Version& version, const FilePath& local_data_path, |
119 const std::wstring& distribution_data) { | 134 const std::wstring& distribution_data) { |
120 } | 135 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 installer::InstallStatus install_status) { | 221 installer::InstallStatus install_status) { |
207 } | 222 } |
208 | 223 |
209 void BrowserDistribution::LaunchUserExperiment( | 224 void BrowserDistribution::LaunchUserExperiment( |
210 installer::InstallStatus status, const Version& version, | 225 installer::InstallStatus status, const Version& version, |
211 const installer::Product& installation, bool system_level) { | 226 const installer::Product& installation, bool system_level) { |
212 } | 227 } |
213 | 228 |
214 | 229 |
215 void BrowserDistribution::InactiveUserToastExperiment(int flavor, | 230 void BrowserDistribution::InactiveUserToastExperiment(int flavor, |
216 const installer::Product& installation) { | 231 const installer::Product& installation, |
| 232 const FilePath& application_path) { |
217 } | 233 } |
218 | |
219 std::vector<FilePath> BrowserDistribution::GetKeyFiles() { | |
220 std::vector<FilePath> key_files; | |
221 key_files.push_back(FilePath(installer::kChromeDll)); | |
222 return key_files; | |
223 } | |
224 | |
225 std::vector<FilePath> BrowserDistribution::GetComDllList() { | |
226 return std::vector<FilePath>(); | |
227 } | |
228 | |
229 void BrowserDistribution::AppendUninstallCommandLineFlags( | |
230 CommandLine* cmd_line) { | |
231 DCHECK(cmd_line); | |
232 cmd_line->AppendSwitch(installer::switches::kChrome); | |
233 } | |
234 | |
235 bool BrowserDistribution::ShouldCreateUninstallEntry() { | |
236 return true; | |
237 } | |
238 | |
239 bool BrowserDistribution::SetChannelFlags( | |
240 bool set, | |
241 installer::ChannelInfo* channel_info) { | |
242 return false; | |
243 } | |
OLD | NEW |