-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled two performance features by default
fix brave/brave-browser#28615 * kBatterySaverModeAvailable * kHighEfficiencyModeAvailable Deleted brave://settings/performance route. brave://settings/system page has performance section. Battery setting is only visible when device has battery.
- Loading branch information
Showing
17 changed files
with
267 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import {html, RegisterPolymerTemplateModifications} from 'chrome://resources/brave/polymer_overriding.js' | ||
import {loadTimeData} from '../i18n_setup.js' | ||
import '../brave_system_page/brave_performance_page.js' | ||
|
||
RegisterPolymerTemplateModifications({ | ||
'settings-system-page': (templateContent) => { | ||
templateContent.appendChild( | ||
html` | ||
<settings-toggle-button | ||
class="cr-row" | ||
pref="{{prefs.brave.enable_closing_last_tab}}" | ||
label="${loadTimeData.getString("braveHelpTipsClosingLastTab")}"> | ||
</settings-toggle-button> | ||
<settings-brave-performance-page prefs="{{prefs}}"> | ||
</settings-brave-performance-page> | ||
`) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
browser/resources/settings/brave_system_page/brave_performance_page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<style include="settings-shared cr-shared-style iron-flex"> | ||
.title { | ||
font-size: 14px; | ||
font-weight: 600; | ||
height: 68px; | ||
} | ||
</style> | ||
|
||
<template is="dom-if" if="[[showPerformancePage_()]]"> | ||
<div class="cr-row title">$i18n{performancePageTitle}</div> | ||
<settings-performance-page prefs="{{prefs}}"> | ||
</settings-performance-page> | ||
</template> | ||
|
||
<template is="dom-if" if="[[showBatteryPage_()]]"> | ||
<div hidden="[[!showBatterySettings_]]"> | ||
<div class="cr-row title">$i18n{batteryPageTitle}</div> | ||
<settings-battery-page prefs="{{prefs}}"> | ||
</settings-battery-page> | ||
</div> | ||
</template> |
86 changes: 86 additions & 0 deletions
86
browser/resources/settings/brave_system_page/brave_performance_page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' | ||
import {WebUiListenerMixin, WebUiListenerMixinInterface} from 'chrome://resources/cr_elements/web_ui_listener_mixin.js' | ||
import {BaseMixin} from '../base_mixin.js' | ||
import {PerformanceBrowserProxy, PerformanceBrowserProxyImpl} from '../performance_page/performance_browser_proxy.js' | ||
import {getTemplate} from './brave_performance_page.html.js' | ||
import {pageVisibility} from '../page_visibility.js' | ||
import {loadTimeData} from '../i18n_setup.js' | ||
import '../performance_page/battery_page.js' | ||
import '../performance_page/performance_page.js' | ||
|
||
/** | ||
* 'settings-brave-performance-page' is the settings page containing | ||
* brave's performance features. | ||
*/ | ||
|
||
const SettingsBravePerformancePageElementBase = | ||
WebUiListenerMixin(BaseMixin(PolymerElement)) as { | ||
new(): PolymerElement & WebUiListenerMixinInterface | ||
} | ||
|
||
export class SettingsBravePerformancePageElement | ||
extends SettingsBravePerformancePageElementBase { | ||
static get is() { | ||
return 'settings-brave-performance-page' | ||
} | ||
|
||
static get template() { | ||
return getTemplate() | ||
} | ||
|
||
static get properties() { | ||
return { | ||
/** | ||
* Used to hide battery settings section if the device has no battery | ||
*/ | ||
showBatterySettings_: { | ||
type: Boolean, | ||
value: false, | ||
}, | ||
} | ||
} | ||
|
||
private showBatterySettings_: boolean; | ||
private performanceBrowserProxy_: PerformanceBrowserProxy = | ||
PerformanceBrowserProxyImpl.getInstance(); | ||
|
||
override connectedCallback() { | ||
super.connectedCallback() | ||
|
||
if (loadTimeData.getBoolean('batterySaverModeAvailable')) { | ||
this.addWebUiListener( | ||
'device-has-battery-changed', | ||
this.onDeviceHasBatteryChanged_.bind(this)) | ||
this.performanceBrowserProxy_.getDeviceHasBattery().then( | ||
this.onDeviceHasBatteryChanged_.bind(this)) | ||
} | ||
} | ||
|
||
private showPerformancePage_(): boolean { | ||
return pageVisibility?.performance !== false && | ||
loadTimeData.getBoolean('highEfficiencyModeAvailable') | ||
} | ||
|
||
private showBatteryPage_(): boolean { | ||
return pageVisibility?.performance !== false && | ||
loadTimeData.getBoolean('batterySaverModeAvailable') | ||
} | ||
|
||
private onDeviceHasBatteryChanged_(deviceHasBattery: boolean) { | ||
this.showBatterySettings_ = deviceHasBattery | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'settings-brave-performance-page': SettingsBravePerformancePageElement | ||
} | ||
} | ||
|
||
customElements.define( | ||
SettingsBravePerformancePageElement.is, SettingsBravePerformancePageElement) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "src/components/performance_manager/features.cc" | ||
|
||
#include "base/feature_override.h" | ||
#include "build/build_config.h" | ||
|
||
namespace performance_manager::features { | ||
|
||
#if !BUILDFLAG(IS_ANDROID) | ||
OVERRIDE_FEATURE_DEFAULT_STATES({{ | ||
{kBatterySaverModeAvailable, base::FEATURE_ENABLED_BY_DEFAULT}, | ||
{kHighEfficiencyModeAvailable, base::FEATURE_ENABLED_BY_DEFAULT}, | ||
}}); | ||
#endif | ||
|
||
} // namespace performance_manager::features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.