Skip to content

Commit

Permalink
Misc fixes for DeAMP (#12999)
Browse files Browse the repository at this point in the history
- Tweak DeAMP regexes to be lazy
- The amp html attribute might have empty value i.e. amp=""
- Move DeAMP (from Security & Privacy section) and ReduceLanguage (from bottom of brave://settings/shields) settings to be near-top of brave://settings/shields so as to separate them from other per-site privacy settings
  • Loading branch information
ShivanKaul authored Apr 13, 2022
1 parent 704b20f commit f7a643b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@
sub-label="$i18n{statsUsagePingEnabledDesc}"
on-settings-boolean-control-change="onStatsUsagePingEnabledChange_">
</settings-toggle-button>
<settings-toggle-button
class="cr-row"
pref="{{prefs.brave.de_amp.enabled}}"
label="$i18n{deAmpSettingLabel}"
sub-label="$i18n{deAmpSettingSubLabel}">
</settings-toggle-button>
</template>
<script src="brave_personalization_options.js"></script>
</dom-module>
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
pref="{{prefs.brave.shields.stats_badge_visible}}"
label="$i18n{showStatsBlockedBadgeLabel}">
</settings-toggle-button>
<settings-toggle-button
class="cr-row"
pref="{{prefs.brave.de_amp.enabled}}"
label="$i18n{deAmpSettingLabel}"
sub-label="$i18n{deAmpSettingSubLabel}">
</settings-toggle-button>
<settings-toggle-button
class="cr-row"
pref="{{prefs.brave.reduce_language}}"
label="$i18n{reduceLanguageControlLabel}"
sub-label="$i18n{reduceLanguageDesc}">
</settings-toggle-button>
<div class="settings-box">
<div class="start">$i18n{adControlLabel}</div>
<select id="adControlType" class="md-select"
Expand Down Expand Up @@ -104,12 +116,6 @@
</template>
</select>
</div>
<settings-toggle-button
class="cr-row"
pref="{{prefs.brave.reduce_language}}"
label="$i18n{reduceLanguageControlLabel}"
sub-label="$i18n{reduceLanguageDesc}">
</settings-toggle-button>
</template>
<script src="default_brave_shields_page.js"></script>
</dom-module>
5 changes: 3 additions & 2 deletions components/de_amp/browser/de_amp_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ namespace {
// Check for "amp" or "⚡" in <html> tag
// https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/?format=websites#ampd
constexpr char kGetHtmlTagPattern[] = "(<\\s*?html\\s.*?>)";
constexpr char kDetectAmpPattern[] = "(?:<.*\\s.*(amp|⚡)(?:\\s.*>|>|/>))";
constexpr char kDetectAmpPattern[] =
"(?:<.*?\\s.*?(amp|⚡|amp=\"\\s*\"|amp='\\s*')(?:\\s.*?>|>|/>))";
// Look for canonical link tag and get href
// https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/?format=websites#canon
constexpr char kFindCanonicalLinkTagPattern[] =
"(<\\s*link\\s[^>]*rel=(?:\"|')canonical(?:\"|')(?:\\s[^>]*>|>|/>))";
"(<\\s*?link\\s[^>]*?rel=(?:\"|')canonical(?:\"|')(?:\\s[^>]*?>|>|/>))";
constexpr char kFindCanonicalHrefInTagPattern[] = "href=(?:\"|')(.*?)(?:\"|')";
} // namespace

Expand Down

0 comments on commit f7a643b

Please sign in to comment.