Commit 2b5b5451 authored by Varun Khaneja's avatar Varun Khaneja Committed by Commit Bot

Detect enterprise enrollment status for ChromeOS.

Bug: 796332
Change-Id: Ia1ddddc9397531e60f6dd524bbec994154316ffb
Reviewed-on: https://chromium-review.googlesource.com/1056163
Commit-Queue: Varun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarJialiu Lin <jialiul@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558482}
parent 4f5af39d
...@@ -63,6 +63,9 @@ class BrowserPolicyConnectorChromeOS ...@@ -63,6 +63,9 @@ class BrowserPolicyConnectorChromeOS
PrefService* local_state, PrefService* local_state,
scoped_refptr<net::URLRequestContextGetter> request_context) override; scoped_refptr<net::URLRequestContextGetter> request_context) override;
// Checks whether this devices is under any kind of enterprise management.
bool IsEnterpriseManaged() const override;
// Shutdown() is called from BrowserProcessImpl::StartTearDown() but |this| // Shutdown() is called from BrowserProcessImpl::StartTearDown() but |this|
// observes some objects that get destroyed earlier. PreShutdown() is called // observes some objects that get destroyed earlier. PreShutdown() is called
// from ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun(), allowing the // from ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun(), allowing the
...@@ -71,9 +74,6 @@ class BrowserPolicyConnectorChromeOS ...@@ -71,9 +74,6 @@ class BrowserPolicyConnectorChromeOS
void Shutdown() override; void Shutdown() override;
// Checks whether this devices is under any kind of enterprise management.
bool IsEnterpriseManaged() const;
// Checks whether this is a cloud (DM server) managed enterprise device. // Checks whether this is a cloud (DM server) managed enterprise device.
bool IsCloudManaged() const; bool IsCloudManaged() const;
......
...@@ -124,6 +124,11 @@ void ChromeBrowserPolicyConnector::Init( ...@@ -124,6 +124,11 @@ void ChromeBrowserPolicyConnector::Init(
#endif #endif
} }
bool ChromeBrowserPolicyConnector::IsEnterpriseManaged() const {
NOTREACHED() << "This method is only defined for Chrome OS";
return false;
}
void ChromeBrowserPolicyConnector::Shutdown() { void ChromeBrowserPolicyConnector::Shutdown() {
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
// Reset the registrar and fetcher before calling base class so that // Reset the registrar and fetcher before calling base class so that
......
...@@ -55,6 +55,8 @@ class ChromeBrowserPolicyConnector : public BrowserPolicyConnector { ...@@ -55,6 +55,8 @@ class ChromeBrowserPolicyConnector : public BrowserPolicyConnector {
PrefService* local_state, PrefService* local_state,
scoped_refptr<net::URLRequestContextGetter> request_context) override; scoped_refptr<net::URLRequestContextGetter> request_context) override;
bool IsEnterpriseManaged() const override;
void Shutdown() override; void Shutdown() override;
ConfigurationPolicyProvider* GetPlatformProvider(); ConfigurationPolicyProvider* GetPlatformProvider();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h" #include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h" #include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h"
#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h"
...@@ -244,6 +245,11 @@ bool ChromePasswordProtectionService::IsPasswordReuseProtectionConfigured( ...@@ -244,6 +245,11 @@ bool ChromePasswordProtectionService::IsPasswordReuseProtectionConfigured(
prefs::kPasswordProtectionWarningTrigger) == PASSWORD_REUSE; prefs::kPasswordProtectionWarningTrigger) == PASSWORD_REUSE;
} }
const policy::BrowserPolicyConnector*
ChromePasswordProtectionService::GetBrowserPolicyConnector() const {
return g_browser_process->browser_policy_connector();
}
void ChromePasswordProtectionService::FillReferrerChain( void ChromePasswordProtectionService::FillReferrerChain(
const GURL& event_url, const GURL& event_url,
SessionID event_tab_id, SessionID event_tab_id,
......
...@@ -26,6 +26,10 @@ namespace content { ...@@ -26,6 +26,10 @@ namespace content {
class WebContents; class WebContents;
} }
namespace policy {
class BrowserPolicyConnector;
}
namespace safe_browsing { namespace safe_browsing {
class SafeBrowsingService; class SafeBrowsingService;
...@@ -168,6 +172,9 @@ class ChromePasswordProtectionService : public PasswordProtectionService { ...@@ -168,6 +172,9 @@ class ChromePasswordProtectionService : public PasswordProtectionService {
protected: protected:
// PasswordProtectionService overrides. // PasswordProtectionService overrides.
const policy::BrowserPolicyConnector* GetBrowserPolicyConnector()
const override;
// Obtains referrer chain of |event_url| and |event_tab_id| and add this // Obtains referrer chain of |event_url| and |event_tab_id| and add this
// info into |frame|. // info into |frame|.
void FillReferrerChain(const GURL& event_url, void FillReferrerChain(const GURL& event_url,
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_service.h" #include "chrome/browser/chrome_service.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/constants.mojom.h" #include "chrome/common/constants.mojom.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -297,7 +298,8 @@ void ClientSideDetectionService::StartClientReportPhishingRequest( ...@@ -297,7 +298,8 @@ void ClientSideDetectionService::StartClientReportPhishingRequest(
DVLOG(2) << "Starting report for hit on model " << request->model_filename(); DVLOG(2) << "Starting report for hit on model " << request->model_filename();
request->mutable_population()->set_profile_management_status( request->mutable_population()->set_profile_management_status(
GetProfileManagementStatus()); GetProfileManagementStatus(
g_browser_process->browser_policy_connector()));
std::string request_data; std::string request_data;
if (!request->SerializeToString(&request_data)) { if (!request->SerializeToString(&request_data)) {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/download_protection/download_feedback_service.h" #include "chrome/browser/safe_browsing/download_protection/download_feedback_service.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
...@@ -862,7 +863,8 @@ void CheckClientDownloadRequest::SendRequest() { ...@@ -862,7 +863,8 @@ void CheckClientDownloadRequest::SendRequest() {
: ChromeUserPopulation::SAFE_BROWSING; : ChromeUserPopulation::SAFE_BROWSING;
request.mutable_population()->set_user_population(population); request.mutable_population()->set_user_population(population);
request.mutable_population()->set_profile_management_status( request.mutable_population()->set_profile_management_status(
GetProfileManagementStatus()); GetProfileManagementStatus(
g_browser_process->browser_policy_connector()));
request.set_url(SanitizeUrl(item_->GetUrlChain().back())); request.set_url(SanitizeUrl(item_->GetUrlChain().back()));
request.mutable_digests()->set_sha256(item_->GetHash()); request.mutable_digests()->set_sha256(item_->GetHash());
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_util.h" #include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
...@@ -168,7 +170,8 @@ void PPAPIDownloadRequest::SendRequest() { ...@@ -168,7 +170,8 @@ void PPAPIDownloadRequest::SendRequest() {
: ChromeUserPopulation::SAFE_BROWSING; : ChromeUserPopulation::SAFE_BROWSING;
request.mutable_population()->set_user_population(population); request.mutable_population()->set_user_population(population);
request.mutable_population()->set_profile_management_status( request.mutable_population()->set_profile_management_status(
GetProfileManagementStatus()); GetProfileManagementStatus(
g_browser_process->browser_policy_connector()));
request.set_download_type(ClientDownloadRequest::PPAPI_SAVE_REQUEST); request.set_download_type(ClientDownloadRequest::PPAPI_SAVE_REQUEST);
ClientDownloadRequest::Resource* resource = request.add_resources(); ClientDownloadRequest::Resource* resource = request.add_resources();
resource->set_type(ClientDownloadRequest::PPAPI_DOCUMENT); resource->set_type(ClientDownloadRequest::PPAPI_DOCUMENT);
......
...@@ -38,6 +38,9 @@ class POLICY_EXPORT BrowserPolicyConnector : public BrowserPolicyConnectorBase { ...@@ -38,6 +38,9 @@ class POLICY_EXPORT BrowserPolicyConnector : public BrowserPolicyConnectorBase {
PrefService* local_state, PrefService* local_state,
scoped_refptr<net::URLRequestContextGetter> request_context) = 0; scoped_refptr<net::URLRequestContextGetter> request_context) = 0;
// Checks whether this device is under any kind of enterprise management.
virtual bool IsEnterpriseManaged() const = 0;
// Cleans up the connector before it can be safely deleted. // Cleans up the connector before it can be safely deleted.
void Shutdown() override; void Shutdown() override;
......
...@@ -17,6 +17,7 @@ source_set("common") { ...@@ -17,6 +17,7 @@ source_set("common") {
deps = [ deps = [
"//base", "//base",
"//components/policy/core/browser:browser",
"//components/safe_browsing:csd_proto", "//components/safe_browsing:csd_proto",
"//crypto:crypto", "//crypto:crypto",
"//ipc", "//ipc",
......
include_rules = [ include_rules = [
"+components/policy/core/browser",
"+components/pref_registry", "+components/pref_registry",
"+components/prefs", "+components/prefs",
"+content/public/test", "+content/public/test",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "crypto/sha2.h" #include "crypto/sha2.h"
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -32,16 +33,20 @@ void LogNoUserActionResourceLoadingDelay(base::TimeDelta time) { ...@@ -32,16 +33,20 @@ void LogNoUserActionResourceLoadingDelay(base::TimeDelta time) {
UMA_HISTOGRAM_LONG_TIMES("SB2.NoUserActionResourceLoadingDelay", time); UMA_HISTOGRAM_LONG_TIMES("SB2.NoUserActionResourceLoadingDelay", time);
} }
ChromeUserPopulation::ProfileManagementStatus GetProfileManagementStatus() { ChromeUserPopulation::ProfileManagementStatus GetProfileManagementStatus(
const policy::BrowserPolicyConnector* bpc) {
#if defined(OS_WIN) #if defined(OS_WIN)
if (base::win::IsEnterpriseManaged()) if (base::win::IsEnterpriseManaged())
return ChromeUserPopulation::ENTERPRISE_MANAGED; return ChromeUserPopulation::ENTERPRISE_MANAGED;
else else
return ChromeUserPopulation::NOT_MANAGED; return ChromeUserPopulation::NOT_MANAGED;
#elif defined(OS_CHROMEOS)
if (!bpc || !bpc->IsEnterpriseManaged())
return ChromeUserPopulation::NOT_MANAGED;
return ChromeUserPopulation::ENTERPRISE_MANAGED;
#else #else
// TODO(crbug/796332): Add check for OS_CHROMEOS also.
return ChromeUserPopulation::UNAVAILABLE; return ChromeUserPopulation::UNAVAILABLE;
#endif // #if defined(OS_WIN) #endif // #if defined(OS_WIN) || defined(OS_CHROMEOS)
} }
} // namespace safe_browsing } // namespace safe_browsing
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include "components/safe_browsing/proto/csd.pb.h" #include "components/safe_browsing/proto/csd.pb.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace policy {
class BrowserPolicyConnector;
} // namespace policy
namespace safe_browsing { namespace safe_browsing {
// Shorten URL by replacing its contents with its SHA256 hash if it has data // Shorten URL by replacing its contents with its SHA256 hash if it has data
...@@ -24,7 +28,11 @@ std::string ShortURLForReporting(const GURL& url); ...@@ -24,7 +28,11 @@ std::string ShortURLForReporting(const GURL& url);
// a load, the sum of all the delays will be reported. // a load, the sum of all the delays will be reported.
void LogNoUserActionResourceLoadingDelay(base::TimeDelta time); void LogNoUserActionResourceLoadingDelay(base::TimeDelta time);
ChromeUserPopulation::ProfileManagementStatus GetProfileManagementStatus(); // Gets the |ProfileManagementStatus| for the current machine. The method
// currently works only on Windows and ChromeOS. The |bpc| parameter is used
// only on ChromeOS, and may be |nullptr|.
ChromeUserPopulation::ProfileManagementStatus GetProfileManagementStatus(
const policy::BrowserPolicyConnector* bpc);
} // namespace safe_browsing } // namespace safe_browsing
......
...@@ -24,6 +24,8 @@ class MockPasswordProtectionService : public PasswordProtectionService { ...@@ -24,6 +24,8 @@ class MockPasswordProtectionService : public PasswordProtectionService {
MOCK_CONST_METHOD0(GetSyncAccountType, MOCK_CONST_METHOD0(GetSyncAccountType,
safe_browsing::LoginReputationClientRequest:: safe_browsing::LoginReputationClientRequest::
PasswordReuseEvent::SyncAccountType()); PasswordReuseEvent::SyncAccountType());
MOCK_CONST_METHOD0(GetBrowserPolicyConnector,
const policy::BrowserPolicyConnector*());
MOCK_CONST_METHOD1( MOCK_CONST_METHOD1(
GetPasswordProtectionTriggerPref, GetPasswordProtectionTriggerPref,
safe_browsing::PasswordProtectionTrigger(const std::string& pref_name)); safe_browsing::PasswordProtectionTrigger(const std::string& pref_name));
......
...@@ -552,7 +552,8 @@ void PasswordProtectionService::FillUserPopulation( ...@@ -552,7 +552,8 @@ void PasswordProtectionService::FillUserPopulation(
user_population->set_user_population( user_population->set_user_population(
IsExtendedReporting() ? ChromeUserPopulation::EXTENDED_REPORTING IsExtendedReporting() ? ChromeUserPopulation::EXTENDED_REPORTING
: ChromeUserPopulation::SAFE_BROWSING); : ChromeUserPopulation::SAFE_BROWSING);
user_population->set_profile_management_status(GetProfileManagementStatus()); user_population->set_profile_management_status(
GetProfileManagementStatus(GetBrowserPolicyConnector()));
user_population->set_is_history_sync_enabled(IsHistorySyncEnabled()); user_population->set_is_history_sync_enabled(IsHistorySyncEnabled());
} }
......
...@@ -34,6 +34,10 @@ namespace history { ...@@ -34,6 +34,10 @@ namespace history {
class HistoryService; class HistoryService;
} }
namespace policy {
class BrowserPolicyConnector;
}
class GURL; class GURL;
class HostContentSettingsMap; class HostContentSettingsMap;
...@@ -285,6 +289,10 @@ class PasswordProtectionService : public history::HistoryServiceObserver { ...@@ -285,6 +289,10 @@ class PasswordProtectionService : public history::HistoryServiceObserver {
virtual int GetStoredVerdictCount( virtual int GetStoredVerdictCount(
LoginReputationClientRequest::TriggerType trigger_type); LoginReputationClientRequest::TriggerType trigger_type);
// Gets an unowned |BrowserPolicyConnector| for the current platform.
virtual const policy::BrowserPolicyConnector* GetBrowserPolicyConnector()
const = 0;
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory() { scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory() {
return url_loader_factory_; return url_loader_factory_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment