diff options
Diffstat (limited to 'chrome/browser/chromeos')
13 files changed, 60 insertions, 53 deletions
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc index 993d426..1a47aad 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc @@ -827,10 +827,9 @@ void AccessibilityManager::UpdateBrailleImeState() { if (!profile_) return; PrefService* pref_service = profile_->GetPrefs(); - std::vector<std::string> preload_engines; - base::SplitString(pref_service->GetString(prefs::kLanguagePreloadEngines), - ',', - &preload_engines); + std::vector<std::string> preload_engines = + base::SplitString(pref_service->GetString(prefs::kLanguagePreloadEngines), + ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); std::vector<std::string>::iterator it = std::find(preload_engines.begin(), preload_engines.end(), diff --git a/chrome/browser/chromeos/camera_detector.cc b/chrome/browser/chromeos/camera_detector.cc index 8c5deff..918a869 100644 --- a/chrome/browser/chromeos/camera_detector.cc +++ b/chrome/browser/chromeos/camera_detector.cc @@ -75,8 +75,9 @@ bool CameraDetector::CheckPresence() { std::string v4l_capabilities; if (storage_monitor::GetUdevDevicePropertyValueByPath( path, kV4LCapabilities, &v4l_capabilities)) { - std::vector<std::string> caps; - base::SplitString(v4l_capabilities, kV4LCapabilitiesDelim, &caps); + std::vector<std::string> caps = base::SplitString( + v4l_capabilities, std::string(1, kV4LCapabilitiesDelim), + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (find(caps.begin(), caps.end(), kV4LCaptureCapability) != caps.end()) { return true; } diff --git a/chrome/browser/chromeos/customization/customization_document.cc b/chrome/browser/chromeos/customization/customization_document.cc index 83be1ce..22e19268 100644 --- a/chrome/browser/chromeos/customization/customization_document.cc +++ b/chrome/browser/chromeos/customization/customization_document.cc @@ -329,8 +329,8 @@ void StartupCustomizationDocument::Init( &initial_timezone_); statistics_provider->GetMachineStatistic(kKeyboardLayoutAttr, &keyboard_layout_); - configured_locales_.resize(0); - base::SplitString(initial_locale_, ',', &configured_locales_); + configured_locales_ = base::SplitString( + initial_locale_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); // Convert ICU locale to chrome ("en_US" to "en-US", etc.). std::for_each(configured_locales_.begin(), configured_locales_.end(), diff --git a/chrome/browser/chromeos/customization/customization_document_browsertest.cc b/chrome/browser/chromeos/customization/customization_document_browsertest.cc index 7ba8243..fc61d5d 100644 --- a/chrome/browser/chromeos/customization/customization_document_browsertest.cc +++ b/chrome/browser/chromeos/customization/customization_document_browsertest.cc @@ -215,8 +215,8 @@ class CustomizationVPDTest : public InProcessBrowserTest, }; IN_PROC_BROWSER_TEST_P(CustomizationVPDTest, GetUILanguageList) { - std::vector<std::string> locales; - base::SplitString(GetParam(), ',', &locales); + std::vector<std::string> locales = base::SplitString( + GetParam(), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); for (std::string& l : locales) { base::TrimString(l, " ", &l); diff --git a/chrome/browser/chromeos/display/display_preferences.cc b/chrome/browser/chromeos/display/display_preferences.cc index b046013..8d0dea9 100644 --- a/chrome/browser/chromeos/display/display_preferences.cc +++ b/chrome/browser/chromeos/display/display_preferences.cc @@ -121,8 +121,8 @@ void LoadDisplayLayouts() { } if (it.key().find(",") != std::string::npos) { - std::vector<std::string> ids; - base::SplitString(it.key(), ',', &ids); + std::vector<std::string> ids = base::SplitString( + it.key(), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); int64 id1 = gfx::Display::kInvalidDisplayID; int64 id2 = gfx::Display::kInvalidDisplayID; if (!base::StringToInt64(ids[0], &id1) || diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc index 7326e5e..12d114f 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc @@ -606,8 +606,8 @@ void InputMethodManagerImpl::StateImpl::SetInputMethodLoginDefaultFromVPD( if (layout.empty()) return; - std::vector<std::string> layouts; - base::SplitString(layout, ',', &layouts); + std::vector<std::string> layouts = base::SplitString( + layout, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); manager_->MigrateInputMethods(&layouts); PrefService* prefs = g_browser_process->local_state(); diff --git a/chrome/browser/chromeos/input_method/input_method_syncer.cc b/chrome/browser/chromeos/input_method/input_method_syncer.cc index 6823f23..7190476 100644 --- a/chrome/browser/chromeos/input_method/input_method_syncer.cc +++ b/chrome/browser/chromeos/input_method/input_method_syncer.cc @@ -58,8 +58,8 @@ std::string CheckAndResolveLocales(const std::string& languages) { DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); if (languages.empty()) return languages; - std::vector<std::string> values; - base::SplitString(languages, ',', &values); + std::vector<std::string> values = base::SplitString( + languages, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); const std::string app_locale = g_browser_process->GetApplicationLocale(); @@ -191,27 +191,33 @@ void InputMethodSyncer::MergeSyncedPrefs() { std::vector<std::string> new_tokens; // First, set the syncable prefs to the union of the local and synced prefs. - base::SplitString( - preferred_languages_syncable_.GetValue(), ',', &synced_tokens); - base::SplitString(preferred_languages_.GetValue(), ',', &new_tokens); + synced_tokens = + base::SplitString(preferred_languages_syncable_.GetValue(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + new_tokens = base::SplitString(preferred_languages_.GetValue(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); // Append the synced values to the current values. MergeLists(&new_tokens, synced_tokens); preferred_languages_syncable_.SetValue(base::JoinString(new_tokens, ",")); - base::SplitString( - enabled_extension_imes_syncable_.GetValue(), ',', &synced_tokens); - base::SplitString(enabled_extension_imes_.GetValue(), ',', &new_tokens); + synced_tokens = + base::SplitString(enabled_extension_imes_syncable_.GetValue(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + new_tokens = base::SplitString(enabled_extension_imes_.GetValue(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); MergeLists(&new_tokens, synced_tokens); enabled_extension_imes_syncable_.SetValue(base::JoinString(new_tokens, ",")); // Revert preload engines to legacy component IDs. - base::SplitString(preload_engines_.GetValue(), ',', &new_tokens); + new_tokens = base::SplitString(preload_engines_.GetValue(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); std::transform(new_tokens.begin(), new_tokens.end(), new_tokens.begin(), extension_ime_util::GetComponentIDByInputMethodID); - base::SplitString( - preload_engines_syncable_.GetValue(), ',', &synced_tokens); + synced_tokens = + base::SplitString(preload_engines_syncable_.GetValue(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); MergeLists(&new_tokens, synced_tokens); preload_engines_syncable_.SetValue(base::JoinString(new_tokens, ",")); @@ -243,10 +249,10 @@ std::string InputMethodSyncer::AddSupportedInputMethodValues( const std::string& pref, const std::string& synced_pref, const char* pref_name) { - std::vector<std::string> old_tokens; - std::vector<std::string> new_tokens; - base::SplitString(pref, ',', &old_tokens); - base::SplitString(synced_pref, ',', &new_tokens); + std::vector<std::string> old_tokens = + base::SplitString(pref, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector<std::string> new_tokens = base::SplitString( + synced_pref, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); // Check and convert the new tokens. if (pref_name == prefs::kLanguagePreloadEngines || @@ -307,8 +313,9 @@ void InputMethodSyncer::OnPreferenceChanged(const std::string& pref_name) { // For preload engines, use legacy xkb IDs so the preference can sync // across Chrome OS and Chromium OS. - std::vector<std::string> engines; - base::SplitString(preload_engines_.GetValue(), ',', &engines); + std::vector<std::string> engines = + base::SplitString(preload_engines_.GetValue(), ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL); std::transform(engines.begin(), engines.end(), engines.begin(), extension_ime_util::GetComponentIDByInputMethodID); preload_engines_syncable_.SetValue(base::JoinString(engines, ",")); diff --git a/chrome/browser/chromeos/login/chrome_restart_request.cc b/chrome/browser/chromeos/login/chrome_restart_request.cc index e3cb8c4..c82550e 100644 --- a/chrome/browser/chromeos/login/chrome_restart_request.cc +++ b/chrome/browser/chromeos/login/chrome_restart_request.cc @@ -256,10 +256,9 @@ std::string DeriveCommandLine(const GURL& start_url, // Simulates a session manager restart by launching give command line // and exit current process. void ReLaunch(const std::string& command_line) { - std::vector<std::string> argv; - // This is not a proper way to get |argv| but it's good enough for debugging. - base::SplitString(command_line, ' ', &argv); + std::vector<std::string> argv = base::SplitString( + command_line, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); base::LaunchProcess(argv, base::LaunchOptions()); chrome::AttemptUserExit(); diff --git a/chrome/browser/chromeos/login/language_list.cc b/chrome/browser/chromeos/login/language_list.cc index f6bf251..9e39539 100644 --- a/chrome/browser/chromeos/login/language_list.cc +++ b/chrome/browser/chromeos/login/language_list.cc @@ -78,10 +78,9 @@ int LanguageList::GetIndexFromLocale(const std::string& locale) const { void LanguageList::CopySpecifiedLanguagesUp(const std::string& locale_codes) { DCHECK(!locale_names_.empty()); - std::vector<std::string> locale_codes_vector; - base::SplitString(locale_codes, ',', &locale_codes_vector); - for (size_t i = 0; i != locale_codes_vector.size(); ++i) { - const int locale_index = GetIndexFromLocale(locale_codes_vector[i]); + for (const std::string& code : base::SplitString( + locale_codes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { + const int locale_index = GetIndexFromLocale(code); CHECK_NE(locale_index, -1); locale_names_.insert(locale_names_.begin(), locale_names_[locale_index]); } diff --git a/chrome/browser/chromeos/power/cpu_data_collector.cc b/chrome/browser/chromeos/power/cpu_data_collector.cc index bc43420..a4eb50f 100644 --- a/chrome/browser/chromeos/power/cpu_data_collector.cc +++ b/chrome/browser/chromeos/power/cpu_data_collector.cc @@ -232,22 +232,21 @@ void SampleCpuFreqData( freq_sample.time = now; - std::vector<std::string> lines; - base::SplitString(time_in_state_string, '\n', &lines); + std::vector<base::StringPiece> lines = + base::SplitStringPiece(time_in_state_string, "\n", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); // The last line could end with '\n'. Ignore the last empty string in // such cases. size_t state_count = lines.size(); if (state_count > 0 && lines.back().empty()) state_count -= 1; for (size_t state = 0; state < state_count; ++state) { - std::vector<std::string> pair; int freq_in_khz; int64 occupancy_time_centisecond; // Occupancy of each state is in the format "<state> <time>" - base::SplitString(lines[state], ' ', &pair); - for (size_t s = 0; s < pair.size(); ++s) - base::TrimWhitespace(pair[s], base::TRIM_ALL, &pair[s]); + std::vector<base::StringPiece> pair = base::SplitStringPiece( + lines[state], " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (pair.size() == 2 && base::StringToInt(pair[0], &freq_in_khz) && base::StringToInt64(pair[1], &occupancy_time_centisecond)) { diff --git a/chrome/browser/chromeos/power/peripheral_battery_observer.cc b/chrome/browser/chromeos/power/peripheral_battery_observer.cc index 22089fa..1ef701e2 100644 --- a/chrome/browser/chromeos/power/peripheral_battery_observer.cc +++ b/chrome/browser/chromeos/power/peripheral_battery_observer.cc @@ -63,8 +63,8 @@ std::string ExtractBluetoothAddress(const std::string& path) { return std::string(); std::string reverse_address = path.substr(header_size, key_len); base::StringToLowerASCII(&reverse_address); - std::vector<std::string> result; - base::SplitString(reverse_address, ':', &result); + std::vector<std::string> result = base::SplitString( + reverse_address, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); std::reverse(result.begin(), result.end()); std::string address = base::JoinString(result, ":"); return address; diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index e19c8ff..848c825 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -553,9 +553,10 @@ void Preferences::ApplyPreferences(ApplyReason reason, std::string value(enabled_extension_imes_.GetValue()); std::vector<std::string> split_values; - if (!value.empty()) - base::SplitString(value, ',', &split_values); - + if (!value.empty()) { + split_values = base::SplitString(value, ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL); + } ime_state_->SetEnabledExtensionImes(&split_values); } @@ -622,8 +623,10 @@ void Preferences::SetLanguageConfigStringListAsCSV(const char* section, VLOG(1) << "Setting " << name << " to '" << value << "'"; std::vector<std::string> split_values; - if (!value.empty()) - base::SplitString(value, ',', &split_values); + if (!value.empty()) { + split_values = base::SplitString(value, ",", base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL); + } // Transfers the xkb id to extension-xkb id. if (input_method_manager_->MigrateInputMethods(&split_values)) diff --git a/chrome/browser/chromeos/preferences_unittest.cc b/chrome/browser/chromeos/preferences_unittest.cc index f790cba..3d391ef 100644 --- a/chrome/browser/chromeos/preferences_unittest.cc +++ b/chrome/browser/chromeos/preferences_unittest.cc @@ -340,8 +340,8 @@ class InputMethodPreferencesTest : public PreferencesTest { // Translates engine IDs in a CSV string to input method IDs. std::string ToInputMethodIds(std::string value) { - std::vector<std::string> tokens; - base::SplitString(value, ',', &tokens); + std::vector<std::string> tokens = base::SplitString( + value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); std::transform(tokens.begin(), tokens.end(), tokens.begin(), &extension_ime_util::GetInputMethodIDByEngineID); return base::JoinString(tokens, ","); |