Skip to content

Commit

Permalink
Merge add profile id to chrome://policy to M109
Browse files Browse the repository at this point in the history
This is a merge request

(cherry picked from commit 6f303e4)

Bug: 1384158
Change-Id: I0380924e85f230491c0df40e32244c0026a488f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4030967
Commit-Queue: Hamda Mare <hmare@google.com>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: Yann Dago <ydago@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1072979}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4041846
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5414@{#179}
Cr-Branched-From: 4417ee5-refs/heads/main@{#1070088}
  • Loading branch information
hmare authored and Chromium LUCI CQ committed Nov 22, 2022
1 parent 565deda commit 40fa7ba
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,7 @@ static_library("browser") {
"//chrome/browser/browsing_data:constants",
"//chrome/browser/chrome_for_testing:buildflags",
"//chrome/browser/devtools",
"//chrome/browser/enterprise/identifiers",
"//chrome/browser/enterprise/platform_auth:features",
"//chrome/browser/favicon",
"//chrome/browser/feature_guide/notifications:public",
Expand Down
14 changes: 14 additions & 0 deletions chrome/browser/policy/status_provider/status_provider_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "chrome/browser/policy/status_provider/status_provider_util.h"

#include "base/values.h"
#include "chrome/browser/enterprise/identifiers/profile_id_service_factory.h"
#include "components/enterprise/browser/identifiers/profile_id_service.h"
#include "components/policy/core/browser/webui/policy_status_provider.h"
#include "google_apis/gaia/gaia_auth_util.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
Expand Down Expand Up @@ -56,6 +58,18 @@ void SetDomainInUserStatus(base::Value::Dict& user_status) {
user_status.Set(policy::kDomainKey, gaia::ExtractDomainName(*username));
}

void SetProfileId(base::Value::Dict* dict, Profile* profile) {
CHECK(profile);
auto* profile_id_service =
enterprise::ProfileIdServiceFactory::GetForProfile(profile);
if (!profile_id_service)
return;

auto profile_id = profile_id_service->GetProfileId();
if (profile_id)
dict->Set("profileId", profile_id.value());
}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void GetOffHoursStatus(base::Value::Dict* dict) {
policy::off_hours::DeviceOffHoursController* off_hours_controller =
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/policy/status_provider/status_provider_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ void GetUserAffiliationStatus(base::Value::Dict* dict, Profile* profile);
// domain of username.
void SetDomainInUserStatus(base::Value::Dict& user_status);

// Adds a new entry to |dict| with the enterprise profile identifier of the
// current |profile|.
void SetProfileId(base::Value::Dict* dict, Profile* profile);

#if BUILDFLAG(IS_CHROMEOS_ASH)
void GetOffHoursStatus(base::Value::Dict* dict);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ base::Value::Dict UserCloudPolicyStatusProvider::GetStatus() {
GetUserAffiliationStatus(&dict, profile_);
dict.Set(policy::kPolicyDescriptionKey, kUserPolicyStatusDescription);
SetDomainInUserStatus(dict);
SetProfileId(&dict, profile_);
return dict;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ base::Value::Dict UserCloudPolicyStatusProviderChromeOS::GetStatus() {
GetUserManager(&dict, profile_);
dict.Set(policy::kPolicyDescriptionKey, kUserPolicyStatusDescription);
SetDomainInUserStatus(dict);
SetProfileId(&dict, profile_);
return dict;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ base::Value::Dict UserPolicyStatusProviderLacros::GetStatus() {
policy::CloudPolicyValidatorBase::Status::VALIDATION_OK));
dict.Set(policy::kPolicyDescriptionKey, kUserPolicyStatusDescription);
SetDomainInUserStatus(dict);
SetProfileId(&dict, profile_);
return dict;
}
1 change: 1 addition & 0 deletions chrome/browser/ui/webui/policy/policy_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() {
{"labelIsOffHoursActive", IDS_POLICY_LABEL_IS_OFFHOURS_ACTIVE},
{"labelPoliciesPush", IDS_POLICY_LABEL_PUSH_POLICIES},
{"labelPrecedence", IDS_POLICY_LABEL_PRECEDENCE},
{"labelProfileId", IDS_POLICY_LABEL_PROFILE_ID},
{"labelRefreshInterval", IDS_POLICY_LABEL_REFRESH_INTERVAL},
{"labelStatus", IDS_POLICY_LABEL_STATUS},
{"labelTimeSinceLastFetchAttempt",
Expand Down
4 changes: 4 additions & 0 deletions components/policy/resources/webui/status_box.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
<div class="label">$i18n{labelClientId}</div>
<div class="client-id"></div>
</div>
<div class="status-entry" hidden>
<div class="label">$i18n{labelProfileId}</div>
<div class="profile-id"></div>
</div>
<div class="status-entry" hidden>
<div class="label">$i18n{labelAssetId}</div>
<div class="asset-id"></div>
Expand Down
2 changes: 2 additions & 0 deletions components/policy/resources/webui/status_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export class StatusBoxElement extends CustomElement {
// Populate the user gaia id.
this.setLabelAndShow_('.gaia-id', status.gaiaId || notSpecifiedString);
this.setLabelAndShow_('.client-id', status.clientId);
this.setLabelAndShow_('.profile-id', status.profileId);

if (status.isAffiliated != null) {
this.setLabelAndShow_(
'.is-affiliated',
Expand Down
3 changes: 3 additions & 0 deletions components/policy_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ Additional details:
<message name="IDS_POLICY_LABEL_CLIENT_ID" desc="Label for the client IDs in the policy status boxes.">
Client ID:
</message>
<message name="IDS_POLICY_LABEL_PROFILE_ID" desc="Label for the user profile ID in the user policy status box.">
Profile ID:
</message>
<message name="IDS_POLICY_LABEL_ASSET_ID" desc="Label for the asset ID in the device policy status box.">
Asset ID:
</message>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cfa02041b09a032541ccd7e49381226210671cd9
1 change: 1 addition & 0 deletions ios/chrome/browser/ui/webui/policy/policy_ui.mm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
{"labelIsOffHoursActive", IDS_POLICY_LABEL_IS_OFFHOURS_ACTIVE},
{"labelPoliciesPush", IDS_POLICY_LABEL_PUSH_POLICIES},
{"labelPrecedence", IDS_POLICY_LABEL_PRECEDENCE},
{"labelProfileId", IDS_POLICY_LABEL_PROFILE_ID},
{"labelRefreshInterval", IDS_POLICY_LABEL_REFRESH_INTERVAL},
{"labelStatus", IDS_POLICY_LABEL_STATUS},
{"labelTimeSinceLastFetchAttempt",
Expand Down

0 comments on commit 40fa7ba

Please sign in to comment.