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