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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 493613002: Add an enrolling state for consumer management section in settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dn
Patch Set: Fixed broken browser tests. Created 6 years, 3 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/ui/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 #if !defined(OS_CHROMEOS) 94 #if !defined(OS_CHROMEOS)
95 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" 95 #include "chrome/browser/ui/webui/options/advanced_options_utils.h"
96 #endif 96 #endif
97 97
98 #if defined(OS_CHROMEOS) 98 #if defined(OS_CHROMEOS)
99 #include "ash/ash_switches.h" 99 #include "ash/ash_switches.h"
100 #include "ash/desktop_background/user_wallpaper_delegate.h" 100 #include "ash/desktop_background/user_wallpaper_delegate.h"
101 #include "ash/magnifier/magnifier_constants.h" 101 #include "ash/magnifier/magnifier_constants.h"
102 #include "ash/shell.h" 102 #include "ash/shell.h"
103 #include "chrome/browser/browser_process_platform_part.h"
103 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 104 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
104 #include "chrome/browser/chromeos/chromeos_utils.h" 105 #include "chrome/browser/chromeos/chromeos_utils.h"
105 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 106 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
106 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 107 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
107 #include "chrome/browser/chromeos/profiles/profile_helper.h" 108 #include "chrome/browser/chromeos/profiles/profile_helper.h"
108 #include "chrome/browser/chromeos/reset/metrics.h" 109 #include "chrome/browser/chromeos/reset/metrics.h"
109 #include "chrome/browser/chromeos/settings/cros_settings.h" 110 #include "chrome/browser/chromeos/settings/cros_settings.h"
110 #include "chrome/browser/chromeos/settings/device_settings_service.h"
111 #include "chrome/browser/chromeos/system/timezone_util.h" 111 #include "chrome/browser/chromeos/system/timezone_util.h"
112 #include "chrome/browser/policy/profile_policy_connector.h" 112 #include "chrome/browser/policy/profile_policy_connector.h"
113 #include "chrome/browser/policy/profile_policy_connector_factory.h" 113 #include "chrome/browser/policy/profile_policy_connector_factory.h"
114 #include "chrome/browser/ui/browser_window.h" 114 #include "chrome/browser/ui/browser_window.h"
115 #include "chromeos/dbus/dbus_thread_manager.h" 115 #include "chromeos/dbus/dbus_thread_manager.h"
116 #include "chromeos/dbus/power_manager_client.h" 116 #include "chromeos/dbus/power_manager_client.h"
117 #include "components/policy/core/common/policy_map.h" 117 #include "components/policy/core/common/policy_map.h"
118 #include "components/policy/core/common/policy_namespace.h" 118 #include "components/policy/core/common/policy_namespace.h"
119 #include "components/policy/core/common/policy_service.h" 119 #include "components/policy/core/common/policy_service.h"
120 #include "components/user_manager/user.h" 120 #include "components/user_manager/user.h"
121 #include "components/user_manager/user_manager.h" 121 #include "components/user_manager/user_manager.h"
122 #include "policy/policy_constants.h" 122 #include "policy/policy_constants.h"
123 #include "policy/proto/device_management_backend.pb.h"
124 #include "ui/gfx/image/image_skia.h" 123 #include "ui/gfx/image/image_skia.h"
125 #endif // defined(OS_CHROMEOS) 124 #endif // defined(OS_CHROMEOS)
126 125
127 #if defined(OS_WIN) 126 #if defined(OS_WIN)
128 #include "chrome/browser/extensions/settings_api_helpers.h" 127 #include "chrome/browser/extensions/settings_api_helpers.h"
129 #include "chrome/installer/util/auto_launch_util.h" 128 #include "chrome/installer/util/auto_launch_util.h"
130 #include "content/public/browser/browser_url_handler.h" 129 #include "content/public/browser/browser_url_handler.h"
131 #endif // defined(OS_WIN) 130 #endif // defined(OS_WIN)
132 131
133 #if defined(ENABLE_SERVICE_DISCOVERY) 132 #if defined(ENABLE_SERVICE_DISCOVERY)
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 { "autoclickDelayShort", 400 { "autoclickDelayShort",
402 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_SHORT }, 401 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_SHORT },
403 { "autoclickDelayLong", 402 { "autoclickDelayLong",
404 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_LONG }, 403 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_LONG },
405 { "autoclickDelayVeryLong", 404 { "autoclickDelayVeryLong",
406 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_VERY_LONG }, 405 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_VERY_LONG },
407 { "consumerManagementDescription", 406 { "consumerManagementDescription",
408 IDS_OPTIONS_CONSUMER_MANAGEMENT_DESCRIPTION }, 407 IDS_OPTIONS_CONSUMER_MANAGEMENT_DESCRIPTION },
409 { "consumerManagementEnrollButton", 408 { "consumerManagementEnrollButton",
410 IDS_OPTIONS_CONSUMER_MANAGEMENT_ENROLL_BUTTON }, 409 IDS_OPTIONS_CONSUMER_MANAGEMENT_ENROLL_BUTTON },
410 { "consumerManagementEnrollingButton",
411 IDS_OPTIONS_CONSUMER_MANAGEMENT_ENROLLING_BUTTON },
411 { "consumerManagementUnenrollButton", 412 { "consumerManagementUnenrollButton",
412 IDS_OPTIONS_CONSUMER_MANAGEMENT_UNENROLL_BUTTON }, 413 IDS_OPTIONS_CONSUMER_MANAGEMENT_UNENROLL_BUTTON },
414 { "consumerManagementUnenrollingButton",
415 IDS_OPTIONS_CONSUMER_MANAGEMENT_UNENROLLING_BUTTON },
413 { "deviceControlTitle", IDS_OPTIONS_DEVICE_CONTROL_SECTION_TITLE }, 416 { "deviceControlTitle", IDS_OPTIONS_DEVICE_CONTROL_SECTION_TITLE },
414 { "enableContentProtectionAttestation", 417 { "enableContentProtectionAttestation",
415 IDS_OPTIONS_ENABLE_CONTENT_PROTECTION_ATTESTATION }, 418 IDS_OPTIONS_ENABLE_CONTENT_PROTECTION_ATTESTATION },
416 { "factoryResetHeading", IDS_OPTIONS_FACTORY_RESET_HEADING }, 419 { "factoryResetHeading", IDS_OPTIONS_FACTORY_RESET_HEADING },
417 { "factoryResetTitle", IDS_OPTIONS_FACTORY_RESET }, 420 { "factoryResetTitle", IDS_OPTIONS_FACTORY_RESET },
418 { "factoryResetRestart", IDS_OPTIONS_FACTORY_RESET_BUTTON }, 421 { "factoryResetRestart", IDS_OPTIONS_FACTORY_RESET_BUTTON },
419 { "factoryResetDataRestart", IDS_RELAUNCH_BUTTON }, 422 { "factoryResetDataRestart", IDS_RELAUNCH_BUTTON },
420 { "factoryResetWarning", IDS_OPTIONS_FACTORY_RESET_WARNING }, 423 { "factoryResetWarning", IDS_OPTIONS_FACTORY_RESET_WARNING },
421 { "factoryResetHelpUrl", IDS_FACTORY_RESET_HELP_URL }, 424 { "factoryResetHelpUrl", IDS_FACTORY_RESET_HELP_URL },
422 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE }, 425 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE },
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 "easyUnlockAllowed", 623 "easyUnlockAllowed",
621 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsAllowed()); 624 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsAllowed());
622 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl); 625 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl);
623 626
624 #if defined(OS_CHROMEOS) 627 #if defined(OS_CHROMEOS)
625 values->SetBoolean( 628 values->SetBoolean(
626 "consumerManagementEnabled", 629 "consumerManagementEnabled",
627 CommandLine::ForCurrentProcess()->HasSwitch( 630 CommandLine::ForCurrentProcess()->HasSwitch(
628 chromeos::switches::kEnableConsumerManagement)); 631 chromeos::switches::kEnableConsumerManagement));
629 632
630 const enterprise_management::PolicyData* policy_data =
631 chromeos::DeviceSettingsService::Get()->policy_data();
632 values->SetBoolean(
633 "consumerManagementEnrolled",
634 policy_data &&
635 policy_data->management_mode() ==
636 enterprise_management::PolicyData::CONSUMER_MANAGED);
637
638 RegisterTitle(values, "thirdPartyImeConfirmOverlay", 633 RegisterTitle(values, "thirdPartyImeConfirmOverlay",
639 IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE); 634 IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE);
640 #endif 635 #endif
641 636
642 values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser()); 637 values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser());
643 638
644 values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings()); 639 values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings());
645 640
646 values->SetBoolean("websiteSettingsManagerEnabled", 641 values->SetBoolean("websiteSettingsManagerEnabled",
647 CommandLine::ForCurrentProcess()->HasSwitch( 642 CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, 756 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators,
762 base::Unretained(this))); 757 base::Unretained(this)));
763 #endif // defined(OS_WIN) 758 #endif // defined(OS_WIN)
764 } 759 }
765 760
766 void BrowserOptionsHandler::Uninitialize() { 761 void BrowserOptionsHandler::Uninitialize() {
767 registrar_.RemoveAll(); 762 registrar_.RemoveAll();
768 #if defined(OS_WIN) 763 #if defined(OS_WIN)
769 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); 764 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this);
770 #endif 765 #endif
766 #if defined(OS_CHROMEOS)
767 policy::ConsumerManagementService* consumer_management =
768 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
769 GetConsumerManagementService();
770 if (consumer_management)
771 consumer_management->RemoveObserver(this);
772 #endif
771 } 773 }
772 774
773 void BrowserOptionsHandler::OnStateChanged() { 775 void BrowserOptionsHandler::OnStateChanged() {
774 UpdateSyncState(); 776 UpdateSyncState();
775 } 777 }
776 778
777 void BrowserOptionsHandler::GoogleSigninSucceeded(const std::string& account_id, 779 void BrowserOptionsHandler::GoogleSigninSucceeded(const std::string& account_id,
778 const std::string& username, 780 const std::string& username,
779 const std::string& password) { 781 const std::string& password) {
780 OnStateChanged(); 782 OnStateChanged();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 OnAccountPictureManagedChanged( 949 OnAccountPictureManagedChanged(
948 policy::ProfilePolicyConnectorFactory::GetForProfile(profile)-> 950 policy::ProfilePolicyConnectorFactory::GetForProfile(profile)->
949 policy_service()->GetPolicies( 951 policy_service()->GetPolicies(
950 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, 952 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME,
951 std::string())) 953 std::string()))
952 .Get(policy::key::kUserAvatarImage)); 954 .Get(policy::key::kUserAvatarImage));
953 955
954 OnWallpaperManagedChanged( 956 OnWallpaperManagedChanged(
955 chromeos::WallpaperManager::Get()->IsPolicyControlled( 957 chromeos::WallpaperManager::Get()->IsPolicyControlled(
956 user_manager::UserManager::Get()->GetActiveUser()->email())); 958 user_manager::UserManager::Get()->GetActiveUser()->email()));
959
960 policy::ConsumerManagementService* consumer_management =
961 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
962 GetConsumerManagementService();
963 if (consumer_management) {
964 OnConsumerManagementStatusChanged();
965 consumer_management->AddObserver(this);
966 }
957 #endif 967 #endif
958 } 968 }
959 969
960 // static 970 // static
961 void BrowserOptionsHandler::CheckAutoLaunch( 971 void BrowserOptionsHandler::CheckAutoLaunch(
962 base::WeakPtr<BrowserOptionsHandler> weak_this, 972 base::WeakPtr<BrowserOptionsHandler> weak_this,
963 const base::FilePath& profile_path) { 973 const base::FilePath& profile_path) {
964 #if defined(OS_WIN) 974 #if defined(OS_WIN)
965 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 975 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
966 976
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 } 1463 }
1454 1464
1455 void BrowserOptionsHandler::OnPowerwashDialogShow( 1465 void BrowserOptionsHandler::OnPowerwashDialogShow(
1456 const base::ListValue* args) { 1466 const base::ListValue* args) {
1457 UMA_HISTOGRAM_ENUMERATION( 1467 UMA_HISTOGRAM_ENUMERATION(
1458 "Reset.ChromeOS.PowerwashDialogShown", 1468 "Reset.ChromeOS.PowerwashDialogShown",
1459 chromeos::reset::DIALOG_FROM_OPTIONS, 1469 chromeos::reset::DIALOG_FROM_OPTIONS,
1460 chromeos::reset::DIALOG_VIEW_TYPE_SIZE); 1470 chromeos::reset::DIALOG_VIEW_TYPE_SIZE);
1461 } 1471 }
1462 1472
1473 void BrowserOptionsHandler::OnConsumerManagementStatusChanged() {
1474 const std::string& status = g_browser_process->platform_part()->
1475 browser_policy_connector_chromeos()->GetConsumerManagementService()->
1476 GetStatusString();
1477 web_ui()->CallJavascriptFunction(
1478 "BrowserOptions.setConsumerManagementStatus", base::StringValue(status));
1479 }
1480
1463 #endif // defined(OS_CHROMEOS) 1481 #endif // defined(OS_CHROMEOS)
1464 1482
1465 void BrowserOptionsHandler::UpdateSyncState() { 1483 void BrowserOptionsHandler::UpdateSyncState() {
1466 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", 1484 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState",
1467 *GetSyncStateDictionary()); 1485 *GetSyncStateDictionary());
1468 } 1486 }
1469 1487
1470 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { 1488 void BrowserOptionsHandler::OnSigninAllowedPrefChange() {
1471 UpdateSyncState(); 1489 UpdateSyncState();
1472 } 1490 }
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 extension = extensions::GetExtensionOverridingProxy( 1881 extension = extensions::GetExtensionOverridingProxy(
1864 Profile::FromWebUI(web_ui())); 1882 Profile::FromWebUI(web_ui()));
1865 AppendExtensionData("proxy", extension, &extension_controlled); 1883 AppendExtensionData("proxy", extension, &extension_controlled);
1866 1884
1867 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", 1885 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators",
1868 extension_controlled); 1886 extension_controlled);
1869 #endif // defined(OS_WIN) 1887 #endif // defined(OS_WIN)
1870 } 1888 }
1871 1889
1872 } // namespace options 1890 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698