123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356 |
- From: uazo <uazo@users.noreply.github.com>
- Date: Wed, 30 Sep 2020 07:40:01 +0000
- Subject: Timezone customization
- Allow specifying a custom timezone, or using a random one.
- See also: https://github.com/bromite/bromite/wiki/TimezoneOverride
- ---
- .../ChromeSiteSettingsDelegate.java | 16 ++
- .../browser_ui/site_settings/android/BUILD.gn | 3 +
- .../res/layout/time_zone_select_dialog.xml | 36 ++++
- ...ezoneoverride_site_settings_preference.xml | 68 ++++++
- .../res/xml/site_settings_preferences.xml | 4 +
- .../java/res/xml/website_preferences.xml | 9 +
- .../ContentSettingsResources.java | 35 +++-
- .../site_settings/SingleCategorySettings.java | 77 ++++++-
- .../site_settings/SingleWebsiteSettings.java | 8 +-
- .../site_settings/SiteSettings.java | 2 +-
- .../site_settings/SiteSettingsCategory.java | 9 +-
- .../site_settings/SiteSettingsDelegate.java | 2 +
- ...imezoneOverrideSiteSettingsPreference.java | 193 ++++++++++++++++++
- .../browser_ui/site_settings/Website.java | 10 +
- .../WebsitePermissionsFetcher.java | 3 +
- .../WebsitePreferenceBridge.java | 12 ++
- .../android/website_preference_bridge.cc | 16 ++
- .../strings/android/site_settings.grdp | 35 ++++
- .../browser/content_settings_pref_provider.cc | 16 ++
- .../browser/content_settings_pref_provider.h | 4 +
- .../core/browser/content_settings_registry.cc | 12 ++
- .../core/browser/content_settings_utils.cc | 7 +
- .../core/browser/host_content_settings_map.cc | 8 +
- .../core/browser/host_content_settings_map.h | 3 +
- .../core/common/content_settings.cc | 3 +-
- .../core/common/content_settings.h | 2 +
- .../core/common/content_settings.mojom | 2 +
- .../common/content_settings_mojom_traits.cc | 4 +-
- .../common/content_settings_mojom_traits.h | 10 +
- .../core/common/content_settings_types.h | 3 +
- .../core/common/pref_names.cc | 3 +
- .../content_settings/core/common/pref_names.h | 2 +
- .../renderer/content_settings_agent_impl.cc | 89 ++++++++
- .../renderer/content_settings_agent_impl.h | 4 +
- .../WebLayerSiteSettingsDelegate.java | 3 +
- 35 files changed, 698 insertions(+), 15 deletions(-)
- create mode 100755 components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml
- create mode 100755 components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml
- create mode 100755 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java
- diff --git a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java
- --- a/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java
- +++ b/chrome/android/java/src/org/chromium/chrome/browser/site_settings/ChromeSiteSettingsDelegate.java
- @@ -43,6 +43,10 @@ import org.chromium.url.GURL;
-
- import java.util.Set;
-
- +import android.content.Intent;
- +import android.provider.Browser;
- +import android.net.Uri;
- +
- /**
- * A SiteSettingsDelegate instance that contains Chrome-specific Site Settings logic.
- */
- @@ -257,4 +261,16 @@ public class ChromeSiteSettingsDelegate implements SiteSettingsDelegate {
- mPrivacySandboxController.dismissSnackbar();
- }
- }
- +
- + // open wiki page for documentation about the timezone override feature
- + @Override
- + public void launchTimeZoneOverrideHelpAndFeedbackActivity(Activity currentActivity) {
- + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/bromite/bromite/wiki/TimezoneOverride"));
- + // Let Chromium know that this intent is from Chromium, so that it does not close the app when
- + // the user presses 'back' button.
- + intent.putExtra(Browser.EXTRA_APPLICATION_ID, currentActivity.getPackageName());
- + intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
- + intent.setPackage(currentActivity.getPackageName());
- + currentActivity.startActivity(intent);
- + }
- }
- diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/browser_ui/site_settings/android/BUILD.gn
- --- a/components/browser_ui/site_settings/android/BUILD.gn
- +++ b/components/browser_ui/site_settings/android/BUILD.gn
- @@ -66,6 +66,7 @@ android_library("java") {
- "java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java",
- "java/src/org/chromium/components/browser_ui/site_settings/WebsitePreference.java",
- "java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java",
- + "java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java"
- ]
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
- resources_package = "org.chromium.components.browser_ui.site_settings"
- @@ -162,6 +163,8 @@ android_resources("java_resources") {
- "java/res/xml/single_website_preferences.xml",
- "java/res/xml/site_settings_preferences.xml",
- "java/res/xml/website_preferences.xml",
- + "java/res/layout/timezoneoverride_site_settings_preference.xml",
- + "java/res/layout/time_zone_select_dialog.xml",
- ]
-
- deps = [
- diff --git a/components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml b/components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml
- new file mode 100755
- --- /dev/null
- +++ b/components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml
- @@ -0,0 +1,36 @@
- +<?xml version="1.0" encoding="utf-8"?>
- +<!--
- + This file is part of Bromite.
- +
- + Bromite is free software: you can redistribute it and/or modify
- + it under the terms of the GNU General Public License as published by
- + the Free Software Foundation, either version 3 of the License, or
- + (at your option) any later version.
- +
- + Bromite is distributed in the hope that it will be useful,
- + but WITHOUT ANY WARRANTY; without even the implied warranty of
- + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + GNU General Public License for more details.
- +
- + You should have received a copy of the GNU General Public License
- + along with Bromite. If not, see <https://www.gnu.org/licenses/>.
- +-->
- +
- +<!-- Layout used by the TimezoneOverrideSettingsPreference. -->
- +
- +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- + android:orientation="vertical"
- + style="@style/AlertDialogContent">
- +
- + <ListView
- + android:id="@+id/listView"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:layout_marginBottom="8dp"
- + android:layout_marginEnd="8dp"
- + android:layout_marginStart="8dp"
- + android:layout_marginTop="8dp"
- + android:choiceMode="singleChoice"
- + android:listSelector="#666666"/>
- +
- +</LinearLayout>
- \ No newline at end of file
- diff --git a/components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml b/components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml
- new file mode 100755
- --- /dev/null
- +++ b/components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml
- @@ -0,0 +1,68 @@
- +<!--
- + This file is part of Bromite.
- +
- + Bromite is free software: you can redistribute it and/or modify
- + it under the terms of the GNU General Public License as published by
- + the Free Software Foundation, either version 3 of the License, or
- + (at your option) any later version.
- +
- + Bromite is distributed in the hope that it will be useful,
- + but WITHOUT ANY WARRANTY; without even the implied warranty of
- + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + GNU General Public License for more details.
- +
- + You should have received a copy of the GNU General Public License
- + along with Bromite. If not, see <https://www.gnu.org/licenses/>.
- +-->
- +
- +<!-- Layout used by the TimezoneOverrideSettingsPreference. -->
- +
- +<LinearLayout
- + xmlns:android="http://schemas.android.com/apk/res/android"
- + xmlns:app="http://schemas.android.com/apk/res-auto"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:focusable="false"
- + android:orientation="vertical">
- +
- + <org.chromium.components.browser_ui.widget.RadioButtonWithDescriptionLayout
- + android:id="@+id/radio_button_layout"
- + android:layout_width="match_parent"
- + android:layout_height="match_parent">
- +
- + <org.chromium.components.browser_ui.widget.RadioButtonWithDescription
- + android:id="@+id/allowed"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- + app:primaryText="@string/website_settings_category_timezone_override_allowed" />
- +
- + <org.chromium.components.browser_ui.widget.RadioButtonWithDescription
- + android:id="@+id/blocked"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- + app:primaryText="@string/website_settings_category_timezone_override_random" />
- +
- + <org.chromium.components.browser_ui.widget.RadioButtonWithEditText
- + android:id="@+id/ask"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- + android:inputType="text"
- + android:hint="@string/website_settings_category_timezone_override_custom_hint"
- + app:descriptionText="@string/website_settings_category_timezone_override_custom" />
- +
- + </org.chromium.components.browser_ui.widget.RadioButtonWithDescriptionLayout>
- +
- + <org.chromium.ui.widget.ButtonCompat
- + android:id="@+id/select_button"
- + style="@style/TextButton"
- + android:layout_width="match_parent"
- + android:layout_height="wrap_content"
- + android:paddingBottom="16dp"
- + android:paddingTop="16dp"
- + android:text="@string/website_settings_select_button"
- + app:verticalInset="0dp" />
- +
- +</LinearLayout>
- diff --git a/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml b/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
- --- a/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
- +++ b/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
- @@ -41,6 +41,10 @@
- <org.chromium.components.browser_ui.settings.ChromeBasePreference
- android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
- android:key="javascript" />
- + <!-- Timezone Override -->
- + <org.chromium.components.browser_ui.settings.ChromeBasePreference
- + android:key="timezone_override"
- + android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings" />
- <!-- Popups -->
- <org.chromium.components.browser_ui.settings.ChromeBasePreference
- android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
- diff --git a/components/browser_ui/site_settings/android/java/res/xml/website_preferences.xml b/components/browser_ui/site_settings/android/java/res/xml/website_preferences.xml
- --- a/components/browser_ui/site_settings/android/java/res/xml/website_preferences.xml
- +++ b/components/browser_ui/site_settings/android/java/res/xml/website_preferences.xml
- @@ -13,6 +13,12 @@
- android:key="cookie_info_text"
- android:summary="@string/website_settings_cookie_info"/>
-
- + <!-- A text message describing timeoverride settings. -->
- + <org.chromium.components.browser_ui.settings.TextMessagePreference
- + android:key="timeoverride_info_text"
- + android:summary="@string/website_settings_timeoverride_info"/>
- +
- +
- <!-- A common binary toggle, only shown for specific categories that allow
- turning default values for that category on/off.-->
- <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
- @@ -26,6 +32,9 @@
- <!-- A four state toggle for cookie preferences, only shown for the Cookies category. -->
- <org.chromium.components.browser_ui.site_settings.FourStateCookieSettingsPreference
- android:key="four_state_cookie_toggle" />
- + <!-- A specific state toggle for time override preferences, only shown for the TimeOverride category. -->
- + <org.chromium.components.browser_ui.site_settings.TimezoneOverrideSiteSettingsPreference
- + android:key="timeoverride_state_toggle" />
-
- <!-- A checkbox for enabling a quiet ui for notification prompts. Only shown in the Notifications category. -->
- <org.chromium.components.browser_ui.settings.ChromeBaseCheckBoxPreference
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
- @@ -269,6 +269,12 @@ public class ContentSettingsResources {
- R.string.vr_permission_title, ContentSettingValues.ASK,
- ContentSettingValues.BLOCK, R.string.website_settings_category_vr_ask,
- R.string.website_settings_category_vr_blocked);
- +
- + case ContentSettingsType.TIMEZONE_OVERRIDE:
- + return new ResourceItem(R.drawable.web_asset, R.string.timezone_override_permission_title,
- + ContentSettingValues.ALLOW, ContentSettingValues.BLOCK,
- + R.string.website_settings_category_timezone_override_custom,
- + R.string.website_settings_category_timezone_override_random);
- }
- assert false; // NOTREACHED
- return null;
- @@ -421,6 +427,23 @@ public class ContentSettingsResources {
- }
- }
-
- + public static int getCategorySummary(int contentType, @Nullable @ContentSettingValues int value) {
- + if (contentType == ContentSettingsType.TIMEZONE_OVERRIDE) {
- + switch (value) {
- + case ContentSettingValues.ALLOW:
- + return R.string.website_settings_category_timezone_override_allowed;
- + case ContentSettingValues.ASK:
- + return R.string.website_settings_category_timezone_override_custom;
- + case ContentSettingValues.BLOCK:
- + return R.string.website_settings_category_timezone_override_random;
- + default:
- + return 0;
- + }
- + }
- + else
- + return getCategorySummary(value);
- + }
- +
- /**
- * Returns the string resource id for a content type to show with a permission category.
- * @param enabled Whether the content type is enabled.
- @@ -435,7 +458,10 @@ public class ContentSettingsResources {
- * with a particular website.
- * @param value The ContentSetting for which we want the resource.
- */
- - public static int getSiteSummary(@ContentSettingValues @Nullable Integer value) {
- + public static int getSiteSummary(int contentType, @ContentSettingValues @Nullable Integer value) {
- + if (contentType == ContentSettingsType.TIMEZONE_OVERRIDE)
- + return getCategorySummary(contentType, value);
- +
- switch (value) {
- case ContentSettingValues.ALLOW:
- return R.string.website_settings_permissions_allow;
- @@ -541,6 +567,13 @@ public class ContentSettingsResources {
- return descriptionIDs;
- }
- }
- + else if (contentType == ContentSettingsType.TIMEZONE_OVERRIDE) {
- + int[] descriptionIDs = {
- + R.string.website_settings_category_timezone_override_allowed, // ALLOWED
- + R.string.website_settings_category_timezone_override_custom, // ASK
- + R.string.website_settings_category_timezone_override_random}; // BLOCKED
- + return descriptionIDs;
- + }
-
- assert false;
- return null;
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
- @@ -62,6 +62,10 @@ import org.chromium.ui.widget.Toast;
-
- import java.lang.annotation.Retention;
- import java.lang.annotation.RetentionPolicy;
- +import android.app.Activity;
- +import android.content.Intent;
- +import org.chromium.components.browser_ui.site_settings.TimezoneOverrideSiteSettingsPreference;
- +
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Collections;
- @@ -141,6 +145,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- public static final String BINARY_TOGGLE_KEY = "binary_toggle";
- public static final String TRI_STATE_TOGGLE_KEY = "tri_state_toggle";
- public static final String FOUR_STATE_COOKIE_TOGGLE_KEY = "four_state_cookie_toggle";
- + public static final String TIMEOVERRIDE_STATE_TOGGLE_KEY = "timeoverride_state_toggle";
-
- // Keys for category-specific preferences (toggle, link, button etc.), dynamically shown.
- public static final String NOTIFICATIONS_VIBRATE_TOGGLE_KEY = "notifications_vibrate";
- @@ -148,6 +153,7 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- public static final String EXPLAIN_PROTECTED_MEDIA_KEY = "protected_content_learn_more";
- public static final String ADD_EXCEPTION_KEY = "add_exception";
- public static final String COOKIE_INFO_TEXT_KEY = "cookie_info_text";
- + public static final String TIMEOVERRIDE_INFO_TEXT = "timeoverride_info_text";
-
- // Keys for Allowed/Blocked preference groups/headers.
- private static final String ALLOWED_GROUP = "allowed_group";
- @@ -216,7 +222,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- Integer contentSetting = website.site().getContentSetting(
- browserContextHandle, SiteSettingsCategory.contentSettingsType(i));
- if (contentSetting != null) {
- - return ContentSettingValues.BLOCK == contentSetting;
- + if (i == SiteSettingsCategory.Type.TIMEZONE_OVERRIDE)
- + return ContentSettingValues.ALLOW != contentSetting;
- + else
- + return ContentSettingValues.BLOCK == contentSetting;
- }
- }
- return false;
- @@ -387,7 +396,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- if (queryHasChanged) getInfoForOrigins();
- });
-
- - if (getSiteSettingsDelegate().isHelpAndFeedbackEnabled()) {
- + if (getSiteSettingsDelegate().isHelpAndFeedbackEnabled() ||
- + mCategory.showSites(SiteSettingsCategory.Type.TIMEZONE_OVERRIDE) ) {
- MenuItem help = menu.add(
- Menu.NONE, R.id.menu_id_site_settings_help, Menu.NONE, R.string.menu_help);
- help.setIcon(VectorDrawableCompat.create(
- @@ -398,7 +408,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.menu_id_site_settings_help) {
- - if (mCategory.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) {
- + if (mCategory.showSites(SiteSettingsCategory.Type.TIMEZONE_OVERRIDE)) {
- + getSiteSettingsDelegate()
- + .launchTimeZoneOverrideHelpAndFeedbackActivity(getActivity());
- + } else if (mCategory.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) {
- getSiteSettingsDelegate().launchProtectedContentHelpAndFeedbackActivity(
- getActivity());
- } else {
- @@ -492,6 +505,12 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- WebsitePreferenceBridge.setDefaultContentSetting(
- browserContextHandle, mCategory.getContentSettingsType(), setting);
- getInfoForOrigins();
- + } else if (TIMEOVERRIDE_STATE_TOGGLE_KEY.equals(preference.getKey())) {
- + @ContentSettingValues
- + int setting = (int) newValue;
- + WebsitePreferenceBridge.setDefaultContentSetting(
- + browserContextHandle, ContentSettingsType.TIMEZONE_OVERRIDE, setting);
- + getInfoForOrigins();
- } else if (FOUR_STATE_COOKIE_TOGGLE_KEY.equals(preference.getKey())) {
- setCookieSettingsPreference((CookieSettingsState) newValue);
- getInfoForOrigins();
- @@ -589,6 +608,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- assert WebsitePreferenceBridge.isCategoryEnabled(
- browserContextHandle, ContentSettingsType.AUTO_DARK_WEB_CONTENT);
- resource = R.string.website_settings_add_site_description_auto_dark_block;
- + } else if (mCategory.showSites(SiteSettingsCategory.Type.TIMEZONE_OVERRIDE)) {
- + resource = R.string.website_settings_category_timezone_override_allowed;
- }
- assert resource > 0;
- return getString(resource);
- @@ -629,6 +650,13 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- if (mCategory.showSites(SiteSettingsCategory.Type.COOKIES) && mRequiresFourStateSetting) {
- setting = cookieSettingsExceptionShouldBlock() ? ContentSettingValues.BLOCK
- : ContentSettingValues.ALLOW;
- + } else if (mRequiresTriStateSetting) {
- + setting = WebsitePreferenceBridge.getDefaultContentSetting(browserContextHandle, mCategory.getContentSettingsType());
- + if (setting == ContentSettingValues.ALLOW) {
- + setting = ContentSettingValues.BLOCK;
- + } else {
- + setting = ContentSettingValues.ALLOW;
- + }
- } else {
- setting = (WebsitePreferenceBridge.isCategoryEnabled(
- browserContextHandle, mCategory.getContentSettingsType()))
- @@ -685,6 +713,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- && !WebsitePreferenceBridge.isCategoryEnabled(
- browserContextHandle, ContentSettingsType.AUTOMATIC_DOWNLOADS)) {
- allowSpecifyingExceptions = true;
- + } else if (mCategory.showSites(SiteSettingsCategory.Type.TIMEZONE_OVERRIDE)) {
- + allowSpecifyingExceptions = true;
- }
- if (allowSpecifyingExceptions) {
- getPreferenceScreen().addPreference(new AddExceptionPreference(getStyledContext(),
- @@ -856,7 +886,14 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- TriStateSiteSettingsPreference triStateToggle =
- (TriStateSiteSettingsPreference) getPreferenceScreen().findPreference(
- TRI_STATE_TOGGLE_KEY);
- - return (triStateToggle.getCheckedSetting() == ContentSettingValues.BLOCK);
- + if (triStateToggle != null)
- + return (triStateToggle.getCheckedSetting() == ContentSettingValues.BLOCK);
- +
- + TimezoneOverrideSiteSettingsPreference timeOverrideStatePreference =
- + (TimezoneOverrideSiteSettingsPreference) getPreferenceScreen().findPreference(
- + TIMEOVERRIDE_STATE_TOGGLE_KEY);
- + if (timeOverrideStatePreference != null)
- + return (timeOverrideStatePreference.getCheckedSetting() != ContentSettingValues.ALLOW);
- } else if (mRequiresFourStateSetting) {
- FourStateCookieSettingsPreference fourStateCookieToggle =
- (FourStateCookieSettingsPreference) getPreferenceScreen().findPreference(
- @@ -885,6 +922,9 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- (FourStateCookieSettingsPreference) screen.findPreference(
- FOUR_STATE_COOKIE_TOGGLE_KEY);
- // TODO(crbug.com/1104836): Remove the old third-party cookie blocking UI
- + TimezoneOverrideSiteSettingsPreference timeOverrideStatePreference =
- + (TimezoneOverrideSiteSettingsPreference) screen.findPreference(
- + TIMEOVERRIDE_STATE_TOGGLE_KEY);
- Preference notificationsVibrate = screen.findPreference(NOTIFICATIONS_VIBRATE_TOGGLE_KEY);
- Preference notificationsQuietUi = screen.findPreference(NOTIFICATIONS_QUIET_UI_TOGGLE_KEY);
- Preference explainProtectedMediaKey = screen.findPreference(EXPLAIN_PROTECTED_MEDIA_KEY);
- @@ -896,20 +936,32 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- if (mRequiresTriStateSetting) {
- screen.removePreference(binaryToggle);
- screen.removePreference(fourStateCookieToggle);
- - configureTriStateToggle(triStateToggle, contentType);
- + if (mCategory.showSites(SiteSettingsCategory.Type.TIMEZONE_OVERRIDE)) {
- + screen.removePreference(triStateToggle);
- + configureTimeOverrideStateToggle(timeOverrideStatePreference);
- + }
- + else {
- + screen.removePreference(timeOverrideStatePreference);
- + configureTriStateToggle(triStateToggle, contentType);
- + }
- } else if (mRequiresFourStateSetting) {
- screen.removePreference(binaryToggle);
- screen.removePreference(triStateToggle);
- + screen.removePreference(timeOverrideStatePreference);
- configureFourStateCookieToggle(fourStateCookieToggle);
- } else {
- screen.removePreference(triStateToggle);
- screen.removePreference(fourStateCookieToggle);
- + screen.removePreference(timeOverrideStatePreference);
- configureBinaryToggle(binaryToggle, contentType);
- }
-
- if (!mCategory.showSites(SiteSettingsCategory.Type.COOKIES)) {
- screen.removePreference(screen.findPreference(COOKIE_INFO_TEXT_KEY));
- }
- + if (!(mCategory.showSites(SiteSettingsCategory.Type.TIMEZONE_OVERRIDE))) {
- + screen.removePreference(screen.findPreference(TIMEOVERRIDE_INFO_TEXT));
- + }
-
- if (permissionBlockedByOs) {
- maybeShowOsWarning(screen);
- @@ -1025,6 +1077,15 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
- triStateToggle.initialize(setting, descriptionIds);
- }
-
- + private void configureTimeOverrideStateToggle(
- + TimezoneOverrideSiteSettingsPreference timeOverrideStateToggle) {
- + timeOverrideStateToggle.setOnPreferenceChangeListener(this);
- + @ContentSettingValues
- + int setting = WebsitePreferenceBridge.getDefaultContentSetting(
- + getSiteSettingsDelegate().getBrowserContextHandle(), ContentSettingsType.TIMEZONE_OVERRIDE);
- + timeOverrideStateToggle.initialize(setting, getSiteSettingsDelegate().getBrowserContextHandle());
- + }
- +
- private void configureBinaryToggle(ChromeSwitchPreference binaryToggle, int contentType) {
- binaryToggle.setOnPreferenceChangeListener(this);
- binaryToggle.setTitle(ContentSettingsResources.getTitle(contentType));
- @@ -1108,9 +1169,11 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
-
- CharSequence[] descriptions = new String[2];
- descriptions[0] =
- - getString(ContentSettingsResources.getSiteSummary(ContentSettingValues.ALLOW));
- + getString(ContentSettingsResources.getSiteSummary(contentSettingsType,
- + ContentSettingValues.ALLOW));
- descriptions[1] =
- - getString(ContentSettingsResources.getSiteSummary(ContentSettingValues.BLOCK));
- + getString(ContentSettingsResources.getSiteSummary(contentSettingsType,
- + ContentSettingValues.BLOCK));
-
- return new AlertDialog.Builder(getContext(), R.style.Theme_Chromium_AlertDialog)
- .setPositiveButton(R.string.cancel, null)
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
- @@ -132,6 +132,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- return "popup_permission_list";
- case ContentSettingsType.SOUND:
- return "sound_permission_list";
- + case ContentSettingsType.TIMEZONE_OVERRIDE:
- + return "timezone_override_permission_list";
- case ContentSettingsType.AR:
- return "ar_permission_list";
- case ContentSettingsType.MEDIASTREAM_CAMERA:
- @@ -884,11 +886,13 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- if (value == null) return;
- setUpPreferenceCommon(preference, value);
-
- + int content_type = getContentSettingsTypeFromPreferenceKey(preference.getKey());
- +
- ChromeSwitchPreference switchPreference = (ChromeSwitchPreference) preference;
- switchPreference.setChecked(value == ContentSettingValues.ALLOW);
- switchPreference.setSummary(isEmbargoed
- ? getString(R.string.automatically_blocked)
- - : getString(ContentSettingsResources.getCategorySummary(value)));
- + : getString(ContentSettingsResources.getCategorySummary(content_type, value)));
- switchPreference.setOnPreferenceChangeListener(this);
- @ContentSettingsType
- int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey());
- @@ -1080,7 +1084,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- }
-
- mSite.setContentSetting(browserContextHandle, type, permission);
- - preference.setSummary(getString(ContentSettingsResources.getCategorySummary(permission)));
- + preference.setSummary(getString(ContentSettingsResources.getCategorySummary(type, permission)));
- preference.setIcon(getContentSettingsIcon(type, permission));
-
- if (mWebsiteSettingsObserver != null) {
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettings.java
- @@ -117,7 +117,7 @@ public class SiteSettings
- } else if (Type.AUTO_DARK_WEB_CONTENT == prefCategory) {
- p.setSummary(ContentSettingsResources.getAutoDarkWebContentListSummary(checked));
- } else if (requiresTriStateSetting) {
- - p.setSummary(ContentSettingsResources.getCategorySummary(setting));
- + p.setSummary(ContentSettingsResources.getCategorySummary(contentType, setting));
- } else {
- p.setSummary(ContentSettingsResources.getCategorySummary(contentType, checked));
- }
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
- @@ -43,7 +43,7 @@ public class SiteSettingsCategory {
- Type.JAVASCRIPT, Type.MICROPHONE, Type.NFC, Type.NOTIFICATIONS, Type.POPUPS,
- Type.PROTECTED_MEDIA, Type.SENSORS, Type.SOUND, Type.USB, Type.VIRTUAL_REALITY,
- Type.USE_STORAGE, Type.AUTO_DARK_WEB_CONTENT, Type.REQUEST_DESKTOP_SITE,
- - Type.FEDERATED_IDENTITY_API})
- + Type.FEDERATED_IDENTITY_API, Type.TIMEZONE_OVERRIDE})
- @Retention(RetentionPolicy.SOURCE)
- public @interface Type {
- // All updates here must also be reflected in {@link #preferenceKey(int)
- @@ -74,10 +74,11 @@ public class SiteSettingsCategory {
- int AUTO_DARK_WEB_CONTENT = 23;
- int REQUEST_DESKTOP_SITE = 24;
- int FEDERATED_IDENTITY_API = 25;
- + int TIMEZONE_OVERRIDE = 26;
- /**
- * Number of handled categories used for calculating array sizes.
- */
- - int NUM_ENTRIES = 26;
- + int NUM_ENTRIES = 27;
- }
-
- private final BrowserContextHandle mBrowserContextHandle;
- @@ -202,6 +203,8 @@ public class SiteSettingsCategory {
- return ContentSettingsType.USB_GUARD;
- case Type.VIRTUAL_REALITY:
- return ContentSettingsType.VR;
- + case Type.TIMEZONE_OVERRIDE:
- + return ContentSettingsType.TIMEZONE_OVERRIDE;
- // case Type.ALL_SITES
- // case Type.USE_STORAGE
- default:
- @@ -282,6 +285,8 @@ public class SiteSettingsCategory {
- return "use_storage";
- case Type.VIRTUAL_REALITY:
- return "virtual_reality";
- + case Type.TIMEZONE_OVERRIDE:
- + return "timezone_override";
- default:
- assert false;
- return "";
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsDelegate.java
- @@ -124,4 +124,6 @@ public interface SiteSettingsDelegate {
- * Dismisses the Privacy Sandbox snackbar, if active.
- */
- void dismissPrivacySandboxSnackbar();
- +
- + void launchTimeZoneOverrideHelpAndFeedbackActivity(Activity currentActivity);
- }
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java
- new file mode 100755
- --- /dev/null
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java
- @@ -0,0 +1,193 @@
- +/*
- + This file is part of Bromite.
- +
- + Bromite is free software: you can redistribute it and/or modify
- + it under the terms of the GNU General Public License as published by
- + the Free Software Foundation, either version 3 of the License, or
- + (at your option) any later version.
- +
- + Bromite is distributed in the hope that it will be useful,
- + but WITHOUT ANY WARRANTY; without even the implied warranty of
- + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + GNU General Public License for more details.
- +
- + You should have received a copy of the GNU General Public License
- + along with Bromite. If not, see <https://www.gnu.org/licenses/>.
- +*/
- +
- +package org.chromium.components.browser_ui.site_settings;
- +
- +import org.chromium.base.Log;
- +import android.content.Context;
- +import android.content.Intent;
- +import android.content.DialogInterface;
- +import android.view.View;
- +import android.widget.RadioGroup;
- +import android.widget.Button;
- +import android.widget.TextView;
- +import android.util.AttributeSet;
- +import android.widget.ArrayAdapter;
- +import android.widget.ListView;
- +import android.view.LayoutInflater;
- +import android.widget.AdapterView;
- +import android.graphics.Color;
- +
- +import androidx.preference.Preference;
- +import androidx.preference.PreferenceViewHolder;
- +import androidx.appcompat.app.AlertDialog;
- +
- +import org.chromium.content_public.browser.BrowserContextHandle;
- +import org.chromium.components.content_settings.ContentSettingValues;
- +import org.chromium.components.browser_ui.site_settings.WebsitePreferenceBridge;
- +import org.chromium.components.browser_ui.widget.RadioButtonWithDescription;
- +import org.chromium.components.browser_ui.widget.RadioButtonWithEditText;
- +import org.chromium.components.browser_ui.widget.TintedDrawable;
- +
- +import java.util.ArrayList;
- +import java.util.Arrays;
- +import java.util.TimeZone;
- +
- +/**
- + * TimezoneOverride Preference for SiteSettings.
- + */
- +public class TimezoneOverrideSiteSettingsPreference
- + extends Preference implements RadioGroup.OnCheckedChangeListener,
- + RadioButtonWithEditText.OnTextChangeListener {
- + private @ContentSettingValues int mSetting = ContentSettingValues.DEFAULT;
- + private RadioButtonWithDescription mAllowed;
- + private RadioButtonWithEditText mAsk;
- + private RadioButtonWithDescription mBlocked;
- + private RadioGroup mRadioGroup;
- + private TextView mSelectButton;
- +
- + private String currentSelected;
- +
- + private BrowserContextHandle mBrowserContextHandle;
- +
- + public TimezoneOverrideSiteSettingsPreference(Context context, AttributeSet attrs) {
- + super(context, attrs);
- +
- + setLayoutResource(R.layout.timezoneoverride_site_settings_preference);
- + setSelectable(false);
- + }
- +
- + public void initialize(@ContentSettingValues int setting, BrowserContextHandle browserContextHandle) {
- + mSetting = setting;
- + mBrowserContextHandle = browserContextHandle;
- + }
- +
- + public @ContentSettingValues int getCheckedSetting() {
- + return mSetting;
- + }
- +
- + @Override
- + public void onCheckedChanged(RadioGroup group, int checkedId) {
- + if (mAllowed.isChecked()) {
- + mSetting = ContentSettingValues.ALLOW;
- + } else if (mAsk.isChecked()) {
- + mSetting = ContentSettingValues.ASK;
- + } else if (mBlocked.isChecked()) {
- + mSetting = ContentSettingValues.BLOCK;
- + }
- +
- + callChangeListener(mSetting);
- + }
- +
- + @Override
- + public void onBindViewHolder(PreferenceViewHolder holder) {
- + super.onBindViewHolder(holder);
- +
- + mAllowed = (RadioButtonWithDescription) holder.findViewById(R.id.allowed);
- + mAsk = (RadioButtonWithEditText) holder.findViewById(R.id.ask);
- + mBlocked = (RadioButtonWithDescription) holder.findViewById(R.id.blocked);
- + mRadioGroup = (RadioGroup) holder.findViewById(R.id.radio_button_layout);
- + mRadioGroup.setOnCheckedChangeListener(this);
- +
- + mAsk.setPrimaryText(WebsitePreferenceBridge.getCustomTimezone(mBrowserContextHandle));
- + mAsk.addTextChangeListener(this);
- +
- + ListView listView = (ListView)holder.findViewById(R.id.listView);
- +
- + mSelectButton = (TextView) holder.findViewById(R.id.select_button);
- + mSelectButton.setOnClickListener(view -> {
- + showSelectTimeZoneDialog();
- + });
- +
- + RadioButtonWithDescription radioButton = findRadioButton(mSetting);
- + if (radioButton != null) radioButton.setChecked(true);
- + }
- +
- + private RadioButtonWithDescription findRadioButton(@ContentSettingValues int setting) {
- + if (setting == ContentSettingValues.ALLOW) {
- + return mAllowed;
- + } else if (setting == ContentSettingValues.ASK) {
- + return mAsk;
- + } else if (setting == ContentSettingValues.BLOCK) {
- + return mBlocked;
- + } else {
- + return null;
- + }
- + }
- +
- + public void onTextChanged(CharSequence newText) {
- + WebsitePreferenceBridge.setCustomTimezone(mBrowserContextHandle, newText.toString());
- + }
- +
- + private void showSelectTimeZoneDialog() {
- + LayoutInflater inflater =
- + (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- + View view = inflater.inflate(R.layout.time_zone_select_dialog, null);
- +
- + ListView listView = view.findViewById(R.id.listView);
- + ArrayList<String> timezones = new ArrayList<>(Arrays.asList(TimeZone.getAvailableIDs()));
- + ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, timezones);
- + listView.setAdapter(adapter);
- +
- + currentSelected = String.valueOf(mAsk.getPrimaryText());
- + listView.post(new Runnable()
- + {
- + public void run()
- + {
- + for (int j = 0; j < timezones.size(); j++) {
- + if (currentSelected.equals(timezones.get(j))) {
- + listView.requestFocusFromTouch();
- + listView.setSelection(j);
- + adapter.notifyDataSetChanged();
- + break;
- + }
- + }
- + }
- + });
- +
- + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- + @Override
- + public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- + currentSelected = timezones.get(i);
- + listView.setSelected(true);
- + }
- + });
- +
- + DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
- + @Override
- + public void onClick(DialogInterface dialog, int button) {
- + if (button == AlertDialog.BUTTON_POSITIVE) {
- + mAsk.setPrimaryText(currentSelected);
- + } else {
- + dialog.dismiss();
- + }
- + }
- + };
- +
- + AlertDialog.Builder alert =
- + new AlertDialog.Builder(getContext(), R.style.Theme_Chromium_AlertDialog);
- + AlertDialog alertDialog =
- + alert.setTitle(R.string.website_settings_select_dialog_title)
- + .setView(view)
- + .setPositiveButton(
- + R.string.website_settings_select_dialog_button, onClickListener)
- + .setNegativeButton(R.string.cancel, onClickListener)
- + .create();
- + alertDialog.getDelegate().setHandleNativeActionModesEnabled(false);
- + alertDialog.show();
- + }
- +}
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
- @@ -229,6 +229,16 @@ public final class Website implements Serializable {
- } else {
- RecordUserAction.record("SoundContentSetting.UnmuteBy.SiteSettings");
- }
- + } else if (type == ContentSettingsType.TIMEZONE_OVERRIDE) {
- + // It is possible to set the permission without having an existing exception,
- + // because we can show the ALLOW state even when this permission is set to the
- + // default. In that case, just set an exception now to ALLOW to enable changing the
- + // permission.
- + if (exception == null) {
- + exception = new ContentSettingException(
- + ContentSettingsType.TIMEZONE_OVERRIDE, getAddress().getHost(), value, "");
- + setContentSettingException(type, exception);
- + }
- }
- // We want to call setContentSetting even after explicitly setting
- // mContentSettingException above because this will trigger the actual change
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
- @@ -68,6 +68,7 @@ public class WebsitePermissionsFetcher {
- case ContentSettingsType.POPUPS:
- case ContentSettingsType.REQUEST_DESKTOP_SITE:
- case ContentSettingsType.SOUND:
- + case ContentSettingsType.TIMEZONE_OVERRIDE:
- return WebsitePermissionsType.CONTENT_SETTING_EXCEPTION;
- case ContentSettingsType.AR:
- case ContentSettingsType.CLIPBOARD_READ_WRITE:
- @@ -148,6 +149,8 @@ public class WebsitePermissionsFetcher {
- for (@ContentSettingsType int type = 0; type < ContentSettingsType.NUM_TYPES; type++) {
- addFetcherForContentSettingsType(queue, type);
- }
- + queue.add(new ExceptionInfoFetcher(ContentSettingsType.TIMEZONE_OVERRIDE));
- +
- queue.add(new PermissionsAvailableCallbackRunner(callback));
- queue.next();
- }
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
- @@ -221,6 +221,8 @@ public class WebsitePreferenceBridge {
- switch (contentSettingsType) {
- case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER:
- return true;
- + case ContentSettingsType.TIMEZONE_OVERRIDE:
- + return true;
- default:
- return false;
- }
- @@ -351,6 +353,14 @@ public class WebsitePreferenceBridge {
- contentSettingType, primaryPattern, secondaryPattern, setting);
- }
-
- + public static String getCustomTimezone(BrowserContextHandle browserContextHandle) {
- + return WebsitePreferenceBridgeJni.get().getCustomTimezone(browserContextHandle);
- + }
- +
- + public static void setCustomTimezone(BrowserContextHandle browserContextHandle, String timezone) {
- + WebsitePreferenceBridgeJni.get().setCustomTimezone(browserContextHandle, timezone);
- + }
- +
- @NativeMethods
- public interface Natives {
- boolean isNotificationEmbargoedForOrigin(
- @@ -412,5 +422,7 @@ public class WebsitePreferenceBridge {
- boolean isContentSettingManagedByCustodian(
- BrowserContextHandle browserContextHandle, int contentSettingType);
- boolean getLocationAllowedByPolicy(BrowserContextHandle browserContextHandle);
- + String getCustomTimezone(BrowserContextHandle browserContextHandle);
- + void setCustomTimezone(BrowserContextHandle browserContextHandle, String timezone);
- }
- }
- diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc
- --- a/components/browser_ui/site_settings/android/website_preference_bridge.cc
- +++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc
- @@ -900,3 +900,19 @@ static jboolean JNI_WebsitePreferenceBridge_GetLocationAllowedByPolicy(
- ->GetDefaultContentSetting(ContentSettingsType::GEOLOCATION,
- nullptr) == CONTENT_SETTING_ALLOW;
- }
- +
- +static void JNI_WebsitePreferenceBridge_SetCustomTimezone(
- + JNIEnv* env,
- + const JavaParamRef<jobject>& jbrowser_context_handle,
- + const JavaParamRef<jstring>& timezone) {
- + std::string new_timezone = ConvertJavaStringToUTF8(env, timezone);
- + GetHostContentSettingsMap(jbrowser_context_handle)->SetTimezoneOverrideValue(new_timezone);
- +}
- +
- +static base::android::ScopedJavaLocalRef<jstring> JNI_WebsitePreferenceBridge_GetCustomTimezone(
- + JNIEnv* env,
- + const JavaParamRef<jobject>& jbrowser_context_handle) {
- + std::string timezone;
- + GetHostContentSettingsMap(jbrowser_context_handle)->GetTimezoneOverrideValue(timezone);
- + return ConvertUTF8ToJavaString(env, timezone);
- +}
- diff --git a/components/browser_ui/strings/android/site_settings.grdp b/components/browser_ui/strings/android/site_settings.grdp
- --- a/components/browser_ui/strings/android/site_settings.grdp
- +++ b/components/browser_ui/strings/android/site_settings.grdp
- @@ -75,6 +75,9 @@
- <message name="IDS_AUTO_DARK_WEB_CONTENT_TITLE" desc="Title of the permission auto darken web content [CHAR_LIMIT=32]">
- Dark theme for sites
- </message>
- + <message name="IDS_TIMEZONE_OVERRIDE_PERMISSION_TITLE" desc="Title of the permission to use TimeZone Override [CHAR-LIMIT=32]">
- + Timezone override
- + </message>
- <message name="IDS_DESKTOP_SITE_TITLE" desc="Title of the permission to request the desktop view of a site by default [CHAR_LIMIT=32]">
- Desktop site
- </message>
- @@ -497,6 +500,38 @@
- Block sites from playing protected content
- </message>
-
- + <!-- Timezone override -->
- + <message name="IDS_WEBSITE_SETTINGS_TIMEOVERRIDE_INFO" desc="Primary text explaining the timezone override feature.">
- + Override timezone with a custom or random one, or use the system timezone
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_ALLOWED_TEXT" desc="Primary text explaining that sites are allowed to access the system timezone.">
- + None (use system timezone)
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_RANDOM_TEXT" desc="Primary text for random timezone override.">
- + Random
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_ALLOWED" desc="Summary text explaining that sites are allowed to access the system timezone.">
- + System timezone
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_CUSTOM" desc="Summary text explaining that sites use custom timezone.">
- + Custom timezone
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_CUSTOM_HINT" desc="Hint text for edit custom timezone.">
- + Specify a custom timezone (default UTC)
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_CATEGORY_TIMEZONE_OVERRIDE_RANDOM" desc="Summary text for random timezone override.">
- + Random (for each page)
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_SELECT_BUTTON" desc="Primary button text for choosing a timezone from a list.">
- + Choose Timezone...
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_SELECT_DIALOG_TITLE" desc="Text of the dialog to choose a timezone.">
- + Choose Timezone
- + </message>
- + <message name="IDS_WEBSITE_SETTINGS_SELECT_DIALOG_BUTTON" desc="Primary button text in the dialog used to choose the custom timezone.">
- + Select
- + </message>
- +
- <!-- Sound -->
-
- <message name="IDS_WEBSITE_SETTINGS_CATEGORY_SOUND_ALLOWED" desc="Summary text explaining that sites are allowed to play sound and that it is the recommended setting.">
- diff --git a/components/content_settings/core/browser/content_settings_pref_provider.cc b/components/content_settings/core/browser/content_settings_pref_provider.cc
- --- a/components/content_settings/core/browser/content_settings_pref_provider.cc
- +++ b/components/content_settings/core/browser/content_settings_pref_provider.cc
- @@ -84,6 +84,8 @@ void PrefProvider::RegisterProfilePrefs(
- info->GetPrefRegistrationFlags());
- }
-
- + registry->RegisterStringPref(prefs::kContentSettingsCustomTimezone, std::string());
- +
- // Obsolete prefs ----------------------------------------------------------
-
- // These prefs have been removed, but need to be registered so they can
- @@ -169,6 +171,10 @@ PrefProvider::PrefProvider(PrefService* prefs,
- event_args->set_number_of_exceptions(
- num_exceptions); // PrefProvider::PrefProvider.
- });
- +
- + custom_timezone_ =
- + prefs_->GetString(
- + prefs::kContentSettingsCustomTimezone);
- }
-
- PrefProvider::~PrefProvider() {
- @@ -299,4 +305,14 @@ void PrefProvider::SetClockForTesting(base::Clock* clock) {
- clock_ = clock;
- }
-
- +void PrefProvider::GetPrefTimezoneOverrideValue(std::string& timezone) const {
- + timezone = custom_timezone_;
- +}
- +
- +void PrefProvider::SetPrefTimezoneOverrideValue(const std::string& timezone) {
- + prefs_->SetString(
- + prefs::kContentSettingsCustomTimezone, timezone);
- + custom_timezone_ = timezone;
- +}
- +
- } // namespace content_settings
- diff --git a/components/content_settings/core/browser/content_settings_pref_provider.h b/components/content_settings/core/browser/content_settings_pref_provider.h
- --- a/components/content_settings/core/browser/content_settings_pref_provider.h
- +++ b/components/content_settings/core/browser/content_settings_pref_provider.h
- @@ -67,6 +67,9 @@ class PrefProvider : public UserModifiableProvider {
-
- ContentSettingsPref* GetPref(ContentSettingsType type) const;
-
- + void GetPrefTimezoneOverrideValue(std::string& timezone) const;
- + void SetPrefTimezoneOverrideValue(const std::string& timezone);
- +
- private:
- friend class DeadlockCheckerObserver; // For testing.
-
- @@ -99,6 +102,7 @@ class PrefProvider : public UserModifiableProvider {
- base::ThreadChecker thread_checker_;
-
- raw_ptr<base::Clock> clock_;
- + std::string custom_timezone_;
- };
-
- } // namespace content_settings
- diff --git a/components/content_settings/core/browser/content_settings_registry.cc b/components/content_settings/core/browser/content_settings_registry.cc
- --- a/components/content_settings/core/browser/content_settings_registry.cc
- +++ b/components/content_settings/core/browser/content_settings_registry.cc
- @@ -645,6 +645,18 @@ void ContentSettingsRegistry::Init() {
- ContentSettingsInfo::PERSISTENT,
- ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS);
-
- + Register(ContentSettingsType::TIMEZONE_OVERRIDE, "timezone-override", CONTENT_SETTING_ALLOW,
- + WebsiteSettingsInfo::SYNCABLE,
- + AllowlistedSchemes(kChromeUIScheme, kChromeDevToolsScheme),
- + ValidSettings(CONTENT_SETTING_ALLOW, // use system time
- + CONTENT_SETTING_ASK, // custom timezone, default UTC
- + CONTENT_SETTING_BLOCK), // random
- + WebsiteSettingsInfo::SINGLE_ORIGIN_WITH_EMBEDDED_EXCEPTIONS_SCOPE,
- + WebsiteSettingsRegistry::PLATFORM_ANDROID,
- + ContentSettingsInfo::INHERIT_IN_INCOGNITO,
- + ContentSettingsInfo::PERSISTENT,
- + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS);
- +
- Register(ContentSettingsType::FEDERATED_IDENTITY_API, "webid-api",
- CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::UNSYNCABLE,
- AllowlistedSchemes(),
- diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc
- --- a/components/content_settings/core/browser/content_settings_utils.cc
- +++ b/components/content_settings/core/browser/content_settings_utils.cc
- @@ -150,6 +150,13 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map,
- &(rules->script_rules));
- map->GetSettingsForOneType(ContentSettingsType::POPUPS,
- &(rules->popup_redirect_rules));
- +
- + // pass custom timezone rules and value to the render process
- + map->GetSettingsForOneType(ContentSettingsType::TIMEZONE_OVERRIDE,
- + &(rules->timezone_override_rules));
- + std::string timezone;
- + map->GetTimezoneOverrideValue(timezone);
- + rules->timezone_override_value = timezone;
- }
-
- bool IsMorePermissive(ContentSetting a, ContentSetting b) {
- diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc
- --- a/components/content_settings/core/browser/host_content_settings_map.cc
- +++ b/components/content_settings/core/browser/host_content_settings_map.cc
- @@ -599,6 +599,14 @@ void HostContentSettingsMap::SetClockForTesting(base::Clock* clock) {
- provider->SetClockForTesting(clock);
- }
-
- +void HostContentSettingsMap::GetTimezoneOverrideValue(std::string& timezone) const {
- + GetPrefProvider()->GetPrefTimezoneOverrideValue(timezone);
- +}
- +
- +void HostContentSettingsMap::SetTimezoneOverrideValue(const std::string& timezone) {
- + GetPrefProvider()->SetPrefTimezoneOverrideValue(timezone);
- +}
- +
- void HostContentSettingsMap::RecordExceptionMetrics() {
- auto* content_setting_registry =
- content_settings::ContentSettingsRegistry::GetInstance();
- diff --git a/components/content_settings/core/browser/host_content_settings_map.h b/components/content_settings/core/browser/host_content_settings_map.h
- --- a/components/content_settings/core/browser/host_content_settings_map.h
- +++ b/components/content_settings/core/browser/host_content_settings_map.h
- @@ -334,6 +334,9 @@ class HostContentSettingsMap : public content_settings::Observer,
- allow_invalid_secondary_pattern_for_testing_ = allow;
- }
-
- + void GetTimezoneOverrideValue(std::string& timezone) const;
- + void SetTimezoneOverrideValue(const std::string& timezone);
- +
- private:
- friend class base::RefCountedThreadSafe<HostContentSettingsMap>;
- friend class content_settings::TestUtils;
- diff --git a/components/content_settings/core/common/content_settings.cc b/components/content_settings/core/common/content_settings.cc
- --- a/components/content_settings/core/common/content_settings.cc
- +++ b/components/content_settings/core/common/content_settings.cc
- @@ -190,7 +190,8 @@ bool RendererContentSettingRules::IsRendererContentSetting(
- content_type == ContentSettingsType::CLIENT_HINTS ||
- content_type == ContentSettingsType::POPUPS ||
- content_type == ContentSettingsType::MIXEDSCRIPT ||
- - content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT;
- + content_type == ContentSettingsType::AUTO_DARK_WEB_CONTENT ||
- + content_type == ContentSettingsType::TIMEZONE_OVERRIDE;
- }
-
- RendererContentSettingRules::RendererContentSettingRules() {}
- diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h
- --- a/components/content_settings/core/common/content_settings.h
- +++ b/components/content_settings/core/common/content_settings.h
- @@ -80,6 +80,8 @@ struct RendererContentSettingRules {
- ContentSettingsForOneType popup_redirect_rules;
- ContentSettingsForOneType mixed_content_rules;
- ContentSettingsForOneType auto_dark_content_rules;
- + ContentSettingsForOneType timezone_override_rules;
- + std::string timezone_override_value;
- };
-
- namespace content_settings {
- diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom
- --- a/components/content_settings/core/common/content_settings.mojom
- +++ b/components/content_settings/core/common/content_settings.mojom
- @@ -78,4 +78,6 @@ struct RendererContentSettingRules {
- array<ContentSettingPatternSource> popup_redirect_rules;
- array<ContentSettingPatternSource> mixed_content_rules;
- array<ContentSettingPatternSource> auto_dark_content_rules;
- + array<ContentSettingPatternSource> timezone_override_rules;
- + string timezone_override_value;
- };
- diff --git a/components/content_settings/core/common/content_settings_mojom_traits.cc b/components/content_settings/core/common/content_settings_mojom_traits.cc
- --- a/components/content_settings/core/common/content_settings_mojom_traits.cc
- +++ b/components/content_settings/core/common/content_settings_mojom_traits.cc
- @@ -101,7 +101,9 @@ bool StructTraits<content_settings::mojom::RendererContentSettingRulesDataView,
- data.ReadScriptRules(&out->script_rules) &&
- data.ReadPopupRedirectRules(&out->popup_redirect_rules) &&
- data.ReadMixedContentRules(&out->mixed_content_rules) &&
- - data.ReadAutoDarkContentRules(&out->auto_dark_content_rules);
- + data.ReadAutoDarkContentRules(&out->auto_dark_content_rules) &&
- + data.ReadTimezoneOverrideRules(&out->timezone_override_rules) &&
- + data.ReadTimezoneOverrideValue(&out->timezone_override_value);
- }
-
- } // namespace mojo
- diff --git a/components/content_settings/core/common/content_settings_mojom_traits.h b/components/content_settings/core/common/content_settings_mojom_traits.h
- --- a/components/content_settings/core/common/content_settings_mojom_traits.h
- +++ b/components/content_settings/core/common/content_settings_mojom_traits.h
- @@ -150,6 +150,16 @@ struct StructTraits<
- return r.auto_dark_content_rules;
- }
-
- + static const std::vector<ContentSettingPatternSource>& timezone_override_rules(
- + const RendererContentSettingRules& r) {
- + return r.timezone_override_rules;
- + }
- +
- + static const std::string& timezone_override_value(
- + const RendererContentSettingRules& r) {
- + return r.timezone_override_value;
- + }
- +
- static bool Read(
- content_settings::mojom::RendererContentSettingRulesDataView data,
- RendererContentSettingRules* out);
- diff --git a/components/content_settings/core/common/content_settings_types.h b/components/content_settings/core/common/content_settings_types.h
- --- a/components/content_settings/core/common/content_settings_types.h
- +++ b/components/content_settings/core/common/content_settings_types.h
- @@ -226,6 +226,9 @@ enum class ContentSettingsType : int32_t {
- // by the File System Access API.
- FILE_SYSTEM_LAST_PICKED_DIRECTORY,
-
- + // Content setting for timezone customization functionality.
- + TIMEZONE_OVERRIDE,
- +
- // Controls access to the getDisplayMedia API when {preferCurrentTab: true}
- // is specified.
- // TODO(crbug.com/1150788): Also apply this when getDisplayMedia() is called
- diff --git a/components/content_settings/core/common/pref_names.cc b/components/content_settings/core/common/pref_names.cc
- --- a/components/content_settings/core/common/pref_names.cc
- +++ b/components/content_settings/core/common/pref_names.cc
- @@ -157,4 +157,7 @@ const char kQuietNotificationPermissionUiDisabledTime[] =
- const char kNotificationsVibrateEnabled[] = "notifications.vibrate_enabled";
- #endif
-
- +const char kContentSettingsCustomTimezone[] =
- + "profile.content_settings.custom_timezone";
- +
- } // namespace prefs
- diff --git a/components/content_settings/core/common/pref_names.h b/components/content_settings/core/common/pref_names.h
- --- a/components/content_settings/core/common/pref_names.h
- +++ b/components/content_settings/core/common/pref_names.h
- @@ -83,6 +83,8 @@ extern const char kQuietNotificationPermissionUiDisabledTime[];
- extern const char kNotificationsVibrateEnabled[];
- #endif
-
- +extern const char kContentSettingsCustomTimezone[];
- +
- } // namespace prefs
-
- #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_PREF_NAMES_H_
- diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc b/components/content_settings/renderer/content_settings_agent_impl.cc
- --- a/components/content_settings/renderer/content_settings_agent_impl.cc
- +++ b/components/content_settings/renderer/content_settings_agent_impl.cc
- @@ -8,8 +8,10 @@
-
- #include "base/bind.h"
- #include "base/feature_list.h"
- +#include "base/logging.h"
- #include "base/metrics/histogram_macros.h"
- #include "base/strings/string_number_conversions.h"
- +#include "base/rand_util.h"
- #include "components/content_settings/core/common/content_settings.h"
- #include "components/content_settings/core/common/content_settings.mojom.h"
- #include "components/content_settings/core/common/content_settings_pattern.h"
- @@ -29,6 +31,10 @@
- #include "third_party/blink/public/web/web_local_frame.h"
- #include "third_party/blink/public/web/web_local_frame_client.h"
- #include "third_party/blink/public/web/web_view.h"
- +#include "third_party/blink/renderer/core/inspector/locale_controller.h"
- +#include "third_party/blink/renderer/core/timezone/timezone_controller.h"
- +#include "third_party/icu/source/common/unicode/strenum.h"
- +#include "third_party/icu/source/i18n/unicode/timezone.h"
- #include "url/gurl.h"
- #include "url/origin.h"
- #include "url/url_constants.h"
- @@ -41,6 +47,8 @@ using blink::WebString;
- using blink::WebURL;
- using blink::WebView;
-
- +std::unique_ptr<blink::TimeZoneController::TimeZoneOverride> timezone_override_;
- +
- namespace content_settings {
- namespace {
-
- @@ -357,6 +365,10 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) {
- allow = allow || IsAllowlistedForContentSettings();
-
- cached_script_permissions_[frame] = allow;
- +
- + if (allow)
- + UpdateOverrides();
- +
- return allow;
- }
-
- @@ -487,4 +499,81 @@ bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const {
- return false;
- }
-
- +bool ContentSettingsAgentImpl::UpdateOverrides() {
- + // Evaluate the content setting rules
- + ContentSetting setting = CONTENT_SETTING_ALLOW;
- +
- + if (content_setting_rules_) {
- + blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
- +
- + setting = GetContentSettingFromRules(
- + content_setting_rules_->timezone_override_rules, frame,
- + url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL());
- + }
- + return UpdateTimeZoneOverride(
- + setting, content_setting_rules_->timezone_override_value);
- + //&& UpdateLocaleOverride(setting);
- +}
- +
- +bool ContentSettingsAgentImpl::UpdateTimeZoneOverride(
- + ContentSetting setting,
- + const std::string& timezone_override_value) {
- + // base/i18n/icu_util.cc # 329
- +
- + /* timezone_id: third_party/icu/source/i18n/timezone.cpp
- + We first try to lookup the zone ID in our system list. If this
- + * fails, we try to parse it as a custom string GMT[+-]hh:mm. If
- + * all else fails, we return GMT, which is probably not what the
- + * user wants, but at least is a functioning TimeZone object.
- + */
- + String timezone_id;
- +
- + if (setting == CONTENT_SETTING_ALLOW) {
- + // system time
- + if (timezone_override_) {
- + timezone_override_.reset();
- + }
- + return true;
- + } else if (setting == CONTENT_SETTING_BLOCK) {
- + // timezone random
- + UErrorCode ec = U_ZERO_ERROR;
- + int32_t rawOffset = base::RandInt(-12, 11) * 3600 * 1000;
- + icu::StringEnumeration* timezones = icu::TimeZone::createEnumeration(
- + rawOffset); // Obtain timezones by GMT timezone offset
- + if (timezones) {
- + const char* tzID;
- + int32_t length;
- + if ((tzID = timezones->next(&length, ec)) != NULL) {
- + timezone_id = String(tzID);
- + }
- + delete timezones;
- + }
- + } else if (setting == CONTENT_SETTING_ASK) {
- + if (timezone_override_value.empty())
- + timezone_id = "Europe/London";
- + else
- + timezone_id = String(timezone_override_value.c_str());
- + }
- +
- + if (blink::TimeZoneController::HasTimeZoneOverride() == false) {
- + timezone_override_.reset();
- + timezone_override_ =
- + blink::TimeZoneController::SetTimeZoneOverride(timezone_id);
- + if (!timezone_override_) {
- + LOG(WARNING) << "UpdateTimeZoneOverride - Invalid timezone id '"
- + << timezone_id << "'";
- + return false;
- + } else {
- + LOG(INFO)
- + << "UpdateTimeZoneOverride - setting to '"
- + << timezone_id << "'";
- + return true;
- + }
- + } else {
- + LOG(INFO)
- + << "UpdateTimeZoneOverride: already set";
- + return false;
- + }
- +}
- +
- } // namespace content_settings
- diff --git a/components/content_settings/renderer/content_settings_agent_impl.h b/components/content_settings/renderer/content_settings_agent_impl.h
- --- a/components/content_settings/renderer/content_settings_agent_impl.h
- +++ b/components/content_settings/renderer/content_settings_agent_impl.h
- @@ -183,6 +183,10 @@ class ContentSettingsAgentImpl
- std::unique_ptr<Delegate> delegate_;
-
- mojo::AssociatedReceiverSet<mojom::ContentSettingsAgent> receivers_;
- +
- + bool UpdateOverrides();
- + bool UpdateTimeZoneOverride(ContentSetting setting, const std::string& timezone_override_value);
- + bool UpdateLocaleOverride(ContentSetting setting);
- };
-
- } // namespace content_settings
- diff --git a/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java b/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java
- --- a/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java
- +++ b/weblayer/browser/java/org/chromium/weblayer_private/settings/WebLayerSiteSettingsDelegate.java
- @@ -137,4 +137,7 @@ public class WebLayerSiteSettingsDelegate
-
- @Override
- public void dismissPrivacySandboxSnackbar() {}
- +
- + @Override
- + public void launchTimeZoneOverrideHelpAndFeedbackActivity(Activity currentActivity) {}
- }
- --
- 2.25.1
|