Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRe-add support for Chromecast #2493
Conversation
|
Errors from prior merge attempt:
|
24f1944
to
63cea2e
|
As @jumde mentioned, case is still not working due to and @jumde tested it is enabled with below patch.
|
@simonhong - With this patch I checked that the signature check fails in |
|
@jumde I edited right before your last comment :) |
| @@ -38,6 +42,9 @@ const char kCRLSetPrefix3[] = | |||
| const char kCRLSetPrefix4[] = | |||
| "*://storage.googleapis.com/update-delta/hfnkpimlhhgieaddgfemjhofmfblmnib" | |||
| "/*crxd"; | |||
| const char kGoogleAPIPrefix[] = "https://www.googleapis.com/"; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jumde
Jun 20, 2019
Contributor
it was not connecting over http but I agree, using * would help if the code fallsback to the non-secure url
9ec2881
to
1b13d24
|
@bridiver added cause this PR adds new patch file. |
|
Thanks for making the restart notification persistent. Minor changes requested to the JS api |
| @@ -63,10 +64,29 @@ void BraveDefaultExtensionsHandler::RegisterMessages() { | |||
| flags_ui::kRestartBrowser, | |||
| base::BindRepeating(&BraveDefaultExtensionsHandler::HandleRestartBrowser, | |||
| base::Unretained(this))); | |||
| web_ui()->RegisterMessageCallback( | |||
| "showRelaunchToast", | |||
This comment has been minimized.
This comment has been minimized.
petemill
Jul 11, 2019
Member
getRestartNeeded so that:
- it's about the data, not the UI implementation (toast)
- it's specific about getting data, and not performing an action
|
|
||
| /** @override */ | ||
| created: function() { | ||
| this.browserProxy_ = settings.BraveDefaultExtensionsBrowserProxyImpl.getInstance(); | ||
| this.browserProxy_.showRelaunchToast().then(show => { | ||
| this.hideRestartToast = !show; | ||
| this.$.needsRestart.hidden = this.hideRestartToast; |
This comment has been minimized.
This comment has been minimized.
petemill
Jul 11, 2019
Member
This may be a micro-optimization, so consider it a nit: I'd feel more comfortable if this didn't require a DOM change on 99.9% of all Settings page loads (i.e. page loads which don't have the toast showing).
This can be achieved by either:
- Preferred: Wrap the element in an
<ifwhich testshideRestartToast(though positive variable name is better, e.g.showRestartToast - Similar pattern to what you have: Create a css class called something like
pageNeedsRestart, and only add this class if the variable comes back true.
|
|
||
| bool IsExtensionInstalled(const std::string& extension_id) const; | ||
| void OnInstallResult(const std::string& pref_name, | ||
| bool success, const std::string& error, | ||
| extensions::webstore_install::Result result); | ||
|
|
||
| Profile* profile_ = nullptr; | ||
| bool restartNeeded = false; |
This comment has been minimized.
This comment has been minimized.
| args->GetBoolean(0, &enabled); | ||
|
|
||
| restartNeeded = !restartNeeded; | ||
| if (enabled) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c6c6a27
to
10047e1
| disable_reason::DisableReason* reason, | ||
| base::string16* error) const { | ||
| CHECK(extension); | ||
| + ReturnFalseIfExtensionShouldSkipSignatureChecking(extension->id()) |
This comment has been minimized.
This comment has been minimized.
jumde
Jul 15, 2019
Contributor
This happens because for Media Router the signature fetch and check happens out of order. This is likely a chromium bug, but not seen because chromium uses ENFORCE instead of ENFORCE_STRICT by default.(https://cs.chromium.org/chromium/src/chrome/browser/extensions/chrome_content_verifier_delegate.cc?l=110)
But, ENFORCE_STRICT (https://cs.chromium.org/chromium/src/extensions/browser/content_verifier_delegate.h?g=0&l=42) is better for security.
We have multiple options here:
- Use
ENFORCEoverENFORCE_STRICTsimilar to chromium. - SkipSignatureVerification for MediaRouter as seen in this PR.
- RedoSignature check after the fetch is complete.
Thoughts? @bridiver @diracdeltas @tomlowenthal
cc: @bsclifton @simonhong
This comment has been minimized.
This comment has been minimized.
bsclifton
Jul 15, 2019
Author
Member
Option 2 or 3 sound great to me- I'd vote for option 2 as my choice
This comment has been minimized.
This comment has been minimized.
diracdeltas
Jul 15, 2019
Member
i prefer 3 since Google Chrome uses ENFORCE_STRICT (https://cs.chromium.org/chromium/src/chrome/browser/extensions/chrome_content_verifier_delegate.cc?l=68); so IIUC, 3 is the only option that gives us parity with Google Chrome security-wise.
This comment has been minimized.
This comment has been minimized.
jumde
Jul 15, 2019
Contributor
@diracdeltas - ENFORCE_STRICT is only used when field trials are enabled, I don't think Chrome has field trials enabled for release builds. Let me know if I'm missing something.
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 15, 2019
Collaborator
@diracdeltas I thought it was the other way around? Chromium uses ENFORCE so my preference is to follow that and not patch here
This comment has been minimized.
This comment has been minimized.
jumde
Jul 15, 2019
Contributor
@diracdeltas @bridiver - ENFORCE_STRICT works well for the extensions I have tested, but I understand the concern that we might run into web-compat issues with an experimental feature.
I have a patch for 3 but, I'm okay with 1 to avoid any web-compat risk we might run into.
| !args->GetString(1, &enable_str)) | ||
| return; | ||
|
|
||
| + SyncFeatureFlagWithBravePrefs(entry_internal_name, Profile::FromWebUI(web_ui())); |
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 15, 2019
Collaborator
I'm confused, I thought we were doing a lazy check to sync with the pref?
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 15, 2019
Collaborator
if we need notification at the time this changes then we should add a pref observer for kEnabledLabsExperiments
This comment has been minimized.
This comment has been minimized.
jumde
Jul 15, 2019
Contributor
I think I could have named it better, the intention of this call is to update the temporary pref kBraveEnabledMediaRouter that we use in brave://settings when flags are toggled. So toggling the flag correctly toggles the Media Router switch in brave://settings.
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 17, 2019
Collaborator
this can be done without a patch using a chromium_src override for SetFeatureEntryEnabled which I thought is what we had before and maybe this is why I'm confused here
| @@ -45,13 +45,42 @@ int OnBeforeURLRequest_CommonStaticRedirectWork( | |||
| const ResponseCallback& next_callback, | |||
| std::shared_ptr<BraveRequestInfo> ctx) { | |||
| GURL::Replacements replacements; | |||
| static URLPattern googleapis_pattern( | |||
| URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS, kGoogleAPIPrefix); | |||
This comment has been minimized.
This comment has been minimized.
| base::Value(restart_needed_)); | ||
| } | ||
|
|
||
| void BraveDefaultExtensionsHandler::HandleRestartBrowser( |
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 15, 2019
Collaborator
I believe the correct way to handle this is to just link to kChromeUIRestartURL
This comment has been minimized.
This comment has been minimized.
jumde
Jul 15, 2019
Contributor
Navigation to kChromeUIRestartURL internally calls chrome::AttemptRestart: https://cs.chromium.org/chromium/src/chrome/browser/browser_about_handler.cc?l=98.
We can link to kChromeUIRestartURL in javascript directly but I was just trying to avoid chances of regression if kChromeUIRestartURL changes in future.
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 16, 2019
Collaborator
I think it is better to use kChromeUIRestartURL than to duplicate the logic here. Not sure why kChromeUIRestartURL would change in the future
This comment has been minimized.
This comment has been minimized.
petemill
Jul 16, 2019
Member
@bridiver just noting that the same functionality in chrome://flags does not link to kChromeUIRestartUI but sends a message to a message handler via chrome.send too and calls AttemptRestart. I wonder what would happen to session restore if the tab was navigated away from the settings page to kChromeUIRestartURL. The settings page may not restore, which would be unfortunate. Although I did spot comments around this being a non-navigation url, so maybe it would restore... Still, I wonder why the Flags page doesn't use it.
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 17, 2019
Collaborator
@petemill because a lot of other things happen in FlagsDOMHandler::HandleRestartBrowser before the restart. The only thing we're doing here is calling AttemptRestart so it's functionally equivalent
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 17, 2019
Collaborator
DCHECK(flags_storage_);
#if defined(OS_CHROMEOS)
// On ChromeOS be less intrusive and restart inside the user session after
// we apply the newly selected flags.
base::CommandLine user_flags(base::CommandLine::NO_PROGRAM);
about_flags::ConvertFlagsToSwitches(flags_storage_.get(),
&user_flags,
flags_ui::kAddSentinels);
// Apply additional switches from policy that should not be dropped when
// applying flags..
chromeos::UserSessionManager::MaybeAppendPolicySwitches(
Profile::FromWebUI(web_ui())->GetPrefs(), &user_flags);
base::CommandLine::StringVector flags;
// argv[0] is the program name |base::CommandLine::NO_PROGRAM|.
flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
VLOG(1) << "Restarting to apply per-session flags...";
AccountId account_id =
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
chromeos::UserSessionManager::GetInstance()->SetSwitchesForUser(
account_id,
chromeos::UserSessionManager::CommandLineSwitchesType::
kPolicyAndFlagsAndKioskControl,
flags);
#endif
chrome::AttemptRestart();
}
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 17, 2019
Collaborator
they need all of that code to run on chromeos before attempting the restart
|
|
||
|
|
||
| AllowJavascript(); | ||
| ResolveJavascriptCallback(args->GetList()[0].Clone(), |
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 15, 2019
•
Collaborator
why are you cloning this? Also args->GetList()[0] is not the correct or safe way to get this value.
std::string callback_id;
args->GetString(0, &callback_id);
and then pass in base::Value(callback_id)
| // Adding the media router extension on explicit toggle to prevent | ||
| // any suprise connections on upgrade | ||
| if (enabled) { | ||
| extensions::ExtensionPrefs::Get(profile_)->SetExtensionEnabled( |
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 15, 2019
Collaborator
we shouldn't be directly calling ExtensionPrefs::SetExtensionEnabled. You should enable/disable using the ExtensionRegistry
9bde2f6
to
40ccf3d
| TEST_F(BraveCommonStaticRedirectNetworkDelegateHelperTest, | ||
| RedirectChromecastDownload) { | ||
| net::TestDelegate test_delegate; | ||
| GURL url( |
This comment has been minimized.
This comment has been minimized.
bridiver
Jul 17, 2019
Collaborator
how do we know this still works if the extension version changes?
This comment has been minimized.
This comment has been minimized.
jumde
Jul 18, 2019
•
Contributor
changed to random_hash and random_version, the pattern https://github.com/brave/brave-core/pull/2493/files#diff-6337bc2627a3b8782b369e66dc193cb9R47 should catch all changes to hash and version
| * You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| #define SetFeatureEntryEnabled SetFeatureEntryEnabled_ChromiumImpl | ||
| #include "../../../../chrome/browser/about_flags.cc" // NOLINT |
This comment has been minimized.
This comment has been minimized.
jumde
Jul 18, 2019
Contributor
Needed because SetFeatureEntryEnabled in about_flags.cc calls, SetFeatureEnabled in flags_state.cc
|
Cast off! |
bsclifton commentedMay 24, 2019
•
edited by jumde
Fixes brave/brave-browser#209
Related brave/brave-browser#4631
Revert "Merge pull request #2119 from brave/revert_enabling_chromecast"
This reverts commit 29ea1df, reversing
changes made to c08710a.
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests && npm run test-security) onnpm run lint)git rebase master(if needed).git rebase -ito squash commits (if needed).Test Plan:
First Launch
udp.port == 1900and verify that no traffic is generated by Brave.Settings Page
Upgrade
Settings UI
Sync with brave://flags
Load Media Router Component Extensionto enabledLoad Media Router Component Extensionto disabledReviewer Checklist:
After-merge Checklist:
changes has landed on.