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

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

Powered by Google App Engine
This is Rietveld 408576698