| 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 #include "chrome/browser/mac/master_prefs.h" | 5 #include "chrome/browser/mac/master_prefs.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "chrome/common/channel_info.h" |
| 9 #include "chrome/common/chrome_paths_internal.h" | 10 #include "chrome/common/chrome_paths_internal.h" |
| 10 #include "chrome/common/chrome_version_info.h" | 11 #include "components/version_info/version_info.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 #if defined(GOOGLE_CHROME_BUILD) | 15 #if defined(GOOGLE_CHROME_BUILD) |
| 15 // This should be NSApplicationSupportDirectory, but it has already been | 16 // This should be NSApplicationSupportDirectory, but it has already been |
| 16 // released using NSLibraryDirectory. | 17 // released using NSLibraryDirectory. |
| 17 const NSSearchPathDirectory kSearchPath = NSLibraryDirectory; | 18 const NSSearchPathDirectory kSearchPath = NSLibraryDirectory; |
| 18 const char kMasterPreferencesDirectory[] = "Google"; | 19 const char kMasterPreferencesDirectory[] = "Google"; |
| 19 const char kMasterPreferencesFileName[] = "Google Chrome Master Preferences"; | 20 const char kMasterPreferencesFileName[] = "Google Chrome Master Preferences"; |
| 20 #else | 21 #else |
| 21 const NSSearchPathDirectory kSearchPath = NSApplicationSupportDirectory; | 22 const NSSearchPathDirectory kSearchPath = NSApplicationSupportDirectory; |
| 22 const char kMasterPreferencesDirectory[] = "Chromium"; | 23 const char kMasterPreferencesDirectory[] = "Chromium"; |
| 23 const char kMasterPreferencesFileName[] = "Chromium Master Preferences"; | 24 const char kMasterPreferencesFileName[] = "Chromium Master Preferences"; |
| 24 #endif // GOOGLE_CHROME_BUILD | 25 #endif // GOOGLE_CHROME_BUILD |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 | 29 |
| 29 namespace master_prefs { | 30 namespace master_prefs { |
| 30 | 31 |
| 31 base::FilePath MasterPrefsPath() { | 32 base::FilePath MasterPrefsPath() { |
| 32 #if defined(GOOGLE_CHROME_BUILD) | 33 #if defined(GOOGLE_CHROME_BUILD) |
| 33 // Don't load master preferences for the canary. | 34 // Don't load master preferences for the canary. |
| 34 version_info::Channel channel = chrome::VersionInfo::GetChannel(); | 35 version_info::Channel channel = chrome::GetChannel(); |
| 35 if (channel == version_info::Channel::CANARY) | 36 if (channel == version_info::Channel::CANARY) |
| 36 return base::FilePath(); | 37 return base::FilePath(); |
| 37 #endif // GOOGLE_CHROME_BUILD | 38 #endif // GOOGLE_CHROME_BUILD |
| 38 | 39 |
| 39 // On official builds, try | 40 // On official builds, try |
| 40 //~/Library/Application Support/Google/Chrome/Google Chrome Master Preferences | 41 //~/Library/Application Support/Google/Chrome/Google Chrome Master Preferences |
| 41 // On chromium builds, try | 42 // On chromium builds, try |
| 42 //~/Library/Application Support/Chromium/Chromium Master Preferences | 43 //~/Library/Application Support/Chromium/Chromium Master Preferences |
| 43 // This intentionally doesn't use eventual --user-data-dir overrides. | 44 // This intentionally doesn't use eventual --user-data-dir overrides. |
| 44 base::FilePath user_application_support_path; | 45 base::FilePath user_application_support_path; |
| 45 if (chrome::GetDefaultUserDataDirectory(&user_application_support_path)) { | 46 if (chrome::GetDefaultUserDataDirectory(&user_application_support_path)) { |
| 46 user_application_support_path = | 47 user_application_support_path = |
| 47 user_application_support_path.Append(kMasterPreferencesFileName); | 48 user_application_support_path.Append(kMasterPreferencesFileName); |
| 48 if (base::PathExists(user_application_support_path)) | 49 if (base::PathExists(user_application_support_path)) |
| 49 return user_application_support_path; | 50 return user_application_support_path; |
| 50 } | 51 } |
| 51 | 52 |
| 52 // On official builds, try /Library/Google/Google Chrome Master Preferences | 53 // On official builds, try /Library/Google/Google Chrome Master Preferences |
| 53 // On chromium builds, try | 54 // On chromium builds, try |
| 54 // /Library/Application Support/Chromium/Chromium Master Preferences | 55 // /Library/Application Support/Chromium/Chromium Master Preferences |
| 55 base::FilePath search_path; | 56 base::FilePath search_path; |
| 56 if (!base::mac::GetLocalDirectory(kSearchPath, &search_path)) | 57 if (!base::mac::GetLocalDirectory(kSearchPath, &search_path)) |
| 57 return base::FilePath(); | 58 return base::FilePath(); |
| 58 | 59 |
| 59 return search_path.Append(kMasterPreferencesDirectory) | 60 return search_path.Append(kMasterPreferencesDirectory) |
| 60 .Append(kMasterPreferencesFileName); | 61 .Append(kMasterPreferencesFileName); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace master_prefs | 64 } // namespace master_prefs |
| OLD | NEW |