Chromium Code Reviews| 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 #include "components/variations/service/variations_service.h" | 5 #include "components/variations/service/variations_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 local_state_->GetList(prefs::kVariationsPermanentConsistencyCountry); | 855 local_state_->GetList(prefs::kVariationsPermanentConsistencyCountry); |
| 856 std::string stored_country; | 856 std::string stored_country; |
| 857 | 857 |
| 858 if (list_value->GetSize() == 2) { | 858 if (list_value->GetSize() == 2) { |
| 859 list_value->GetString(1, &stored_country); | 859 list_value->GetString(1, &stored_country); |
| 860 } | 860 } |
| 861 | 861 |
| 862 return stored_country; | 862 return stored_country; |
| 863 } | 863 } |
| 864 | 864 |
| 865 bool VariationsService::ForceSetStoredPermanentCountry( | |
| 866 const std::string& country_override) { | |
| 867 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 868 | |
| 869 // FIXME: Can we check for valid country? | |
|
Alexei Svitkine (slow)
2016/04/20 20:30:24
Probably not really feasible.
hamelphi
2016/04/20 21:39:47
Acknowledged.
| |
| 870 if(country_override.empty()) { | |
|
Alexei Svitkine (slow)
2016/04/20 20:30:24
Nit: space after if. Also, no {}'s on a one-line i
hamelphi
2016/04/20 21:39:47
Done.
| |
| 871 return false; | |
| 872 } | |
| 873 | |
| 874 const base::ListValue* list_value = | |
| 875 local_state_->GetList(prefs::kVariationsPermanentConsistencyCountry); | |
| 876 | |
| 877 std::string stored_country; | |
| 878 const bool got_stored_country = | |
| 879 list_value->GetSize() == 2 && list_value->GetString(1, &stored_country); | |
| 880 | |
| 881 const bool needs_update = | |
| 882 !got_stored_country || stored_country != country_override; | |
| 883 | |
| 884 if (!needs_update) { | |
| 885 return false; | |
|
Alexei Svitkine (slow)
2016/04/20 20:30:24
Not sure we actually need this logic. What's the d
hamelphi
2016/04/20 21:39:47
There is no danger. However, this allows us to tel
Alexei Svitkine (slow)
2016/04/20 21:46:44
That makes sense. However, I feel it's strange to
| |
| 886 } | |
| 887 std::string current_version = version_info::GetVersionNumber(); | |
| 888 | |
| 889 base::ListValue new_list_value; | |
| 890 new_list_value.AppendString(current_version); | |
| 891 new_list_value.AppendString(country_override); | |
| 892 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | |
| 893 new_list_value); | |
|
Alexei Svitkine (slow)
2016/04/20 20:30:24
Can you make a helper function for this logic sinc
hamelphi
2016/04/20 21:39:47
Done.
| |
| 894 return true; | |
| 895 } | |
| 896 | |
| 865 } // namespace variations | 897 } // namespace variations |
| OLD | NEW |