diff options
Diffstat (limited to 'www/chromium-uc/patches/extra/inox-patchset')
6 files changed, 393 insertions, 0 deletions
diff --git a/www/chromium-uc/patches/extra/inox-patchset/0006-modify-default-prefs.patch b/www/chromium-uc/patches/extra/inox-patchset/0006-modify-default-prefs.patch new file mode 100644 index 0000000..d62ef29 --- /dev/null +++ b/www/chromium-uc/patches/extra/inox-patchset/0006-modify-default-prefs.patch | |||
| @@ -0,0 +1,199 @@ | |||
| 1 | |||
| 2 | --- chrome/browser/background/background_mode_manager.cc.orig | ||
| 3 | +++ chrome/browser/background/background_mode_manager.cc | ||
| 4 | @@ -376,7 +376,7 @@ void BackgroundModeManager::RegisterPref | ||
| 5 | registry->RegisterBooleanPref(prefs::kChromeCreatedLoginItem, false); | ||
| 6 | registry->RegisterBooleanPref(prefs::kMigratedLoginItemPref, false); | ||
| 7 | #endif | ||
| 8 | - registry->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); | ||
| 9 | + registry->RegisterBooleanPref(prefs::kBackgroundModeEnabled, false); | ||
| 10 | } | ||
| 11 | |||
| 12 | void BackgroundModeManager::RegisterProfile(Profile* profile) { | ||
| 13 | --- chrome/browser/chrome_content_browser_client.cc.orig | ||
| 14 | +++ chrome/browser/chrome_content_browser_client.cc | ||
| 15 | @@ -1238,7 +1238,7 @@ void ChromeContentBrowserClient::Registe | ||
| 16 | void ChromeContentBrowserClient::RegisterProfilePrefs( | ||
| 17 | user_prefs::PrefRegistrySyncable* registry) { | ||
| 18 | registry->RegisterBooleanPref(prefs::kDisable3DAPIs, false); | ||
| 19 | - registry->RegisterBooleanPref(prefs::kEnableHyperlinkAuditing, true); | ||
| 20 | + registry->RegisterBooleanPref(prefs::kEnableHyperlinkAuditing, false); | ||
| 21 | // Register user prefs for mapping SitePerProcess and IsolateOrigins in | ||
| 22 | // user policy in addition to the same named ones in Local State (which are | ||
| 23 | // used for mapping the command-line flags). | ||
| 24 | --- chrome/browser/net/prediction_options.cc.orig | ||
| 25 | +++ chrome/browser/net/prediction_options.cc | ||
| 26 | @@ -31,7 +31,7 @@ NetworkPredictionStatus CanPrefetchAndPr | ||
| 27 | } | ||
| 28 | return NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK; | ||
| 29 | default: | ||
| 30 | - DCHECK_EQ(NETWORK_PREDICTION_NEVER, network_prediction_options); | ||
| 31 | + //DCHECK_EQ(NETWORK_PREDICTION_NEVER, network_prediction_options); | ||
| 32 | return NetworkPredictionStatus::DISABLED_ALWAYS; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | --- chrome/browser/net/prediction_options.h.orig | ||
| 36 | +++ chrome/browser/net/prediction_options.h | ||
| 37 | @@ -22,7 +22,7 @@ enum NetworkPredictionOptions { | ||
| 38 | NETWORK_PREDICTION_ALWAYS, | ||
| 39 | NETWORK_PREDICTION_WIFI_ONLY, | ||
| 40 | NETWORK_PREDICTION_NEVER, | ||
| 41 | - NETWORK_PREDICTION_DEFAULT = NETWORK_PREDICTION_WIFI_ONLY, | ||
| 42 | + NETWORK_PREDICTION_DEFAULT = NETWORK_PREDICTION_NEVER, | ||
| 43 | }; | ||
| 44 | |||
| 45 | enum class NetworkPredictionStatus { | ||
| 46 | --- chrome/browser/net/profile_network_context_service.cc.orig | ||
| 47 | +++ chrome/browser/net/profile_network_context_service.cc | ||
| 48 | @@ -319,7 +319,7 @@ void ProfileNetworkContextService::Updat | ||
| 49 | void ProfileNetworkContextService::RegisterProfilePrefs( | ||
| 50 | user_prefs::PrefRegistrySyncable* registry) { | ||
| 51 | registry->RegisterBooleanPref( | ||
| 52 | - embedder_support::kAlternateErrorPagesEnabled, true, | ||
| 53 | + embedder_support::kAlternateErrorPagesEnabled, false, | ||
| 54 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 55 | registry->RegisterBooleanPref(prefs::kQuicAllowed, true); | ||
| 56 | registry->RegisterBooleanPref(prefs::kGloballyScopeHTTPAuthCacheEnabled, | ||
| 57 | --- chrome/browser/profiles/profile.cc.orig | ||
| 58 | +++ chrome/browser/profiles/profile.cc | ||
| 59 | @@ -276,7 +276,7 @@ const char Profile::kProfileKey[] = "__P | ||
| 60 | void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | ||
| 61 | registry->RegisterBooleanPref( | ||
| 62 | prefs::kSearchSuggestEnabled, | ||
| 63 | - true, | ||
| 64 | + false, | ||
| 65 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 66 | #if defined(OS_ANDROID) | ||
| 67 | registry->RegisterStringPref( | ||
| 68 | --- chrome/browser/resources/settings/reset_page/reset_profile_dialog.html.orig | ||
| 69 | +++ chrome/browser/resources/settings/reset_page/reset_profile_dialog.html | ||
| 70 | @@ -36,7 +36,7 @@ | ||
| 71 | </cr-button> | ||
| 72 | </div> | ||
| 73 | <div slot="footer"> | ||
| 74 | - <cr-checkbox id="sendSettings" checked> | ||
| 75 | + <cr-checkbox id="sendSettings"> | ||
| 76 | $i18nRaw{resetPageFeedback}</cr-checkbox> | ||
| 77 | </div> | ||
| 78 | </cr-dialog> | ||
| 79 | --- chrome/browser/signin/account_consistency_mode_manager.cc.orig | ||
| 80 | +++ chrome/browser/signin/account_consistency_mode_manager.cc | ||
| 81 | @@ -111,7 +111,7 @@ AccountConsistencyModeManager::~AccountC | ||
| 82 | // static | ||
| 83 | void AccountConsistencyModeManager::RegisterProfilePrefs( | ||
| 84 | user_prefs::PrefRegistrySyncable* registry) { | ||
| 85 | - registry->RegisterBooleanPref(prefs::kSigninAllowedOnNextStartup, true); | ||
| 86 | + registry->RegisterBooleanPref(prefs::kSigninAllowedOnNextStartup, false); | ||
| 87 | } | ||
| 88 | |||
| 89 | // static | ||
| 90 | --- chrome/browser/ui/browser_ui_prefs.cc.orig | ||
| 91 | +++ chrome/browser/ui/browser_ui_prefs.cc | ||
| 92 | @@ -77,11 +77,11 @@ void RegisterBrowserUserPrefs(user_prefs | ||
| 93 | registry->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); | ||
| 94 | registry->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); | ||
| 95 | registry->RegisterBooleanPref( | ||
| 96 | - translate::prefs::kOfferTranslateEnabled, true, | ||
| 97 | + translate::prefs::kOfferTranslateEnabled, false, | ||
| 98 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 99 | registry->RegisterStringPref(prefs::kCloudPrintEmail, std::string()); | ||
| 100 | registry->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, true); | ||
| 101 | - registry->RegisterBooleanPref(prefs::kCloudPrintSubmitEnabled, true); | ||
| 102 | + registry->RegisterBooleanPref(prefs::kCloudPrintSubmitEnabled, false); | ||
| 103 | registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | ||
| 104 | registry->RegisterDictionaryPref(prefs::kBrowserWindowPlacementPopup); | ||
| 105 | registry->RegisterDictionaryPref(prefs::kAppWindowPlacement); | ||
| 106 | --- chrome/service/cloud_print/connector_settings.cc.orig | ||
| 107 | +++ chrome/service/cloud_print/connector_settings.cc | ||
| 108 | @@ -59,7 +59,7 @@ void ConnectorSettings::InitFrom(Service | ||
| 109 | DCHECK(server_url_.is_valid()); | ||
| 110 | |||
| 111 | connect_new_printers_ = prefs->GetBoolean( | ||
| 112 | - prefs::kCloudPrintConnectNewPrinters, true); | ||
| 113 | + prefs::kCloudPrintConnectNewPrinters, false); | ||
| 114 | |||
| 115 | xmpp_ping_enabled_ = prefs->GetBoolean( | ||
| 116 | prefs::kCloudPrintXmppPingEnabled, false); | ||
| 117 | --- components/autofill/core/common/autofill_prefs.cc.orig | ||
| 118 | +++ components/autofill/core/common/autofill_prefs.cc | ||
| 119 | @@ -131,10 +131,10 @@ const char kAutocompleteLastVersionReten | ||
| 120 | void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | ||
| 121 | // Synced prefs. Used for cross-device choices, e.g., credit card Autofill. | ||
| 122 | registry->RegisterBooleanPref( | ||
| 123 | - prefs::kAutofillEnabledDeprecated, true, | ||
| 124 | + prefs::kAutofillEnabledDeprecated, false, | ||
| 125 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 126 | registry->RegisterBooleanPref( | ||
| 127 | - prefs::kAutofillProfileEnabled, true, | ||
| 128 | + prefs::kAutofillProfileEnabled, false, | ||
| 129 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 130 | registry->RegisterIntegerPref( | ||
| 131 | prefs::kAutofillLastVersionDeduped, 0, | ||
| 132 | @@ -147,7 +147,7 @@ void RegisterProfilePrefs(user_prefs::Pr | ||
| 133 | prefs::kAutofillLastVersionDisusedAddressesDeleted, 0, | ||
| 134 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 135 | registry->RegisterBooleanPref( | ||
| 136 | - prefs::kAutofillCreditCardEnabled, true, | ||
| 137 | + prefs::kAutofillCreditCardEnabled, false, | ||
| 138 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 139 | registry->RegisterStringPref( | ||
| 140 | prefs::kAutofillProfileValidity, "", | ||
| 141 | --- components/bookmarks/browser/bookmark_utils.cc.orig | ||
| 142 | +++ components/bookmarks/browser/bookmark_utils.cc | ||
| 143 | @@ -437,7 +437,7 @@ bool DoesBookmarkContainWords(const std: | ||
| 144 | void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | ||
| 145 | registry->RegisterBooleanPref( | ||
| 146 | prefs::kShowBookmarkBar, | ||
| 147 | - false, | ||
| 148 | + true, | ||
| 149 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 150 | registry->RegisterBooleanPref(prefs::kEditBookmarksEnabled, true); | ||
| 151 | registry->RegisterBooleanPref( | ||
| 152 | --- components/bookmarks/browser/features.cc.orig | ||
| 153 | +++ components/bookmarks/browser/features.cc | ||
| 154 | @@ -10,7 +10,7 @@ namespace features { | ||
| 155 | // Changes the apps shortcut on the bookmarks bar to default to off. | ||
| 156 | // https://crbug.com/1236793 | ||
| 157 | const base::Feature kAppsShortcutDefaultOff{"AppsShortcutDefaultOff", | ||
| 158 | - base::FEATURE_DISABLED_BY_DEFAULT}; | ||
| 159 | + base::FEATURE_ENABLED_BY_DEFAULT}; | ||
| 160 | |||
| 161 | } // namespace features | ||
| 162 | } // namespace bookmarks | ||
| 163 | --- components/content_settings/core/browser/cookie_settings.cc.orig | ||
| 164 | +++ components/content_settings/core/browser/cookie_settings.cc | ||
| 165 | @@ -63,7 +63,7 @@ void CookieSettings::RegisterProfilePref | ||
| 166 | user_prefs::PrefRegistrySyncable* registry) { | ||
| 167 | registry->RegisterIntegerPref( | ||
| 168 | prefs::kCookieControlsMode, | ||
| 169 | - static_cast<int>(CookieControlsMode::kIncognitoOnly), | ||
| 170 | + static_cast<int>(CookieControlsMode::kBlockThirdParty), | ||
| 171 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 172 | } | ||
| 173 | |||
| 174 | --- components/password_manager/core/browser/password_manager.cc.orig | ||
| 175 | +++ components/password_manager/core/browser/password_manager.cc | ||
| 176 | @@ -204,10 +204,10 @@ bool HasMutedCredentials(base::span<cons | ||
| 177 | void PasswordManager::RegisterProfilePrefs( | ||
| 178 | user_prefs::PrefRegistrySyncable* registry) { | ||
| 179 | registry->RegisterBooleanPref( | ||
| 180 | - prefs::kCredentialsEnableService, true, | ||
| 181 | + prefs::kCredentialsEnableService, false, | ||
| 182 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); | ||
| 183 | registry->RegisterBooleanPref( | ||
| 184 | - prefs::kCredentialsEnableAutosignin, true, | ||
| 185 | + prefs::kCredentialsEnableAutosignin, false, | ||
| 186 | user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); | ||
| 187 | registry->RegisterStringPref(prefs::kSyncPasswordHash, std::string(), | ||
| 188 | PrefRegistry::NO_REGISTRATION_FLAGS); | ||
| 189 | --- components/payments/core/payment_prefs.cc.orig | ||
| 190 | +++ components/payments/core/payment_prefs.cc | ||
| 191 | @@ -16,7 +16,7 @@ const char kCanMakePaymentEnabled[] = "p | ||
| 192 | void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | ||
| 193 | registry->RegisterBooleanPref(kPaymentsFirstTransactionCompleted, false); | ||
| 194 | registry->RegisterBooleanPref( | ||
| 195 | - kCanMakePaymentEnabled, true, | ||
| 196 | + kCanMakePaymentEnabled, false, | ||
| 197 | user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | ||
| 198 | } | ||
| 199 | |||
diff --git a/www/chromium-uc/patches/extra/inox-patchset/0008-restore-classic-ntp.patch b/www/chromium-uc/patches/extra/inox-patchset/0008-restore-classic-ntp.patch new file mode 100644 index 0000000..9d21b6f --- /dev/null +++ b/www/chromium-uc/patches/extra/inox-patchset/0008-restore-classic-ntp.patch | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | --- chrome/browser/search/search.cc.orig | ||
| 2 | +++ chrome/browser/search/search.cc | ||
| 3 | @@ -182,26 +182,7 @@ struct NewTabURLDetails { | ||
| 4 | : chrome::kChromeUINewTabPageThirdPartyURL); | ||
| 5 | #endif | ||
| 6 | |||
| 7 | - if (ShouldShowLocalNewTab(profile)) | ||
| 8 | - return NewTabURLDetails(local_url, NEW_TAB_URL_VALID); | ||
| 9 | - | ||
| 10 | - const TemplateURL* template_url = | ||
| 11 | - GetDefaultSearchProviderTemplateURL(profile); | ||
| 12 | - if (!profile || !template_url) | ||
| 13 | - return NewTabURLDetails(local_url, NEW_TAB_URL_BAD); | ||
| 14 | - | ||
| 15 | - GURL search_provider_url(template_url->new_tab_url_ref().ReplaceSearchTerms( | ||
| 16 | - TemplateURLRef::SearchTermsArgs(std::u16string()), | ||
| 17 | - UIThreadSearchTermsData())); | ||
| 18 | - | ||
| 19 | - if (!search_provider_url.is_valid()) | ||
| 20 | - return NewTabURLDetails(local_url, NEW_TAB_URL_NOT_SET); | ||
| 21 | - if (!search_provider_url.SchemeIsCryptographic()) | ||
| 22 | - return NewTabURLDetails(local_url, NEW_TAB_URL_INSECURE); | ||
| 23 | - if (!IsURLAllowedForSupervisedUser(search_provider_url, profile)) | ||
| 24 | - return NewTabURLDetails(local_url, NEW_TAB_URL_BLOCKED); | ||
| 25 | - | ||
| 26 | - return NewTabURLDetails(search_provider_url, NEW_TAB_URL_VALID); | ||
| 27 | + return NewTabURLDetails(local_url, NEW_TAB_URL_VALID); | ||
| 28 | } | ||
| 29 | |||
| 30 | const GURL url; | ||
| 31 | --- components/ntp_snippets/features.cc.orig | ||
| 32 | +++ components/ntp_snippets/features.cc | ||
| 33 | @@ -39,7 +39,7 @@ const base::Feature* const kAllFeatures[ | ||
| 34 | &kOptionalImagesEnabledFeature}; | ||
| 35 | |||
| 36 | const base::Feature kArticleSuggestionsFeature{ | ||
| 37 | - "NTPArticleSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; | ||
| 38 | + "NTPArticleSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; | ||
| 39 | |||
| 40 | const base::Feature kRemoteSuggestionsEmulateM58FetchingSchedule{ | ||
| 41 | "RemoteSuggestionsEmulateM58FetchingSchedule", | ||
| 42 | @@ -69,10 +69,10 @@ const char kNotificationsDailyLimit[] = | ||
| 43 | const char kNotificationsIgnoredLimitParam[] = "ignored_limit"; | ||
| 44 | |||
| 45 | const base::Feature kKeepPrefetchedContentSuggestions{ | ||
| 46 | - "KeepPrefetchedContentSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; | ||
| 47 | + "KeepPrefetchedContentSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; | ||
| 48 | |||
| 49 | const base::Feature kOptionalImagesEnabledFeature{ | ||
| 50 | - "NTPRemoteSuggestionsOptionalImages", base::FEATURE_ENABLED_BY_DEFAULT}; | ||
| 51 | + "NTPRemoteSuggestionsOptionalImages", base::FEATURE_DISABLED_BY_DEFAULT}; | ||
| 52 | |||
| 53 | std::vector<const base::Feature*> GetAllFeatures() { | ||
| 54 | // Skip the last feature as it's a nullptr. | ||
diff --git a/www/chromium-uc/patches/extra/inox-patchset/0013-disable-missing-key-warning.patch b/www/chromium-uc/patches/extra/inox-patchset/0013-disable-missing-key-warning.patch new file mode 100644 index 0000000..0b14cd8 --- /dev/null +++ b/www/chromium-uc/patches/extra/inox-patchset/0013-disable-missing-key-warning.patch | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --- chrome/browser/ui/startup/google_api_keys_infobar_delegate.cc.orig | ||
| 2 | +++ chrome/browser/ui/startup/google_api_keys_infobar_delegate.cc | ||
| 3 | @@ -17,9 +17,6 @@ | ||
| 4 | // static | ||
| 5 | void GoogleApiKeysInfoBarDelegate::Create( | ||
| 6 | infobars::ContentInfoBarManager* infobar_manager) { | ||
| 7 | - infobar_manager->AddInfoBar( | ||
| 8 | - CreateConfirmInfoBar(std::unique_ptr<ConfirmInfoBarDelegate>( | ||
| 9 | - new GoogleApiKeysInfoBarDelegate()))); | ||
| 10 | } | ||
| 11 | |||
| 12 | GoogleApiKeysInfoBarDelegate::GoogleApiKeysInfoBarDelegate() | ||
diff --git a/www/chromium-uc/patches/extra/inox-patchset/0016-chromium-sandbox-pie.patch b/www/chromium-uc/patches/extra/inox-patchset/0016-chromium-sandbox-pie.patch new file mode 100644 index 0000000..ff72a53 --- /dev/null +++ b/www/chromium-uc/patches/extra/inox-patchset/0016-chromium-sandbox-pie.patch | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --- sandbox/linux/BUILD.gn.orig | ||
| 2 | +++ sandbox/linux/BUILD.gn | ||
| 3 | @@ -327,6 +327,12 @@ if (is_linux || is_chromeos) { | ||
| 4 | # These files have a suspicious comparison. | ||
| 5 | # TODO fix this and re-enable this warning. | ||
| 6 | "-Wno-sign-compare", | ||
| 7 | + | ||
| 8 | + "-fPIE", | ||
| 9 | + ] | ||
| 10 | + | ||
| 11 | + ldflags = [ | ||
| 12 | + "-pie", | ||
| 13 | ] | ||
| 14 | } | ||
| 15 | } | ||
diff --git a/www/chromium-uc/patches/extra/inox-patchset/0018-disable-first-run-behaviour.patch b/www/chromium-uc/patches/extra/inox-patchset/0018-disable-first-run-behaviour.patch new file mode 100644 index 0000000..4790f65 --- /dev/null +++ b/www/chromium-uc/patches/extra/inox-patchset/0018-disable-first-run-behaviour.patch | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | --- chrome/browser/ui/startup/startup_tab_provider.cc.orig | ||
| 2 | +++ chrome/browser/ui/startup/startup_tab_provider.cc | ||
| 3 | @@ -105,7 +105,7 @@ bool ValidateUrl(const GURL& url) { | ||
| 4 | |||
| 5 | StartupTabs StartupTabProviderImpl::GetOnboardingTabs(Profile* profile) const { | ||
| 6 | // Chrome OS has its own welcome flow provided by OOBE. | ||
| 7 | -#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
| 8 | +#if 1 | ||
| 9 | return StartupTabs(); | ||
| 10 | #else | ||
| 11 | if (!profile) | ||
diff --git a/www/chromium-uc/patches/extra/inox-patchset/0019-disable-battery-status-service.patch b/www/chromium-uc/patches/extra/inox-patchset/0019-disable-battery-status-service.patch new file mode 100644 index 0000000..ded3df9 --- /dev/null +++ b/www/chromium-uc/patches/extra/inox-patchset/0019-disable-battery-status-service.patch | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | --- services/device/battery/battery_status_service.cc.orig | ||
| 2 | +++ services/device/battery/battery_status_service.cc | ||
| 3 | @@ -22,10 +22,7 @@ BatteryStatusService::BatteryStatusServi | ||
| 4 | update_callback_( | ||
| 5 | base::BindRepeating(&BatteryStatusService::NotifyConsumers, | ||
| 6 | base::Unretained(this))), | ||
| 7 | - status_updated_(false), | ||
| 8 | is_shutdown_(false) { | ||
| 9 | - callback_list_.set_removal_callback(base::BindRepeating( | ||
| 10 | - &BatteryStatusService::ConsumersChanged, base::Unretained(this))); | ||
| 11 | } | ||
| 12 | |||
| 13 | BatteryStatusService::~BatteryStatusService() = default; | ||
| 14 | @@ -40,58 +37,16 @@ base::CallbackListSubscription BatterySt | ||
| 15 | DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | ||
| 16 | DCHECK(!is_shutdown_); | ||
| 17 | |||
| 18 | - if (!battery_fetcher_) | ||
| 19 | - battery_fetcher_ = BatteryStatusManager::Create(update_callback_); | ||
| 20 | - | ||
| 21 | - if (callback_list_.empty()) { | ||
| 22 | - bool success = battery_fetcher_->StartListeningBatteryChange(); | ||
| 23 | - // On failure pass the default values back. | ||
| 24 | - if (!success) | ||
| 25 | - callback.Run(mojom::BatteryStatus()); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - if (status_updated_) { | ||
| 29 | - // Send recent status to the new callback if already available. | ||
| 30 | - callback.Run(status_); | ||
| 31 | - } | ||
| 32 | + // Always pass the default values. | ||
| 33 | + callback.Run(mojom::BatteryStatus()); | ||
| 34 | |||
| 35 | return callback_list_.Add(callback); | ||
| 36 | } | ||
| 37 | |||
| 38 | -void BatteryStatusService::ConsumersChanged() { | ||
| 39 | - if (is_shutdown_) | ||
| 40 | - return; | ||
| 41 | - | ||
| 42 | - if (callback_list_.empty()) { | ||
| 43 | - battery_fetcher_->StopListeningBatteryChange(); | ||
| 44 | - status_updated_ = false; | ||
| 45 | - } | ||
| 46 | -} | ||
| 47 | - | ||
| 48 | void BatteryStatusService::NotifyConsumers(const mojom::BatteryStatus& status) { | ||
| 49 | - DCHECK(!is_shutdown_); | ||
| 50 | - | ||
| 51 | - main_thread_task_runner_->PostTask( | ||
| 52 | - FROM_HERE, | ||
| 53 | - base::BindOnce(&BatteryStatusService::NotifyConsumersOnMainThread, | ||
| 54 | - base::Unretained(this), status)); | ||
| 55 | -} | ||
| 56 | - | ||
| 57 | -void BatteryStatusService::NotifyConsumersOnMainThread( | ||
| 58 | - const mojom::BatteryStatus& status) { | ||
| 59 | - DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | ||
| 60 | - if (callback_list_.empty()) | ||
| 61 | - return; | ||
| 62 | - | ||
| 63 | - status_ = status; | ||
| 64 | - status_updated_ = true; | ||
| 65 | - callback_list_.Notify(status_); | ||
| 66 | } | ||
| 67 | |||
| 68 | void BatteryStatusService::Shutdown() { | ||
| 69 | - if (!callback_list_.empty()) | ||
| 70 | - battery_fetcher_->StopListeningBatteryChange(); | ||
| 71 | - battery_fetcher_.reset(); | ||
| 72 | is_shutdown_ = true; | ||
| 73 | } | ||
| 74 | |||
| 75 | @@ -102,9 +57,6 @@ BatteryStatusService::GetUpdateCallbackF | ||
| 76 | |||
| 77 | void BatteryStatusService::SetBatteryManagerForTesting( | ||
| 78 | std::unique_ptr<BatteryStatusManager> test_battery_manager) { | ||
| 79 | - battery_fetcher_ = std::move(test_battery_manager); | ||
| 80 | - status_ = mojom::BatteryStatus(); | ||
| 81 | - status_updated_ = false; | ||
| 82 | is_shutdown_ = false; | ||
| 83 | main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | ||
| 84 | } | ||
| 85 | --- services/device/battery/battery_status_service.h.orig | ||
| 86 | +++ services/device/battery/battery_status_service.h | ||
| 87 | @@ -60,15 +60,10 @@ class BatteryStatusService { | ||
| 88 | // Updates current battery status and sends new status to interested | ||
| 89 | // render processes. Can be called on any thread via a callback. | ||
| 90 | void NotifyConsumers(const mojom::BatteryStatus& status); | ||
| 91 | - void NotifyConsumersOnMainThread(const mojom::BatteryStatus& status); | ||
| 92 | - void ConsumersChanged(); | ||
| 93 | |||
| 94 | scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | ||
| 95 | - std::unique_ptr<BatteryStatusManager> battery_fetcher_; | ||
| 96 | BatteryUpdateCallbackList callback_list_; | ||
| 97 | BatteryUpdateCallback update_callback_; | ||
| 98 | - mojom::BatteryStatus status_; | ||
| 99 | - bool status_updated_; | ||
| 100 | bool is_shutdown_; | ||
| 101 | }; | ||
| 102 | |||
