Commit a26cfab7 authored by Yann Dago's avatar Yann Dago Committed by Commit Bot

Reland "Policy WebUI: 'Reload Policies' button reloads google update policies"

This is a reland of e0309342

Original change's description:
> Policy WebUI: 'Reload Policies' button reloads google update policies
>
> Bug: 1119703
> Change-Id: Ib91b37dc1da4f06782caea7b67ecc6d0c8c87b2d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2367673
> Commit-Queue: Yann Dago <ydago@chromium.org>
> Reviewed-by: Owen Min <zmin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#802644}

Bug: 1119703
Change-Id: I0542a481dc512b1c214e050084114cf313c10baf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382216Reviewed-by: default avatarOwen Min <zmin@chromium.org>
Commit-Queue: Yann Dago <ydago@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803150}
parent e2e1850e
...@@ -895,15 +895,7 @@ void PolicyUIHandler::RegisterMessages() { ...@@ -895,15 +895,7 @@ void PolicyUIHandler::RegisterMessages() {
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
updater_status_provider_ = std::make_unique<UpdaterStatusProvider>(); ReloadUpdaterPolicies();
base::PostTaskAndReplyWithResult(
base::ThreadPool::CreateCOMSTATaskRunner(
{base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN, base::MayBlock()})
.get(),
FROM_HERE, base::BindOnce(&GetGoogleUpdatePolicies),
base::BindOnce(&PolicyUIHandler::SetUpdaterPolicies,
weak_factory_.GetWeakPtr()));
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) #endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
if (!user_status_provider_.get()) if (!user_status_provider_.get())
...@@ -1185,6 +1177,11 @@ void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) { ...@@ -1185,6 +1177,11 @@ void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) {
} }
} }
#endif #endif
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
ReloadUpdaterPolicies();
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
GetPolicyService()->RefreshPolicies(base::BindOnce( GetPolicyService()->RefreshPolicies(base::BindOnce(
&PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr())); &PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr()));
} }
...@@ -1295,6 +1292,20 @@ void PolicyUIHandler::SetUpdaterPolicies( ...@@ -1295,6 +1292,20 @@ void PolicyUIHandler::SetUpdaterPolicies(
if (updater_policies_) if (updater_policies_)
SendPolicies(); SendPolicies();
} }
void PolicyUIHandler::ReloadUpdaterPolicies() {
if (!updater_status_provider_)
updater_status_provider_ = std::make_unique<UpdaterStatusProvider>();
base::PostTaskAndReplyWithResult(
base::ThreadPool::CreateCOMSTATaskRunner(
{base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN, base::MayBlock()})
.get(),
FROM_HERE, base::BindOnce(&GetGoogleUpdatePolicies),
base::BindOnce(&PolicyUIHandler::SetUpdaterPolicies,
weak_factory_.GetWeakPtr()));
}
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) #endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
void PolicyUIHandler::OnRefreshPoliciesDone() { void PolicyUIHandler::OnRefreshPoliciesDone() {
......
...@@ -100,6 +100,8 @@ class PolicyUIHandler : public content::WebUIMessageHandler, ...@@ -100,6 +100,8 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
// Sets |updater_policies_| in this instance and refreshes the UI via // Sets |updater_policies_| in this instance and refreshes the UI via
// SendPolicies. // SendPolicies.
void SetUpdaterPolicies(std::unique_ptr<policy::PolicyMap> updater_policies); void SetUpdaterPolicies(std::unique_ptr<policy::PolicyMap> updater_policies);
void ReloadUpdaterPolicies();
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) #endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Send the status of cloud policy to the UI. For each scope that has cloud // Send the status of cloud policy to the UI. For each scope that has cloud
......
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