Skip to content

Commit

Permalink
Printing: Delete PrintingAllowedPageSizes policy
Browse files Browse the repository at this point in the history
We are not going to have page size restriction policy in the near
future. If we ever implement this policy it will have more scalable
format (see follow-up CL).

Taking into the account the above, we delete PrintingAllowedPageSizes
policy from the code. It's safe as we have never released this policy
('future': 'true') and have even never had appropriate handler for it.

Bug: 1015690
Change-Id: I38129f8012e82c6a27413597b615c3111593d821
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135690
Commit-Queue: Nikita Podguzov <nikitapodguzov@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758184}
  • Loading branch information
Nikita Podguzov authored and Commit Bot committed Apr 10, 2020
1 parent 558b5c4 commit bdea700
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,6 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
std::make_unique<PrintingAllowedDuplexModesPolicyHandler>());
handlers->AddHandler(
std::make_unique<PrintingAllowedPinModesPolicyHandler>());
handlers->AddHandler(
std::make_unique<PrintingAllowedPageSizesPolicyHandler>());
handlers->AddHandler(std::make_unique<PrintingColorDefaultPolicyHandler>());
handlers->AddHandler(std::make_unique<PrintingDuplexDefaultPolicyHandler>());
handlers->AddHandler(std::make_unique<PrintingPinDefaultPolicyHandler>());
Expand Down
22 changes: 0 additions & 22 deletions chrome/browser/policy/printing_restrictions_policy_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,6 @@ PrintingPinDefaultPolicyHandler::PrintingPinDefaultPolicyHandler()

PrintingPinDefaultPolicyHandler::~PrintingPinDefaultPolicyHandler() = default;

PrintingAllowedPageSizesPolicyHandler::PrintingAllowedPageSizesPolicyHandler()
: ListPolicyHandler(key::kPrintingAllowedPageSizes,
base::Value::Type::DICTIONARY) {}

PrintingAllowedPageSizesPolicyHandler::
~PrintingAllowedPageSizesPolicyHandler() {}

bool PrintingAllowedPageSizesPolicyHandler::CheckListEntry(
const base::Value& value) {
if (!value.is_dict())
return false;
const base::Value* width = value.FindKey(printing::kPageWidthUm);
const base::Value* height = value.FindKey(printing::kPageHeightUm);
return width && height && width->is_int() && height->is_int();
}

void PrintingAllowedPageSizesPolicyHandler::ApplyList(base::Value filtered_list,
PrefValueMap* prefs) {
DCHECK(filtered_list.is_list());
prefs->SetValue(prefs::kPrintingAllowedPageSizes, std::move(filtered_list));
}

PrintingSizeDefaultPolicyHandler::PrintingSizeDefaultPolicyHandler()
: TypeCheckingPolicyHandler(key::kPrintingSizeDefault,
base::Value::Type::DICTIONARY) {}
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/policy/printing_restrictions_policy_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ class PrintingPinDefaultPolicyHandler
~PrintingPinDefaultPolicyHandler() override;
};

class PrintingAllowedPageSizesPolicyHandler : public ListPolicyHandler {
public:
PrintingAllowedPageSizesPolicyHandler();
~PrintingAllowedPageSizesPolicyHandler() override;

// ListPolicyHandler implementation:
bool CheckListEntry(const base::Value& value) override;
void ApplyList(base::Value filtered_list, PrefValueMap* prefs) override;
};

class PrintingSizeDefaultPolicyHandler : public TypeCheckingPolicyHandler {
public:
PrintingSizeDefaultPolicyHandler();
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/prefs/browser_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ const char kInvalidatorSavedInvalidations[] = "invalidator.saved_invalidations";
#if defined(OS_CHROMEOS)
// Deprecated 4/2020
const char kAmbientModeTopicSource[] = "settings.ambient_mode.topic_source";

// Deprecated 4/2020
const char kPrintingAllowedPageSizes[] = "printing.allowed_page_sizes";
#endif // defined(OS_CHROMEOS)

// Register local state used only for migration (clearing or moving to a new
Expand Down Expand Up @@ -609,6 +612,7 @@ void RegisterProfilePrefsForMigration(

#if defined(OS_CHROMEOS)
registry->RegisterIntegerPref(kAmbientModeTopicSource, 0);
registry->RegisterListPref(kPrintingAllowedPageSizes);
#endif // defined(OS_CHROMEOS)
}

Expand Down Expand Up @@ -1209,5 +1213,8 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
#if defined(OS_CHROMEOS)
// Added 4/2020.
profile_prefs->ClearPref(kAmbientModeTopicSource);

// Added 4/2020.
profile_prefs->ClearPref(kPrintingAllowedPageSizes);
#endif
}
1 change: 0 additions & 1 deletion chrome/browser/ui/webui/print_preview/policy_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ void PolicySettings::RegisterProfilePrefs(
registry->RegisterIntegerPref(prefs::kPrintingAllowedColorModes, 0);
registry->RegisterIntegerPref(prefs::kPrintingAllowedDuplexModes, 0);
registry->RegisterIntegerPref(prefs::kPrintingAllowedPinModes, 0);
registry->RegisterListPref(prefs::kPrintingAllowedPageSizes);
registry->RegisterIntegerPref(prefs::kPrintingColorDefault, 0);
registry->RegisterIntegerPref(prefs::kPrintingDuplexDefault, 0);
registry->RegisterIntegerPref(prefs::kPrintingPinDefault, 0);
Expand Down
4 changes: 0 additions & 4 deletions chrome/common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1418,10 +1418,6 @@ const char kPrintingAllowedDuplexModes[] = "printing.allowed_duplex_modes";
// A pref holding the allowed PIN printing modes.
const char kPrintingAllowedPinModes[] = "printing.allowed_pin_modes";

// A pref holding the list of allowed printing duplex mode.
// Empty list is no restriction.
const char kPrintingAllowedPageSizes[] = "printing.allowed_page_sizes";

// A pref holding the default color mode.
const char kPrintingColorDefault[] = "printing.color_default";

Expand Down
1 change: 0 additions & 1 deletion chrome/common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ extern const char kUserNativePrintersAllowed[];
extern const char kPrintingAllowedColorModes[];
extern const char kPrintingAllowedDuplexModes[];
extern const char kPrintingAllowedPinModes[];
extern const char kPrintingAllowedPageSizes[];
extern const char kPrintingColorDefault[];
extern const char kPrintingDuplexDefault[];
extern const char kPrintingPinDefault[];
Expand Down
10 changes: 0 additions & 10 deletions chrome/test/data/policy/policy_test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,6 @@
]
},

"PrintingAllowedPageSizes": {
"os": ["chromeos"],
"policy_pref_mapping_test": [
{
"policies": { "PrintingAllowedPageSizes": [{ "WidthUm": 210000, "HeightUm": 297000 }] },
"prefs": { "printing.allowed_page_sizes": {} }
}
]
},

"PrintingColorDefault": {
"os": ["chromeos"],
"policy_pref_mapping_test": [
Expand Down
37 changes: 1 addition & 36 deletions components/policy/resources/policy_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,6 @@
'PrintingAllowedDuplexModes',
'PrintingAllowedPinModes',
'PrintingAllowedBackgroundGraphicsModes',
'PrintingAllowedPageSizes',
'PrintingColorDefault',
'PrintingDuplexDefault',
'PrintingPinDefault',
Expand Down Expand Up @@ -2324,40 +2323,6 @@
'tags': [],
'desc': '''Restricts background graphics printing mode. Unset policy is treated as no restriction.''',
},
{
'name': 'PrintingAllowedPageSizes',
'owners': ['vkuzkokov@chromium.org'],
'type': 'dict',
'schema': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'WidthUm': {
'description': '''Width of the page in micrometers''',
'type': 'integer',
},
'HeightUm': {
'description': '''Height of the page in micrometers''',
'type': 'integer',
},
},
'required': ['WidthUm', 'HeightUm'],
},
},
'supported_on': ['chrome_os:72-'],
'future': True,
'features': {
'can_be_recommended': False,
'dynamic_refresh': True,
'per_profile': True,
},
'example_value': [{'WidthUm': 210000, 'HeightUm': 297000}],
'id': 476,
'caption': '''Restrict printing page size''',
'tags': [],
'desc': '''Restricts printing page size. Unset policy and empty set are treated as no restriction.''',
},
{
'name': 'PrintingColorDefault',
'owners': ['vkuzkokov@chromium.org'],
Expand Down Expand Up @@ -21323,7 +21288,7 @@ The recommended way to configure policy on Windows is via GPO, although provisio
},
],
'placeholders': [],
'deleted_policy_ids': [412, 546, 562, 569, 578],
'deleted_policy_ids': [412, 476, 546, 562, 569, 578],
'highest_id_currently_used': 691,
'highest_atomic_group_id_currently_used': 38
}
3 changes: 1 addition & 2 deletions printing/backend/printing_restrictions.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ PRINTING_EXPORT extern const char kDefaultColorMode[];
PRINTING_EXPORT extern const char kDefaultDuplexMode[];
PRINTING_EXPORT extern const char kDefaultPinMode[];

// Dictionary keys to be used with |kPrintingAllowedPageSizes| and
// |kPrintingSizeDefault| policies.
// Dictionary keys to be used with |kPrintingSizeDefault| policy.
PRINTING_EXPORT extern const char kPageWidthUm[];
PRINTING_EXPORT extern const char kPageHeightUm[];

Expand Down
1 change: 0 additions & 1 deletion tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19741,7 +19741,6 @@ to ensure that the crash string is shown properly on the user-facing crash UI.
<int value="473" label="ReportUserIDData"/>
<int value="474" label="PrintingAllowedColorModes"/>
<int value="475" label="PrintingAllowedDuplexModes"/>
<int value="476" label="PrintingAllowedPageSizes"/>
<int value="477" label="PrintingColorDefault"/>
<int value="478" label="PrintingDuplexDefault"/>
<int value="479" label="PrintingSizeDefault"/>
Expand Down

0 comments on commit bdea700

Please sign in to comment.