| 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/chromeos/customization_document.h" | 5 #include "chrome/browser/chromeos/customization_document.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_tokenizer.h" | 11 #include "base/string_tokenizer.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 17 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
| 18 #include "chrome/browser/chromeos/login/wizard_controller.h" | 18 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 19 #include "chrome/browser/chromeos/system_access.h" | 19 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "content/browser/browser_thread.h" | 22 #include "content/browser/browser_thread.h" |
| 23 | 23 |
| 24 // Manifest attributes names. | 24 // Manifest attributes names. |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const char kVersionAttr[] = "version"; | 28 const char kVersionAttr[] = "version"; |
| 29 const char kDefaultAttr[] = "default"; | 29 const char kDefaultAttr[] = "default"; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // StartupCustomizationDocument implementation. -------------------------------- | 141 // StartupCustomizationDocument implementation. -------------------------------- |
| 142 | 142 |
| 143 StartupCustomizationDocument::StartupCustomizationDocument() { | 143 StartupCustomizationDocument::StartupCustomizationDocument() { |
| 144 { | 144 { |
| 145 // Loading manifest causes us to do blocking IO on UI thread. | 145 // Loading manifest causes us to do blocking IO on UI thread. |
| 146 // Temporarily allow it until we fix http://crosbug.com/11103 | 146 // Temporarily allow it until we fix http://crosbug.com/11103 |
| 147 base::ThreadRestrictions::ScopedAllowIO allow_io; | 147 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 148 LoadManifestFromFile(FilePath(kStartupCustomizationManifestPath)); | 148 LoadManifestFromFile(FilePath(kStartupCustomizationManifestPath)); |
| 149 } | 149 } |
| 150 Init(SystemAccess::GetInstance()); | 150 Init(chromeos::system::StatisticsProvider::GetInstance()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 StartupCustomizationDocument::StartupCustomizationDocument( | 153 StartupCustomizationDocument::StartupCustomizationDocument( |
| 154 SystemAccess* system_access, const std::string& manifest) { | 154 chromeos::system::StatisticsProvider* statistics_provider, |
| 155 const std::string& manifest) { |
| 155 LoadManifestFromString(manifest); | 156 LoadManifestFromString(manifest); |
| 156 Init(system_access); | 157 Init(statistics_provider); |
| 157 } | 158 } |
| 158 | 159 |
| 159 StartupCustomizationDocument::~StartupCustomizationDocument() {} | 160 StartupCustomizationDocument::~StartupCustomizationDocument() {} |
| 160 | 161 |
| 161 StartupCustomizationDocument* StartupCustomizationDocument::GetInstance() { | 162 StartupCustomizationDocument* StartupCustomizationDocument::GetInstance() { |
| 162 return Singleton<StartupCustomizationDocument, | 163 return Singleton<StartupCustomizationDocument, |
| 163 DefaultSingletonTraits<StartupCustomizationDocument> >::get(); | 164 DefaultSingletonTraits<StartupCustomizationDocument> >::get(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void StartupCustomizationDocument::Init(SystemAccess* system_access) { | 167 void StartupCustomizationDocument::Init( |
| 168 chromeos::system::StatisticsProvider* statistics_provider) { |
| 167 if (!IsReady()) | 169 if (!IsReady()) |
| 168 return; | 170 return; |
| 169 | 171 |
| 170 root_->GetString(kInitialLocaleAttr, &initial_locale_); | 172 root_->GetString(kInitialLocaleAttr, &initial_locale_); |
| 171 root_->GetString(kInitialTimezoneAttr, &initial_timezone_); | 173 root_->GetString(kInitialTimezoneAttr, &initial_timezone_); |
| 172 root_->GetString(kKeyboardLayoutAttr, &keyboard_layout_); | 174 root_->GetString(kKeyboardLayoutAttr, &keyboard_layout_); |
| 173 root_->GetString(kRegistrationUrlAttr, ®istration_url_); | 175 root_->GetString(kRegistrationUrlAttr, ®istration_url_); |
| 174 | 176 |
| 175 std::string hwid; | 177 std::string hwid; |
| 176 if (system_access->GetMachineStatistic(kHardwareClass, &hwid)) { | 178 if (statistics_provider->GetMachineStatistic(kHardwareClass, &hwid)) { |
| 177 ListValue* hwid_list = NULL; | 179 ListValue* hwid_list = NULL; |
| 178 if (root_->GetList(kHwidMapAttr, &hwid_list)) { | 180 if (root_->GetList(kHwidMapAttr, &hwid_list)) { |
| 179 for (size_t i = 0; i < hwid_list->GetSize(); ++i) { | 181 for (size_t i = 0; i < hwid_list->GetSize(); ++i) { |
| 180 DictionaryValue* hwid_dictionary = NULL; | 182 DictionaryValue* hwid_dictionary = NULL; |
| 181 std::string hwid_mask; | 183 std::string hwid_mask; |
| 182 if (hwid_list->GetDictionary(i, &hwid_dictionary) && | 184 if (hwid_list->GetDictionary(i, &hwid_dictionary) && |
| 183 hwid_dictionary->GetString(kHwidMaskAttr, &hwid_mask)) { | 185 hwid_dictionary->GetString(kHwidMaskAttr, &hwid_mask)) { |
| 184 if (MatchPattern(hwid, hwid_mask)) { | 186 if (MatchPattern(hwid, hwid_mask)) { |
| 185 // If HWID for this machine matches some mask, use HWID specific | 187 // If HWID for this machine matches some mask, use HWID specific |
| 186 // settings. | 188 // settings. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 197 // Don't break here to allow other entires to be applied if match. | 199 // Don't break here to allow other entires to be applied if match. |
| 198 } else { | 200 } else { |
| 199 LOG(ERROR) << "Syntax error in customization manifest"; | 201 LOG(ERROR) << "Syntax error in customization manifest"; |
| 200 } | 202 } |
| 201 } | 203 } |
| 202 } | 204 } |
| 203 } else { | 205 } else { |
| 204 LOG(ERROR) << "HWID is missing in machine statistics"; | 206 LOG(ERROR) << "HWID is missing in machine statistics"; |
| 205 } | 207 } |
| 206 | 208 |
| 207 system_access->GetMachineStatistic(kInitialLocaleAttr, &initial_locale_); | 209 statistics_provider->GetMachineStatistic(kInitialLocaleAttr, |
| 208 system_access->GetMachineStatistic(kInitialTimezoneAttr, &initial_timezone_); | 210 &initial_locale_); |
| 209 system_access->GetMachineStatistic(kKeyboardLayoutAttr, &keyboard_layout_); | 211 statistics_provider->GetMachineStatistic(kInitialTimezoneAttr, |
| 212 &initial_timezone_); |
| 213 statistics_provider->GetMachineStatistic(kKeyboardLayoutAttr, |
| 214 &keyboard_layout_); |
| 210 } | 215 } |
| 211 | 216 |
| 212 std::string StartupCustomizationDocument::GetHelpPage( | 217 std::string StartupCustomizationDocument::GetHelpPage( |
| 213 const std::string& locale) const { | 218 const std::string& locale) const { |
| 214 return GetLocaleSpecificString(locale, kSetupContentAttr, kHelpPageAttr); | 219 return GetLocaleSpecificString(locale, kSetupContentAttr, kHelpPageAttr); |
| 215 } | 220 } |
| 216 | 221 |
| 217 std::string StartupCustomizationDocument::GetEULAPage( | 222 std::string StartupCustomizationDocument::GetEULAPage( |
| 218 const std::string& locale) const { | 223 const std::string& locale) const { |
| 219 return GetLocaleSpecificString(locale, kSetupContentAttr, kEulaPageAttr); | 224 return GetLocaleSpecificString(locale, kSetupContentAttr, kEulaPageAttr); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 DictionaryValue* carrier_deal = NULL; | 410 DictionaryValue* carrier_deal = NULL; |
| 406 if (carriers->GetDictionary(*iter, &carrier_deal)) { | 411 if (carriers->GetDictionary(*iter, &carrier_deal)) { |
| 407 carrier_deals_[*iter] = new CarrierDeal(carrier_deal); | 412 carrier_deals_[*iter] = new CarrierDeal(carrier_deal); |
| 408 } | 413 } |
| 409 } | 414 } |
| 410 } | 415 } |
| 411 return true; | 416 return true; |
| 412 } | 417 } |
| 413 | 418 |
| 414 } // namespace chromeos | 419 } // namespace chromeos |
| OLD | NEW |