Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature_notification_guide] Implemented notification scheduling logic
This CL adds notification scheduling logic to feature guide. - Moved the bridge and factory to live in chrome target. - The bridge will implement a Delegate interface for the service. - We will skip notifications if they are already in the scheduled queue, or have been already shown which will be handled by the Tracker. - Notifications will have a fixed hardcoded ID so that they can be easily deleted if user starts using the feature. Bug: 1277400 Change-Id: Ic8b26cd0b93e226202497646658deb338760ae76 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3320077 Reviewed-by: Min Qin <qinmin@chromium.org> Reviewed-by: Xing Liu <xingliu@chromium.org> Reviewed-by: David Trainor <dtrainor@chromium.org> Commit-Queue: Shakti Sahu <shaktisahu@chromium.org> Cr-Commit-Position: refs/heads/main@{#950183}
- Loading branch information
Shakti Sahu
authored and
Chromium LUCI CQ
committed
Dec 9, 2021
1 parent
885604e
commit bfa6585
Showing
26 changed files
with
553 additions
and
218 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
4 changes: 4 additions & 0 deletions
4
chrome/android/java/src/org/chromium/chrome/browser/feature_guide/notifications/DIR_METADATA
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,4 @@ | ||
monorail { | ||
component: "Upboarding" | ||
} | ||
team_email: "chrome-upboarding-eng@google.com" |
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
File renamed without changes.
1 change: 1 addition & 0 deletions
1
chrome/android/java/src/org/chromium/chrome/browser/feature_guide/notifications/OWNERS
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 @@ | ||
shaktisahu@chromium.org |
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
42 changes: 42 additions & 0 deletions
42
chrome/browser/feature_guide/notifications/android/feature_notification_guide_bridge.h
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,42 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_FEATURE_GUIDE_NOTIFICATIONS_ANDROID_FEATURE_NOTIFICATION_GUIDE_BRIDGE_H_ | ||
#define CHROME_BROWSER_FEATURE_GUIDE_NOTIFICATIONS_ANDROID_FEATURE_NOTIFICATION_GUIDE_BRIDGE_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/android/jni_android.h" | ||
#include "base/supports_user_data.h" | ||
#include "chrome/browser/feature_guide/notifications/feature_notification_guide_service.h" | ||
#include "chrome/browser/feature_guide/notifications/feature_type.h" | ||
|
||
using base::android::ScopedJavaGlobalRef; | ||
using base::android::ScopedJavaLocalRef; | ||
|
||
namespace feature_guide { | ||
class FeatureNotificationGuideService; | ||
|
||
// Contains JNI methods needed by the feature notification guide. | ||
class FeatureNotificationGuideBridge | ||
: public base::SupportsUserData::Data, | ||
public FeatureNotificationGuideService::Delegate { | ||
public: | ||
FeatureNotificationGuideBridge(); | ||
~FeatureNotificationGuideBridge() override; | ||
|
||
ScopedJavaLocalRef<jobject> GetJavaObj(); | ||
std::u16string GetNotificationTitle(FeatureType feature) override; | ||
std::u16string GetNotificationMessage(FeatureType feature) override; | ||
void OnNotificationClick(FeatureType feature) override; | ||
|
||
private: | ||
// A reference to the Java counterpart of this class. See | ||
// FeatureNotificationGuideBridge.java. | ||
ScopedJavaGlobalRef<jobject> java_obj_; | ||
}; | ||
|
||
} // namespace feature_guide | ||
|
||
#endif // CHROME_BROWSER_FEATURE_GUIDE_NOTIFICATIONS_ANDROID_FEATURE_NOTIFICATION_GUIDE_BRIDGE_H_ |
26 changes: 26 additions & 0 deletions
26
...feature_guide/notifications/android/feature_notification_guide_service_factory_android.cc
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,26 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/android/scoped_java_ref.h" | ||
#include "chrome/android/chrome_jni_headers/FeatureNotificationGuideServiceFactory_jni.h" | ||
#include "chrome/browser/feature_guide/notifications/android/feature_notification_guide_bridge.h" | ||
#include "chrome/browser/feature_guide/notifications/feature_notification_guide_service_factory.h" | ||
#include "chrome/browser/feature_guide/notifications/internal/feature_notification_guide_service_impl.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/profiles/profile_android.h" | ||
|
||
static base::android::ScopedJavaLocalRef<jobject> | ||
JNI_FeatureNotificationGuideServiceFactory_GetForProfile( | ||
JNIEnv* env, | ||
const base::android::JavaParamRef<jobject>& jprofile) { | ||
Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); | ||
DCHECK(profile); | ||
feature_guide::FeatureNotificationGuideServiceImpl* service = | ||
static_cast<feature_guide::FeatureNotificationGuideServiceImpl*>( | ||
feature_guide::FeatureNotificationGuideServiceFactory::GetForProfile( | ||
profile->GetOriginalProfile())); | ||
return static_cast<feature_guide::FeatureNotificationGuideBridge*>( | ||
service->GetDelegate()) | ||
->GetJavaObj(); | ||
} |
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,17 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/feature_guide/notifications/config.h" | ||
|
||
namespace feature_guide { | ||
|
||
Config::Config() = default; | ||
|
||
Config::~Config() = default; | ||
|
||
Config::Config(const Config& other) = default; | ||
|
||
Config& Config::operator=(const Config& other) = default; | ||
|
||
} // namespace feature_guide |
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,33 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_FEATURE_GUIDE_NOTIFICATIONS_CONFIG_H_ | ||
#define CHROME_BROWSER_FEATURE_GUIDE_NOTIFICATIONS_CONFIG_H_ | ||
|
||
#include <vector> | ||
|
||
#include "base/time/time.h" | ||
#include "chrome/browser/feature_guide/notifications/feature_type.h" | ||
|
||
namespace feature_guide { | ||
|
||
// Contains various finch configuration params used by the feature notification | ||
// guide. | ||
struct Config { | ||
Config(); | ||
~Config(); | ||
|
||
Config(const Config& other); | ||
Config& operator=(const Config& other); | ||
|
||
// The list of features enabled via finch for showing feature notifications. | ||
std::vector<FeatureType> enabled_features; | ||
|
||
// Relative start time for launching the notification. | ||
base::TimeDelta notification_deliver_time_delta; | ||
}; | ||
|
||
} // namespace feature_guide | ||
|
||
#endif // CHROME_BROWSER_FEATURE_GUIDE_NOTIFICATIONS_CONFIG_H_ |
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.