Commit 3ab7de11 authored by Yann Dago's avatar Yann Dago Committed by Commit Bot

Policy WebUI: Enforce AllowFileSelectionDialogs policy on export json

Bug: 1054966
Change-Id: I93f73023e6e6bdc24c329c36b2b14323522a078c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2085156
Commit-Queue: Yann Dago <ydago@chromium.org>
Auto-Submit: Yann Dago <ydago@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747820}
parent cceeacfe
...@@ -449,18 +449,6 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) { ...@@ -449,18 +449,6 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) {
std::string(policy::key::kDefaultImagesSetting), std::string(policy::key::kDefaultImagesSetting),
nullptr); nullptr);
#if !defined(OS_CHROMEOS)
// This also checks that we bypass the policy that blocks file selection
// dialogs. This is a desktop only policy.
values.Set(policy::key::kAllowFileSelectionDialogs,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE,
policy::POLICY_SOURCE_PLATFORM,
std::make_unique<base::Value>(false), nullptr);
SetExpectedPolicy(&expected_values, policy::key::kAllowFileSelectionDialogs,
"mandatory", "machine", "platform", std::string(),
std::string(), false, base::Value(false));
#endif
popups_blocked_for_urls.AppendString("ddd"); popups_blocked_for_urls.AppendString("ddd");
values.Set(policy::key::kPopupsBlockedForUrls, policy::POLICY_LEVEL_MANDATORY, values.Set(policy::key::kPopupsBlockedForUrls, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM, policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM,
...@@ -474,6 +462,24 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) { ...@@ -474,6 +462,24 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) {
// Check writing changed policies to the same file (should overwrite the // Check writing changed policies to the same file (should overwrite the
// contents). // contents).
VerifyExportingPolicies(expected_values); VerifyExportingPolicies(expected_values);
#if !defined(OS_CHROMEOS)
// This also checks that we do not bypass the policy that blocks file
// selection dialogs. This is a desktop only policy.
values.Set(policy::key::kAllowFileSelectionDialogs,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE,
policy::POLICY_SOURCE_PLATFORM,
std::make_unique<base::Value>(false), nullptr);
popups_blocked_for_urls.AppendString("eeeeee");
values.Set(policy::key::kPopupsBlockedForUrls, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM,
popups_blocked_for_urls.CreateDeepCopy(), nullptr);
provider_.UpdateChromePolicy(values);
// Check writing changed policies did not overwrite the exported policies
// because the file selection dialog is not allowed.
VerifyExportingPolicies(expected_values);
#endif
} }
IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyNames) { IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyNames) {
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/schema_registry_service.h" #include "chrome/browser/policy/schema_registry_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/webui/webui_util.h" #include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
...@@ -69,7 +70,6 @@ ...@@ -69,7 +70,6 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h" #include "ui/base/l10n/time_format.h"
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
#include "ui/shell_dialogs/select_file_policy.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/ui/android/android_about_app_info.h" #include "chrome/browser/ui/android/android_about_app_info.h"
...@@ -1054,13 +1054,9 @@ void PolicyUIHandler::HandleExportPoliciesJson(const base::ListValue* args) { ...@@ -1054,13 +1054,9 @@ void PolicyUIHandler::HandleExportPoliciesJson(const base::ListValue* args) {
base::FilePath initial_path = base::FilePath initial_path =
initial_dir.Append(FILE_PATH_LITERAL("policies.json")); initial_dir.Append(FILE_PATH_LITERAL("policies.json"));
// Here we overwrite the actual value of SelectFileDialog policy by passing a
// nullptr to ui::SelectFileDialog::Create instead of the actual policy value.
// This is done for the following reason: the admin might want to set this
// policy for the user to forbid the select file dialogs, but this shouldn't
// block the possibility to export the policies.
export_policies_select_file_dialog_ = ui::SelectFileDialog::Create( export_policies_select_file_dialog_ = ui::SelectFileDialog::Create(
this, std::unique_ptr<ui::SelectFilePolicy>()); this,
std::make_unique<ChromeSelectFilePolicy>(web_ui()->GetWebContents()));
ui::SelectFileDialog::FileTypeInfo file_type_info; ui::SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions = {{FILE_PATH_LITERAL("json")}}; file_type_info.extensions = {{FILE_PATH_LITERAL("json")}};
gfx::NativeWindow owning_window = webcontents->GetTopLevelNativeWindow(); gfx::NativeWindow owning_window = webcontents->GetTopLevelNativeWindow();
......
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