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

Side by Side Diff: chrome/browser/chromeos/extensions/info_private_api.cc

Issue 2849823003: ChromeOS: implement per-user time zone preferences. (Closed)
Patch Set: Try remove g_browser_process check Created 3 years, 7 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 (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 "chrome/browser/chromeos/extensions/info_private_api.h" 5 #include "chrome/browser/chromeos/extensions/info_private_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 default: 319 default:
320 return base::MakeUnique<base::Value>(kDeviceTypeChromedevice); 320 return base::MakeUnique<base::Value>(kDeviceTypeChromedevice);
321 } 321 }
322 } 322 }
323 323
324 if (property_name == kPropertyClientId) { 324 if (property_name == kPropertyClientId) {
325 return base::MakeUnique<base::Value>(GetClientId()); 325 return base::MakeUnique<base::Value>(GetClientId());
326 } 326 }
327 327
328 if (property_name == kPropertyTimezone) { 328 if (property_name == kPropertyTimezone) {
329 // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr.
330 return base::WrapUnique<base::Value>( 329 return base::WrapUnique<base::Value>(
331 chromeos::CrosSettings::Get() 330 Profile::FromBrowserContext(context_)
332 ->GetPref(chromeos::kSystemTimezone) 331 ->GetPrefs()
332 ->GetUserPrefValue(prefs::kUserTimezone)
333 ->DeepCopy()); 333 ->DeepCopy());
334 } 334 }
335 335
336 if (property_name == kPropertySupportedTimezones) { 336 if (property_name == kPropertySupportedTimezones) {
337 std::unique_ptr<base::ListValue> values = 337 std::unique_ptr<base::ListValue> values =
338 chromeos::system::GetTimezoneList(); 338 chromeos::system::GetTimezoneList();
339 // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required. 339 // TODO(crbug.com/703565): remove std::move() once Xcode 9.0+ is required.
340 return std::move(values); 340 return std::move(values);
341 } 341 }
342 342
(...skipping 13 matching lines...) Expand all
356 356
357 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { 357 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() {
358 } 358 }
359 359
360 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { 360 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() {
361 std::string param_name; 361 std::string param_name;
362 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &param_name)); 362 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &param_name));
363 if (param_name == kPropertyTimezone) { 363 if (param_name == kPropertyTimezone) {
364 std::string param_value; 364 std::string param_value;
365 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &param_value)); 365 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &param_value));
366 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, 366 Profile::FromBrowserContext(context_)->GetPrefs()->SetString(
367 base::Value(param_value)); 367 prefs::kUserTimezone, param_value);
368 } else { 368 } else {
369 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); 369 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str());
370 if (pref_name) { 370 if (pref_name) {
371 bool param_value; 371 bool param_value;
372 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &param_value)); 372 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &param_value));
373 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( 373 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean(
374 pref_name, 374 pref_name,
375 param_value); 375 param_value);
376 } else { 376 } else {
377 return RespondNow(Error(kPropertyNotFound, param_name)); 377 return RespondNow(Error(kPropertyNotFound, param_name));
378 } 378 }
379 } 379 }
380 380
381 return RespondNow(NoArguments()); 381 return RespondNow(NoArguments());
382 } 382 }
383 383
384 } // namespace extensions 384 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698