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

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

Issue 2849823003: ChromeOS: implement per-user time zone preferences. (Closed)
Patch Set: Rebased. Created 3 years, 4 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 if (chromeos::system::PerUserTimezoneEnabled()) {
330 return base::WrapUnique<base::Value>(
331 Profile::FromBrowserContext(context_)
332 ->GetPrefs()
333 ->GetUserPrefValue(prefs::kUserTimezone)
334 ->DeepCopy());
335 }
329 // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr. 336 // TODO(crbug.com/697817): Convert CrosSettings::Get to take a unique_ptr.
330 return base::WrapUnique<base::Value>( 337 return base::WrapUnique<base::Value>(
331 chromeos::CrosSettings::Get() 338 chromeos::CrosSettings::Get()
332 ->GetPref(chromeos::kSystemTimezone) 339 ->GetPref(chromeos::kSystemTimezone)
333 ->DeepCopy()); 340 ->DeepCopy());
334 } 341 }
335 342
336 if (property_name == kPropertySupportedTimezones) { 343 if (property_name == kPropertySupportedTimezones) {
337 std::unique_ptr<base::ListValue> values = 344 std::unique_ptr<base::ListValue> values =
338 chromeos::system::GetTimezoneList(); 345 chromeos::system::GetTimezoneList();
(...skipping 17 matching lines...) Expand all
356 363
357 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { 364 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() {
358 } 365 }
359 366
360 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { 367 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() {
361 std::string param_name; 368 std::string param_name;
362 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &param_name)); 369 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &param_name));
363 if (param_name == kPropertyTimezone) { 370 if (param_name == kPropertyTimezone) {
364 std::string param_value; 371 std::string param_value;
365 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &param_value)); 372 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &param_value));
366 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, 373 if (chromeos::system::PerUserTimezoneEnabled()) {
367 base::Value(param_value)); 374 Profile::FromBrowserContext(context_)->GetPrefs()->SetString(
375 prefs::kUserTimezone, param_value);
376 } else {
377 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone,
378 base::Value(param_value));
379 }
368 } else { 380 } else {
369 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); 381 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str());
370 if (pref_name) { 382 if (pref_name) {
371 bool param_value; 383 bool param_value;
372 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &param_value)); 384 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &param_value));
373 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( 385 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean(
374 pref_name, 386 pref_name,
375 param_value); 387 param_value);
376 } else { 388 } else {
377 return RespondNow(Error(kPropertyNotFound, param_name)); 389 return RespondNow(Error(kPropertyNotFound, param_name));
378 } 390 }
379 } 391 }
380 392
381 return RespondNow(NoArguments()); 393 return RespondNow(NoArguments());
382 } 394 }
383 395
384 } // namespace extensions 396 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/BUILD.gn ('k') | chrome/browser/chromeos/extensions/info_private_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698