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

Side by Side Diff: chrome/browser/policy/browser_policy_connector.cc

Issue 10827050: Added a timezone policy and pyauto tests for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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/policy/browser_policy_connector.h" 5 #include "chrome/browser/policy/browser_policy_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/cros_settings.h"
15 #include "chrome/browser/chromeos/cros_settings_provider.h"
16 #include "chrome/browser/chromeos/system/timezone_settings.h"
Joao da Silva 2012/07/27 13:40:57 Move these to the #if defined(OS_CHROMEOS) below
pneubeck (no reviews) 2012/07/31 22:21:05 Done.
13 #include "chrome/browser/policy/async_policy_provider.h" 17 #include "chrome/browser/policy/async_policy_provider.h"
14 #include "chrome/browser/policy/cloud_policy_client.h" 18 #include "chrome/browser/policy/cloud_policy_client.h"
15 #include "chrome/browser/policy/cloud_policy_provider.h" 19 #include "chrome/browser/policy/cloud_policy_provider.h"
16 #include "chrome/browser/policy/cloud_policy_service.h" 20 #include "chrome/browser/policy/cloud_policy_service.h"
17 #include "chrome/browser/policy/cloud_policy_subsystem.h" 21 #include "chrome/browser/policy/cloud_policy_subsystem.h"
18 #include "chrome/browser/policy/configuration_policy_provider.h" 22 #include "chrome/browser/policy/configuration_policy_provider.h"
19 #include "chrome/browser/policy/device_management_service.h" 23 #include "chrome/browser/policy/device_management_service.h"
20 #include "chrome/browser/policy/managed_mode_policy_provider.h" 24 #include "chrome/browser/policy/managed_mode_policy_provider.h"
21 #include "chrome/browser/policy/managed_mode_policy_provider_factory.h" 25 #include "chrome/browser/policy/managed_mode_policy_provider_factory.h"
22 #include "chrome/browser/policy/policy_service_impl.h" 26 #include "chrome/browser/policy/policy_service_impl.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 564
561 device_cloud_policy_subsystem_->CompleteInitialization( 565 device_cloud_policy_subsystem_->CompleteInitialization(
562 prefs::kDevicePolicyRefreshRate, 566 prefs::kDevicePolicyRefreshRate,
563 kServiceInitializationStartupDelay); 567 kServiceInitializationStartupDelay);
564 } 568 }
565 device_data_store_->set_device_status_collector( 569 device_data_store_->set_device_status_collector(
566 new DeviceStatusCollector( 570 new DeviceStatusCollector(
567 g_browser_process->local_state(), 571 g_browser_process->local_state(),
568 chromeos::system::StatisticsProvider::GetInstance(), 572 chromeos::system::StatisticsProvider::GetInstance(),
569 NULL)); 573 NULL));
574
575 SetTimezoneIfPolicyAvailable();
Joao da Silva 2012/07/27 13:40:57 Notice that CompleteInitialization() is only execu
pneubeck (no reviews) 2012/07/31 22:21:05 The only thing, I don't like about the "execute on
570 #endif 576 #endif
571 } 577 }
572 578
579 #if defined(OS_CHROMEOS)
Joao da Silva 2012/07/27 13:40:57 Move the #ifdef into the method, and make the meth
pneubeck (no reviews) 2012/07/31 22:21:05 Done.
580 void BrowserPolicyConnector::SetTimezoneIfPolicyAvailable() {
581 typedef chromeos::CrosSettingsProvider Provider;
582 Provider::TrustedStatus result =
583 chromeos::CrosSettings::Get()->PrepareTrustedValues(
584 base::Bind(&BrowserPolicyConnector::SetTimezoneIfPolicyAvailable,
585 weak_ptr_factory_.GetWeakPtr()));
586
587 if (result == Provider::TEMPORARILY_UNTRUSTED ||
588 result == Provider::PERMANENTLY_UNTRUSTED)
Joao da Silva 2012/07/27 13:40:57 Nit: indent of the 2nd line Nit: braces when the c
pneubeck (no reviews) 2012/07/31 22:21:05 Done.
589 return;
590
591 DCHECK_EQ(result, Provider::TRUSTED);
592
593 std::string timezone;
594 if (chromeos::CrosSettings::Get()->GetString(
595 chromeos::kSystemTimezonePolicy, &timezone)) {
596 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID(
597 UTF8ToUTF16(timezone));
598 }
599 }
600 #endif
601
573 // static 602 // static
574 ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() { 603 ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() {
575 #if defined(OS_WIN) 604 #if defined(OS_WIN)
576 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); 605 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList();
577 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderWin(policy_list)); 606 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderWin(policy_list));
578 return new AsyncPolicyProvider(loader.Pass()); 607 return new AsyncPolicyProvider(loader.Pass());
579 #elif defined(OS_MACOSX) 608 #elif defined(OS_MACOSX)
580 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList(); 609 const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList();
581 scoped_ptr<AsyncPolicyLoader> loader( 610 scoped_ptr<AsyncPolicyLoader> loader(
582 new PolicyLoaderMac(policy_list, new MacPreferences())); 611 new PolicyLoaderMac(policy_list, new MacPreferences()));
583 return new AsyncPolicyProvider(loader.Pass()); 612 return new AsyncPolicyProvider(loader.Pass());
584 #elif defined(OS_POSIX) 613 #elif defined(OS_POSIX)
585 FilePath config_dir_path; 614 FilePath config_dir_path;
586 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { 615 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) {
587 scoped_ptr<AsyncPolicyLoader> loader( 616 scoped_ptr<AsyncPolicyLoader> loader(
588 new ConfigDirPolicyLoader(config_dir_path, POLICY_SCOPE_MACHINE)); 617 new ConfigDirPolicyLoader(config_dir_path, POLICY_SCOPE_MACHINE));
589 return new AsyncPolicyProvider(loader.Pass()); 618 return new AsyncPolicyProvider(loader.Pass());
590 } else { 619 } else {
591 return NULL; 620 return NULL;
592 } 621 }
593 #else 622 #else
594 return NULL; 623 return NULL;
595 #endif 624 #endif
596 } 625 }
597 626
598 } // namespace policy 627 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698