Commit 40358733 authored by dpapad's avatar dpapad Committed by Commit Bot

polymer.py: Make chrome://resources/ URL rewriting more robust.

Previously the redirects dictionary had to include several
subpaths separately. For example it included the following keys

chrome://resources/polymer/v1_0/
chrome://resources/html/
chrome://resources/cr_elements/

This  was necessary because the redirects where not applied in
any particular order. By turning the dictionary to an OrderedDict
there is no need to hold all these paths, and instead it can only
hold the following

chrome://resources/polymer/v1_0/ (special case redirect)
chrome://resources/              (default redirect)

Which is more robust, and allows correctly redirecting other
non-special subpaths like chrome://resources/cr_components/ without
having to update the dictionary.

Bug: None
Change-Id: I57eb1f0e9241e05a5150b6463410b653fcbf0c60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274324Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784462}
parent 9019fac9
......@@ -54,6 +54,7 @@ import io
import os
import re
import sys
from collections import OrderedDict
_CWD = os.getcwd()
_HERE_PATH = os.path.dirname(__file__)
......@@ -78,14 +79,13 @@ _ignore_imports = []
_migrated_imports = []
_chrome_redirects = {
'chrome://resources/polymer/v1_0/': POLYMER_V1_DIR,
'chrome://resources/html/': 'ui/webui/resources/html/',
'chrome://resources/cr_elements/': 'ui/webui/resources/cr_elements/',
'//resources/polymer/v1_0/': POLYMER_V1_DIR,
'//resources/html/': 'ui/webui/resources/html/',
'//resources/cr_elements/': 'ui/webui/resources/cr_elements/',
}
# Use an OrderedDict, since the order these redirects are applied matters.
_chrome_redirects = OrderedDict([
('chrome://resources/polymer/v1_0/', POLYMER_V1_DIR),
('chrome://resources/', 'ui/webui/resources/'),
('//resources/polymer/v1_0/', POLYMER_V1_DIR),
('//resources/', 'ui/webui/resources/'),
])
_chrome_reverse_redirects = {
POLYMER_V3_DIR: '//resources/polymer/v3_0/',
......
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