OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "google_apis/gcm/engine/gservices_settings.h" | 5 #include "google_apis/gcm/engine/gservices_settings.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 if (settings_diff) | 220 if (settings_diff) |
221 new_settings = settings_map(); | 221 new_settings = settings_map(); |
222 | 222 |
223 for (int i = 0; i < checkin_response.setting_size(); ++i) { | 223 for (int i = 0; i < checkin_response.setting_size(); ++i) { |
224 std::string name = checkin_response.setting(i).name(); | 224 std::string name = checkin_response.setting(i).name(); |
225 if (name.empty()) { | 225 if (name.empty()) { |
226 DVLOG(1) << "Setting name is empty"; | 226 DVLOG(1) << "Setting name is empty"; |
227 return false; | 227 return false; |
228 } | 228 } |
229 | 229 |
230 if (settings_diff && name.find(kDeleteSettingPrefix) == 0) { | 230 if (settings_diff && base::StartsWith(name, kDeleteSettingPrefix, |
| 231 base::CompareCase::SENSITIVE)) { |
231 std::string setting_to_delete = | 232 std::string setting_to_delete = |
232 name.substr(arraysize(kDeleteSettingPrefix) - 1); | 233 name.substr(arraysize(kDeleteSettingPrefix) - 1); |
233 new_settings.erase(setting_to_delete); | 234 new_settings.erase(setting_to_delete); |
234 DVLOG(1) << "Setting deleted: " << setting_to_delete; | 235 DVLOG(1) << "Setting deleted: " << setting_to_delete; |
235 } else { | 236 } else { |
236 std::string value = checkin_response.setting(i).value(); | 237 std::string value = checkin_response.setting(i).value(); |
237 new_settings[name] = value; | 238 new_settings[name] = value; |
238 DVLOG(1) << "New setting: '" << name << "' : '" << value << "'"; | 239 DVLOG(1) << "New setting: '" << name << "' : '" << value << "'"; |
239 } | 240 } |
240 } | 241 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 command_line->GetSwitchValueASCII(switches::kGCMRegistrationURL)); | 352 command_line->GetSwitchValueASCII(switches::kGCMRegistrationURL)); |
352 } | 353 } |
353 | 354 |
354 SettingsMap::const_iterator iter = settings_.find(kRegistrationURLKey); | 355 SettingsMap::const_iterator iter = settings_.find(kRegistrationURLKey); |
355 if (iter == settings_.end() || iter->second.empty()) | 356 if (iter == settings_.end() || iter->second.empty()) |
356 return GURL(kDefaultRegistrationURL); | 357 return GURL(kDefaultRegistrationURL); |
357 return GURL(iter->second); | 358 return GURL(iter->second); |
358 } | 359 } |
359 | 360 |
360 } // namespace gcm | 361 } // namespace gcm |
OLD | NEW |