| 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 // 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 <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/atomicops.h" | 14 #include "base/atomicops.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "chrome/installer/util/app_registration_data.h" | 17 #include "chrome/installer/util/app_registration_data.h" |
| 18 #include "chrome/installer/util/google_chrome_distribution.h" | 18 #include "chrome/installer/util/google_chrome_distribution.h" |
| 19 #include "chrome/installer/util/google_chrome_sxs_distribution.h" | |
| 20 #include "chrome/installer/util/install_util.h" | |
| 21 #include "chrome/installer/util/installer_util_strings.h" | 19 #include "chrome/installer/util/installer_util_strings.h" |
| 22 #include "chrome/installer/util/l10n_string_util.h" | 20 #include "chrome/installer/util/l10n_string_util.h" |
| 23 #include "chrome/installer/util/non_updating_app_registration_data.h" | 21 #include "chrome/installer/util/non_updating_app_registration_data.h" |
| 24 | 22 |
| 25 namespace { | 23 namespace { |
| 26 | 24 |
| 27 // The BrowserDistribution objects are never freed. | 25 // The BrowserDistribution object is never freed. |
| 28 BrowserDistribution* g_browser_distribution = NULL; | 26 BrowserDistribution* g_browser_distribution = NULL; |
| 29 | 27 |
| 30 } // namespace | 28 } // namespace |
| 31 | 29 |
| 32 BrowserDistribution::BrowserDistribution() | 30 BrowserDistribution::BrowserDistribution() |
| 33 : app_reg_data_(base::MakeUnique<NonUpdatingAppRegistrationData>( | 31 : app_reg_data_(base::MakeUnique<NonUpdatingAppRegistrationData>( |
| 34 L"Software\\Chromium")) {} | 32 L"Software\\Chromium")) {} |
| 35 | 33 |
| 36 BrowserDistribution::BrowserDistribution( | 34 BrowserDistribution::BrowserDistribution( |
| 37 std::unique_ptr<AppRegistrationData> app_reg_data) | 35 std::unique_ptr<AppRegistrationData> app_reg_data) |
| 38 : app_reg_data_(std::move(app_reg_data)) {} | 36 : app_reg_data_(std::move(app_reg_data)) {} |
| 39 | 37 |
| 40 BrowserDistribution::~BrowserDistribution() {} | 38 BrowserDistribution::~BrowserDistribution() = default; |
| 41 | 39 |
| 42 template<class DistributionClass> | 40 template<class DistributionClass> |
| 43 BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution( | 41 BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution( |
| 44 BrowserDistribution** dist) { | 42 BrowserDistribution** dist) { |
| 45 if (!*dist) { | 43 if (!*dist) { |
| 46 DistributionClass* temp = new DistributionClass(); | 44 DistributionClass* temp = new DistributionClass(); |
| 47 if (base::subtle::NoBarrier_CompareAndSwap( | 45 if (base::subtle::NoBarrier_CompareAndSwap( |
| 48 reinterpret_cast<base::subtle::AtomicWord*>(dist), NULL, | 46 reinterpret_cast<base::subtle::AtomicWord*>(dist), NULL, |
| 49 reinterpret_cast<base::subtle::AtomicWord>(temp)) != NULL) | 47 reinterpret_cast<base::subtle::AtomicWord>(temp)) != NULL) |
| 50 delete temp; | 48 delete temp; |
| 51 } | 49 } |
| 52 | 50 |
| 53 return *dist; | 51 return *dist; |
| 54 } | 52 } |
| 55 | 53 |
| 56 // static | 54 // static |
| 57 BrowserDistribution* BrowserDistribution::GetDistribution() { | 55 BrowserDistribution* BrowserDistribution::GetDistribution() { |
| 58 BrowserDistribution* dist = NULL; | 56 BrowserDistribution* dist = NULL; |
| 59 | 57 |
| 60 #if defined(GOOGLE_CHROME_BUILD) | 58 #if defined(GOOGLE_CHROME_BUILD) |
| 61 if (InstallUtil::IsChromeSxSProcess()) { | 59 dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>( |
| 62 dist = GetOrCreateBrowserDistribution<GoogleChromeSxSDistribution>( | 60 &g_browser_distribution); |
| 63 &g_browser_distribution); | |
| 64 } else { | |
| 65 dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>( | |
| 66 &g_browser_distribution); | |
| 67 } | |
| 68 #else | 61 #else |
| 69 dist = GetOrCreateBrowserDistribution<BrowserDistribution>( | 62 dist = GetOrCreateBrowserDistribution<BrowserDistribution>( |
| 70 &g_browser_distribution); | 63 &g_browser_distribution); |
| 71 #endif | 64 #endif |
| 72 | 65 |
| 73 return dist; | 66 return dist; |
| 74 } | 67 } |
| 75 | 68 |
| 76 const AppRegistrationData& BrowserDistribution::GetAppRegistrationData() const { | 69 const AppRegistrationData& BrowserDistribution::GetAppRegistrationData() const { |
| 77 return *app_reg_data_; | 70 return *app_reg_data_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 void BrowserDistribution::DoPostUninstallOperations( | 85 void BrowserDistribution::DoPostUninstallOperations( |
| 93 const base::Version& version, const base::FilePath& local_data_path, | 86 const base::Version& version, const base::FilePath& local_data_path, |
| 94 const base::string16& distribution_data) { | 87 const base::string16& distribution_data) { |
| 95 } | 88 } |
| 96 | 89 |
| 97 base::string16 BrowserDistribution::GetDisplayName() { | 90 base::string16 BrowserDistribution::GetDisplayName() { |
| 98 return GetShortcutName(); | 91 return GetShortcutName(); |
| 99 } | 92 } |
| 100 | 93 |
| 101 base::string16 BrowserDistribution::GetShortcutName() { | 94 base::string16 BrowserDistribution::GetShortcutName() { |
| 95 // IDS_PRODUCT_NAME is automatically mapped to the mode-specific shortcut |
| 96 // name. |
| 102 return installer::GetLocalizedString(IDS_PRODUCT_NAME_BASE); | 97 return installer::GetLocalizedString(IDS_PRODUCT_NAME_BASE); |
| 103 } | 98 } |
| 104 | 99 |
| 105 base::string16 BrowserDistribution::GetStartMenuShortcutSubfolder( | 100 base::string16 BrowserDistribution::GetStartMenuShortcutSubfolder( |
| 106 Subfolder subfolder_type) { | 101 Subfolder subfolder_type) { |
| 107 switch (subfolder_type) { | 102 switch (subfolder_type) { |
| 108 case SUBFOLDER_APPS: | 103 case SUBFOLDER_APPS: |
| 109 return installer::GetLocalizedString(IDS_APP_SHORTCUTS_SUBDIR_NAME_BASE); | 104 return installer::GetLocalizedString(IDS_APP_SHORTCUTS_SUBDIR_NAME_BASE); |
| 110 default: | 105 default: |
| 111 DCHECK_EQ(SUBFOLDER_CHROME, subfolder_type); | 106 DCHECK_EQ(SUBFOLDER_CHROME, subfolder_type); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 132 } | 127 } |
| 133 | 128 |
| 134 base::string16 BrowserDistribution::GetDistributionData(HKEY root_key) { | 129 base::string16 BrowserDistribution::GetDistributionData(HKEY root_key) { |
| 135 return L""; | 130 return L""; |
| 136 } | 131 } |
| 137 | 132 |
| 138 void BrowserDistribution::UpdateInstallStatus(bool system_install, | 133 void BrowserDistribution::UpdateInstallStatus(bool system_install, |
| 139 installer::ArchiveType archive_type, | 134 installer::ArchiveType archive_type, |
| 140 installer::InstallStatus install_status) { | 135 installer::InstallStatus install_status) { |
| 141 } | 136 } |
| OLD | NEW |