| 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 "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/message_loop.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/policy/async_policy_provider.h" | 14 #include "chrome/browser/policy/async_policy_provider.h" |
| 14 #include "chrome/browser/policy/cloud_policy_client.h" | 15 #include "chrome/browser/policy/cloud_policy_client.h" |
| 15 #include "chrome/browser/policy/cloud_policy_provider.h" | 16 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 16 #include "chrome/browser/policy/cloud_policy_service.h" | 17 #include "chrome/browser/policy/cloud_policy_service.h" |
| 17 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 18 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 18 #include "chrome/browser/policy/configuration_policy_provider.h" | 19 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 19 #include "chrome/browser/policy/device_management_service.h" | 20 #include "chrome/browser/policy/device_management_service.h" |
| 20 #include "chrome/browser/policy/managed_mode_policy_provider.h" | 21 #include "chrome/browser/policy/managed_mode_policy_provider.h" |
| 21 #include "chrome/browser/policy/managed_mode_policy_provider_factory.h" | 22 #include "chrome/browser/policy/managed_mode_policy_provider_factory.h" |
| 22 #include "chrome/browser/policy/policy_service_impl.h" | 23 #include "chrome/browser/policy/policy_service_impl.h" |
| 24 #include "chrome/browser/policy/policy_statistics_collector.h" |
| 23 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 25 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
| 24 #include "chrome/browser/policy/user_policy_cache.h" | 26 #include "chrome/browser/policy/user_policy_cache.h" |
| 25 #include "chrome/browser/policy/user_policy_token_cache.h" | 27 #include "chrome/browser/policy/user_policy_token_cache.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/signin/token_service.h" | 29 #include "chrome/browser/signin/token_service.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 32 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (!command_line->HasSwitch(switches::kEnableCloudPolicyService)) { | 155 if (!command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 154 managed_cloud_provider_.reset(new CloudPolicyProvider( | 156 managed_cloud_provider_.reset(new CloudPolicyProvider( |
| 155 this, | 157 this, |
| 156 POLICY_LEVEL_MANDATORY)); | 158 POLICY_LEVEL_MANDATORY)); |
| 157 recommended_cloud_provider_.reset(new CloudPolicyProvider( | 159 recommended_cloud_provider_.reset(new CloudPolicyProvider( |
| 158 this, | 160 this, |
| 159 POLICY_LEVEL_RECOMMENDED)); | 161 POLICY_LEVEL_RECOMMENDED)); |
| 160 } | 162 } |
| 161 | 163 |
| 162 InitializeDevicePolicy(); | 164 InitializeDevicePolicy(); |
| 165 #endif |
| 163 | 166 |
| 164 // Complete the initialization once the message loops are spinning. | 167 // Complete the initialization once the message loops are spinning. |
| 165 MessageLoop::current()->PostTask( | 168 MessageLoop::current()->PostTask( |
| 166 FROM_HERE, | 169 FROM_HERE, |
| 167 base::Bind(&BrowserPolicyConnector::CompleteInitialization, | 170 base::Bind(&BrowserPolicyConnector::CompleteInitialization, |
| 168 weak_ptr_factory_.GetWeakPtr())); | 171 weak_ptr_factory_.GetWeakPtr())); |
| 169 #endif | |
| 170 } | 172 } |
| 171 | 173 |
| 172 scoped_ptr<UserCloudPolicyManager> | 174 scoped_ptr<UserCloudPolicyManager> |
| 173 BrowserPolicyConnector::CreateCloudPolicyManager(Profile* profile) { | 175 BrowserPolicyConnector::CreateCloudPolicyManager(Profile* profile) { |
| 174 scoped_ptr<UserCloudPolicyManager> manager; | 176 scoped_ptr<UserCloudPolicyManager> manager; |
| 175 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 177 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 176 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { | 178 if (command_line->HasSwitch(switches::kEnableCloudPolicyService)) { |
| 177 bool wait_for_policy_fetch = false; | 179 bool wait_for_policy_fetch = false; |
| 178 #if defined(OS_CHROMEOS) | 180 #if defined(OS_CHROMEOS) |
| 179 // TODO(mnissler): Revisit once Chrome OS gains multi-profiles support. | 181 // TODO(mnissler): Revisit once Chrome OS gains multi-profiles support. |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 if (device_data_store_.get()) { | 617 if (device_data_store_.get()) { |
| 616 device_data_store_->set_device_status_collector( | 618 device_data_store_->set_device_status_collector( |
| 617 new DeviceStatusCollector( | 619 new DeviceStatusCollector( |
| 618 g_browser_process->local_state(), | 620 g_browser_process->local_state(), |
| 619 chromeos::system::StatisticsProvider::GetInstance(), | 621 chromeos::system::StatisticsProvider::GetInstance(), |
| 620 NULL)); | 622 NULL)); |
| 621 } | 623 } |
| 622 | 624 |
| 623 SetTimezoneIfPolicyAvailable(); | 625 SetTimezoneIfPolicyAvailable(); |
| 624 #endif | 626 #endif |
| 627 |
| 628 // TODO: Do not use g_browser_process once policy service is moved to |
| 629 // BrowserPolicyConnector (http://crbug.com/128999). |
| 630 policy_statistics_collector_.reset(new policy::PolicyStatisticsCollector( |
| 631 g_browser_process->policy_service(), |
| 632 g_browser_process->local_state(), |
| 633 MessageLoop::current()->message_loop_proxy())); |
| 625 } | 634 } |
| 626 | 635 |
| 627 void BrowserPolicyConnector::SetTimezoneIfPolicyAvailable() { | 636 void BrowserPolicyConnector::SetTimezoneIfPolicyAvailable() { |
| 628 #if defined(OS_CHROMEOS) | 637 #if defined(OS_CHROMEOS) |
| 629 typedef chromeos::CrosSettingsProvider Provider; | 638 typedef chromeos::CrosSettingsProvider Provider; |
| 630 Provider::TrustedStatus result = | 639 Provider::TrustedStatus result = |
| 631 chromeos::CrosSettings::Get()->PrepareTrustedValues( | 640 chromeos::CrosSettings::Get()->PrepareTrustedValues( |
| 632 base::Bind(&BrowserPolicyConnector::SetTimezoneIfPolicyAvailable, | 641 base::Bind(&BrowserPolicyConnector::SetTimezoneIfPolicyAvailable, |
| 633 weak_ptr_factory_.GetWeakPtr())); | 642 weak_ptr_factory_.GetWeakPtr())); |
| 634 | 643 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 663 return new AsyncPolicyProvider(loader.Pass()); | 672 return new AsyncPolicyProvider(loader.Pass()); |
| 664 } else { | 673 } else { |
| 665 return NULL; | 674 return NULL; |
| 666 } | 675 } |
| 667 #else | 676 #else |
| 668 return NULL; | 677 return NULL; |
| 669 #endif | 678 #endif |
| 670 } | 679 } |
| 671 | 680 |
| 672 } // namespace policy | 681 } // namespace policy |
| OLD | NEW |