Skip to content
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

Issue 2301: Enable push messaging #3390

Merged
merged 2 commits into from Oct 4, 2019
Merged

Issue 2301: Enable push messaging #3390

merged 2 commits into from Oct 4, 2019

Conversation

jumde
Copy link
Contributor

@jumde jumde commented Sep 9, 2019

fix brave/brave-browser#2301

Submitter Checklist:

Test Plan:

  1. Navigate to brave://settings/privacy
  2. Enable Use Google Services for Push Messaging
  3. Relaunch
  4. Navigate to:

and verify push messaging works.

  1. Navigate to brave://settings/privacy
  2. Disable Use Google Services for Push Messaging and relaunch
  3. Verify that push notifications don't work after push messaging is disabled.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

PushMessagingServiceImpl* push_service =
PushMessagingServiceFactory::GetForProfile(profile);
- push_service->IncreasePushSubscriptionCount(count, false /* is_pending */);
+ if (push_service) { push_service->IncreasePushSubscriptionCount(count, false /* is_pending */); }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetForProfile can return NULL, upstream issue here: https://bugs.chromium.org/p/chromium/issues/detail?id=999665

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only place where the check is needed? I'm concerned about https://bugs.chromium.org/p/chromium/issues/detail?id=999665#c2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this patch, given that this check is enough. I'm just not sure if we will not hit any other null push_service pointers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -7,12 +7,18 @@

#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"

namespace content {
class WebUIDataSource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing is not needed

@@ -30,6 +30,7 @@ int OnBeforeURLRequest_StaticRedirectWork(
int OnBeforeURLRequest_StaticRedirectWorkForGURL(
const GURL& request_url,
GURL* new_url) {
LOG(INFO) << "URL: " << request_url.spec();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too much for production, I hope this is something temporary :)

@jumde jumde force-pushed the push_messaging branch 3 times, most recently from 07acad0 to fae9111 Compare September 19, 2019 11:12
@jumde jumde self-assigned this Sep 21, 2019
@jumde jumde changed the title [WIP] Issue 2301: Enable push messaging Issue 2301: Enable push messaging Sep 21, 2019
@jumde jumde force-pushed the push_messaging branch 3 times, most recently from 3050dd0 to e138d62 Compare September 23, 2019 22:34
std::string group_name =
base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName);
- return !base::StartsWith(group_name, kInstanceIDFieldTrialDisabledGroupPrefix,
+ return true || !base::StartsWith(group_name, kInstanceIDFieldTrialDisabledGroupPrefix,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, either we're not setting this field trial in which case it won't start with "Disabled" or we should set it to something that doesn't start with "Disabled" if we always want it to return true. If we did need to patch it should return true; on its own line before the original return, but it doesn't look to me like we should have to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my bad, was trying to refactor the original patch. Will fix. Sorry about this.

@bsclifton
Copy link
Member

bsclifton commented Sep 24, 2019

If a relaunch is required (seems to be, from my testing) should this present a similar banner to what was done for Chromecast (Media Router)? (cc: @rebron)
Screen Shot 2019-09-23 at 11 26 43 PM

It does have the Relaunch button, which is a pretty nice visual indicator 😄
Screen Shot 2019-09-24 at 2 27 33 AM

@@ -389,6 +389,10 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_SETTINGS_WEBRTC_POLICY_DISABLE_NON_PROXIED_UDP" desc="Select value">
Disable non-proxied UDP
</message>
<!-- Push Messaging -->
<message name="IDS_SETTINGS_PUSH_MESSAGING" desc="Select value">
Use GCM/FCM for Push Messaging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rebron what do you think of this text? Is this good enough for users? or should this be simplified a bit?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to "Use Google Services for Push Messaging"

bsclifton
bsclifton previously approved these changes Sep 24, 2019
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran through test plan - works great 😄 Code changes look good too, pending review feedback from @bridiver and @rebron (some comments left)

Great job on this 😄👍

@jumde
Copy link
Contributor Author

jumde commented Sep 24, 2019

If a relaunch is required (seems to be, from my testing) should this present a similar banner to what was done for Chromecast (Media Router)? (cc: @rebron)
Screen Shot 2019-09-23 at 11 26 43 PM

It does have the Relaunch button, which is a pretty nice visual indicator 😄
Screen Shot 2019-09-24 at 2 27 33 AM

cc: @petemill

@rebron
Copy link
Collaborator

rebron commented Sep 24, 2019

If a relaunch is required (seems to be, from my testing) should this present a similar banner to what was done for Chromecast (Media Router)? (cc: @rebron)
Screen Shot 2019-09-23 at 11 26 43 PM

It does have the Relaunch button, which is a pretty nice visual indicator 😄

Yes. We should do the same UE as Chromecast (Media Router). Sounds like that's already the case.

@diracdeltas
Copy link
Member

sec review: lgtm with the current text and the switch off by default

iefremov
iefremov previously approved these changes Sep 30, 2019
@@ -161,6 +163,8 @@ source_set("ui") {
"//chrome/app:command_ids",
"//chrome/common",
"//components/prefs",
"//components/gcm_driver:gcm_driver",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't need gcm_driver anymore, but brave_gcm_driver target does

@@ -153,6 +154,7 @@ source_set("ui") {
"//brave/browser/tor",
"//brave/common",
"//brave/components/brave_adblock_ui:generated_resources",
"//brave/components/brave_gcm_driver:brave_gcm_driver",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:brave_gcm_driver is redundant. //brave/components/brave_gcm_driver is all you need


namespace gcm {

static bool gcm_channel_enabled_ = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already discussed in DM, but can't have a static var for a per-profile setting

@jumde
Copy link
Contributor Author

jumde commented Oct 2, 2019

How does it differ from the original test? I'm not sure if copypasting it is better than patching the original

@iefremov - One line change to enable the pushMessaging pref. I try to avoid patching as much as possible.

#include "brave/components/brave_gcm_driver/brave_gcm_channel_status_syncer.h"

#include "base/memory/ptr_util.h"
#include "chrome/browser/profiles/profile.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't have dependencies on chrome/browser inside a component. This class should be moved to brave/browser/gcm_driver/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@bridiver bridiver Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need ^^ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we are capturing the initial pref status using the subclass BraveGCMChannelStatusSyncer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't have dependencies on chrome/browser inside a component. This class should be moved to brave/browser/gcm_driver/

will move.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like we don't need the BraveGCMChannelStatusSyncer class at all anymore and only need BraveGCMChannelStatus?

user_agent,
url_loader_factory) {
// At destruction all the objects will be cleaned up by SupportsUserData
BraveGCMChannelStatusSyncer::status =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct, you've created a static BraveGCMChannelStatus* here. You should be creating a unique_ptr in GetForProfile if profile->GetUserData(kBraveGCMStatusKey) is null

@jumde jumde force-pushed the push_messaging branch 2 times, most recently from 4bf7dcf to b475918 Compare October 2, 2019 20:06
import("//build/buildflag_header.gni")
import("//components/gcm_driver/config.gni")

static_library("gcm_driver") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a static_library instead of source_set?

gcm::BraveGCMChannelStatus::GetForProfile(profile);

DCHECK(gcm_channel_status);
data_source->AddBoolean("pushMessagingEnabledAtStartup",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this just be true if USE_GCM_FROM_PLATFORM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@jumde jumde force-pushed the push_messaging branch 2 times, most recently from efeffcd to 8fd3083 Compare October 3, 2019 21:00
bridiver
bridiver previously approved these changes Oct 3, 2019
@jumde
Copy link
Contributor Author

jumde commented Oct 4, 2019

https://bugs.chromium.org/p/chromium/issues/detail?id=1011244 - Debug failure on receiving push notifications on some site.

@bsclifton bsclifton merged commit cd3df93 into master Oct 4, 2019
@bsclifton bsclifton deleted the push_messaging branch October 4, 2019 17:21
@jumde jumde added this to the 0.72.x - Nightly milestone Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants