-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #18152: Cast should be disabled on toggling off media router switch in extension settings #10116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
05b9008
to
39409da
Compare
browser/brave_profile_prefs.cc
Outdated
@@ -409,6 +409,8 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | |||
|
|||
registry->SetDefaultPrefValue(prefs::kEnableMediaRouter, base::Value(false)); | |||
|
|||
registry->RegisterBooleanPref(kBraveMediaRouter, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we're adding a new pref and how is this different from prefs::kEnableMediaRouter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cast extension requires a browser restart once the setting is toggled. We use the pref kBraveMediaRouter
as a proxy to identify the current state of the switch and prefs::kEnableMediaRouter
is updated to kBraveMediaRouter
on browser start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we already had something like this?
common/pref_names.h
Outdated
@@ -92,6 +92,7 @@ extern const char kSafetynetStatus[]; | |||
extern const char kDefaultBrowserLaunchingCount[]; | |||
extern const char kTabsSearchShow[]; | |||
extern const char kDontAskForCrashReporting[]; | |||
extern const char kBraveMediaRouter[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above these prefs need comments explaining them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -5,6 +5,7 @@ | |||
|
|||
#include "chrome/browser/media/router/media_router_feature.h" | |||
|
|||
#include "brave/common/pref_names.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't appear to be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
KeyedService* MediaRouterUIServiceFactory::BuildServiceInstanceFor( | ||
BrowserContext* context) const { | ||
#if !defined(OS_ANDROID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also needs a comment because I don't understand why we're doing this or why it's happening here because this definitely doesn't seem like the right place. If kEnableMediaRouter
needs to be kept in sync with kBraveMediaRouter
, there should be a pref observer for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common/pref_names.cc
Outdated
// kBraveMediaRouter is used as a proxy to identify the current state of the | ||
// switch and prefs::kEnableMediaRouter is updated to kBraveMediaRouter | ||
// on restart. | ||
const char kBraveMediaRouter[] = "brave.media_router"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this naming is confusing imo. It makes it sound like we have our own media router. If this pref is needed (not sure why we can't just restart when changing kEnableMediaRouter
) it should be renamed to something like kEnableMediaRouterOnRestart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the comment should go in the .h file, not the .cc file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
|
||
KeyedService* MediaRouterUIServiceFactory::BuildServiceInstanceFor( | ||
BrowserContext* context) const { | ||
// Chromecast is enabled by default on Android. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should go in BraveProfileManager::InitProfileUserPrefs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
@@ -366,11 +368,15 @@ void BraveAddAboutStrings(content::WebUIDataSource* html_source, | |||
html_source->AddString("aboutProductLicense", license); | |||
} | |||
|
|||
void BraveAddSocialBlockingLoadTimeData(content::WebUIDataSource* html_source, | |||
Profile* profile) { | |||
void BraveAddExtensionSettingsLoadTimeData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old name didn't make sense, but neither does this one and I don't think this needs to be a method anyway, just put them directly in BraveAddLocalizedStrings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved!
// on restart | ||
#if !defined(OS_ANDROID) | ||
auto* pref_service = profile->GetPrefs(); | ||
auto enabled = pref_service->GetBoolean(kEnableMediaRouterOnRestart); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to check IsDefaultValue
or this will disable for everyone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved!
32bcea1
to
92b0031
Compare
common/pref_names.cc
Outdated
@@ -101,6 +101,13 @@ const char kMRUCyclingEnabled[] = "brave.mru_cycling_enabled"; | |||
const char kTabsSearchShow[] = "brave.tabs_search_show"; | |||
const char kDontAskForCrashReporting[] = "brave.dont_ask_for_crash_reporting"; | |||
|
|||
// Cast extension requires a browser restart once the setting is toggled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment should be in the .h file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
"signInAllowedOnNextStartupInitialValue", | ||
profile->GetPrefs()->GetBoolean(prefs::kSigninAllowedOnNextStartup)); | ||
|
||
html_source->AddBoolean("mediaRouterEnabledInitialValue", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ts/js naming convention should match c++ to avoid confusion. isMediaRouterEnabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -21,6 +21,7 @@ cr.define('settings', function () { | |||
isWidevineEnabled() {} | |||
getRestartNeeded () {} | |||
wasSignInEnabledAtStartup () {} | |||
wasMediaRouterEnabledAtStartup () {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the pref isMediaRouterEnabled
fully captures what this value is and is consistent with c++
…ch in extension settings
Fix #18152: Cast should be disabled on toggling off media router switch in extension settings
Verification PASSED on
|
Example |
Example |
---|---|
Casting Desktop
Example |
Example |
---|---|
Casting Local File
Example |
Example |
---|---|
Verification PASSED on Samsung S10+
running Android 11
using the following build:
Brave | 1.32.56 Chromium: 95.0.4638.40
- ensured that
Media Router
was enabled by default by visiting https://gem.cbc.ca/live/channel/ottawa and ensuring that theCast
icon was being displayed via the media player - ensured that tapping on the
Cast
button displayed a modal with all the devices that can cast
Example |
Example |
Example |
Example |
---|---|---|---|
Resolves brave/brave-browser#18152
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Desktop
Android