Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/chromeos/system/timezone_util.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/system/timezone_util.h" 5 #include "chrome/browser/chromeos/system/timezone_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
11 #include <utility>
10 12
11 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
12 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
16 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
17 #include "base/values.h" 20 #include "base/values.h"
18 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" 23 #include "chrome/browser/chromeos/profiles/profile_helper.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h" 24 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" 25 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 namespace system { 148 namespace system {
146 149
147 // Creates a list of pairs of each timezone's ID and name. 150 // Creates a list of pairs of each timezone's ID and name.
148 std::unique_ptr<base::ListValue> GetTimezoneList() { 151 std::unique_ptr<base::ListValue> GetTimezoneList() {
149 const std::vector<icu::TimeZone*> &timezones = 152 const std::vector<icu::TimeZone*> &timezones =
150 chromeos::system::TimezoneSettings::GetInstance()->GetTimezoneList(); 153 chromeos::system::TimezoneSettings::GetInstance()->GetTimezoneList();
151 std::unique_ptr<base::ListValue> timezoneList(new base::ListValue()); 154 std::unique_ptr<base::ListValue> timezoneList(new base::ListValue());
152 for (std::vector<icu::TimeZone*>::const_iterator iter = timezones.begin(); 155 for (std::vector<icu::TimeZone*>::const_iterator iter = timezones.begin();
153 iter != timezones.end(); ++iter) { 156 iter != timezones.end(); ++iter) {
154 const icu::TimeZone* timezone = *iter; 157 const icu::TimeZone* timezone = *iter;
155 base::ListValue* option = new base::ListValue(); 158 auto option = base::MakeUnique<base::ListValue>();
156 option->Append(new base::StringValue( 159 option->AppendString(
157 chromeos::system::TimezoneSettings::GetTimezoneID(*timezone))); 160 chromeos::system::TimezoneSettings::GetTimezoneID(*timezone));
158 option->Append(new base::StringValue(GetTimezoneName(*timezone))); 161 option->AppendString(GetTimezoneName(*timezone));
159 timezoneList->Append(option); 162 timezoneList->Append(std::move(option));
160 } 163 }
161 return timezoneList; 164 return timezoneList;
162 } 165 }
163 166
164 bool HasSystemTimezonePolicy() { 167 bool HasSystemTimezonePolicy() {
165 policy::BrowserPolicyConnectorChromeOS* connector = 168 policy::BrowserPolicyConnectorChromeOS* connector =
166 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 169 g_browser_process->platform_part()->browser_policy_connector_chromeos();
167 if (!connector->IsEnterpriseManaged()) 170 if (!connector->IsEnterpriseManaged())
168 return false; 171 return false;
169 172
(...skipping 19 matching lines...) Expand all
189 VLOG(1) << "Refresh TimeZone: setting timezone to '" << timezone->timeZoneId 192 VLOG(1) << "Refresh TimeZone: setting timezone to '" << timezone->timeZoneId
190 << "'"; 193 << "'";
191 194
192 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( 195 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID(
193 base::UTF8ToUTF16(timezone->timeZoneId)); 196 base::UTF8ToUTF16(timezone->timeZoneId));
194 } 197 }
195 } 198 }
196 199
197 } // namespace system 200 } // namespace system
198 } // namespace chromeos 201 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698