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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider.cc

Issue 742513006: Add ManagementMode enum and GetManagementMode(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing POLICY_EXPORT Created 6 years 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/settings/device_settings_provider.h" 5 #include "chrome/browser/chromeos/settings/device_settings_provider.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/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 16 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
18 #include "chrome/browser/chromeos/policy/device_local_account.h" 18 #include "chrome/browser/chromeos/policy/device_local_account.h"
19 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 19 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "chrome/browser/chromeos/settings/device_settings_cache.h" 21 #include "chrome/browser/chromeos/settings/device_settings_cache.h"
22 #include "chrome/browser/metrics/metrics_reporting_state.h" 22 #include "chrome/browser/metrics/metrics_reporting_state.h"
23 #include "chrome/installer/util/google_update_settings.h" 23 #include "chrome/installer/util/google_update_settings.h"
24 #include "chromeos/chromeos_switches.h" 24 #include "chromeos/chromeos_switches.h"
25 #include "chromeos/dbus/cryptohome_client.h" 25 #include "chromeos/dbus/cryptohome_client.h"
26 #include "chromeos/dbus/dbus_thread_manager.h" 26 #include "chromeos/dbus/dbus_thread_manager.h"
27 #include "chromeos/settings/cros_settings_names.h" 27 #include "chromeos/settings/cros_settings_names.h"
28 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
28 #include "policy/proto/device_management_backend.pb.h" 29 #include "policy/proto/device_management_backend.pb.h"
29 30
30 using google::protobuf::RepeatedField; 31 using google::protobuf::RepeatedField;
31 using google::protobuf::RepeatedPtrField; 32 using google::protobuf::RepeatedPtrField;
32 33
33 namespace em = enterprise_management; 34 namespace em = enterprise_management;
34 35
35 namespace chromeos { 36 namespace chromeos {
36 37
37 namespace { 38 namespace {
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 608
608 void DeviceSettingsProvider::UpdateValuesCache( 609 void DeviceSettingsProvider::UpdateValuesCache(
609 const em::PolicyData& policy_data, 610 const em::PolicyData& policy_data,
610 const em::ChromeDeviceSettingsProto& settings, 611 const em::ChromeDeviceSettingsProto& settings,
611 TrustedStatus trusted_status) { 612 TrustedStatus trusted_status) {
612 PrefValueMap new_values_cache; 613 PrefValueMap new_values_cache;
613 614
614 // If the device is not managed, or is consumer-managed, we set the device 615 // If the device is not managed, or is consumer-managed, we set the device
615 // owner value. 616 // owner value.
616 if (policy_data.has_username() && 617 if (policy_data.has_username() &&
617 (!policy_data.has_request_token() || 618 (policy::GetManagementMode(policy_data) ==
618 policy_data.management_mode() == em::PolicyData::CONSUMER_MANAGED)) { 619 policy::MANAGEMENT_MODE_LOCAL_OWNER ||
620 policy::GetManagementMode(policy_data) ==
621 policy::MANAGEMENT_MODE_CONSUMER_MANAGED)) {
619 new_values_cache.SetString(kDeviceOwner, policy_data.username()); 622 new_values_cache.SetString(kDeviceOwner, policy_data.username());
620 } 623 }
621 624
622 if (policy_data.has_service_account_identity()) { 625 if (policy_data.has_service_account_identity()) {
623 new_values_cache.SetString(kServiceAccountIdentity, 626 new_values_cache.SetString(kServiceAccountIdentity,
624 policy_data.service_account_identity()); 627 policy_data.service_account_identity());
625 } 628 }
626 629
627 DecodeLoginPolicies(settings, &new_values_cache); 630 DecodeLoginPolicies(settings, &new_values_cache);
628 DecodeKioskPolicies(settings, &new_values_cache); 631 DecodeKioskPolicies(settings, &new_values_cache);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 void DeviceSettingsProvider::AttemptMigration() { 818 void DeviceSettingsProvider::AttemptMigration() {
816 if (device_settings_service_->HasPrivateOwnerKey()) { 819 if (device_settings_service_->HasPrivateOwnerKey()) {
817 PrefValueMap::const_iterator i; 820 PrefValueMap::const_iterator i;
818 for (i = migration_values_.begin(); i != migration_values_.end(); ++i) 821 for (i = migration_values_.begin(); i != migration_values_.end(); ++i)
819 DoSet(i->first, *i->second); 822 DoSet(i->first, *i->second);
820 migration_values_.Clear(); 823 migration_values_.Clear();
821 } 824 }
822 } 825 }
823 826
824 } // namespace chromeos 827 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/fake_device_cloud_policy_initializer.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698