Skip to content

Commit

Permalink
Add BraveRewards feature flag for android
Browse files Browse the repository at this point in the history
  • Loading branch information
yrliou committed Oct 10, 2019
1 parent 1523c00 commit 8ecdac3
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/BraveActivity.java",
"../../brave/android/java/org/chromium/chrome/browser/BraveBadge.java",
"../../brave/android/java/org/chromium/chrome/browser/BraveFeatureList.java",
"../../brave/android/java/org/chromium/chrome/browser/BraveRelaunchUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/appmenu/BraveAppMenuPropertiesDelegateImpl.java",
"../../brave/android/java/org/chromium/chrome/browser/appmenu/BraveShieldsMenuAdapter.java",
Expand Down
10 changes: 10 additions & 0 deletions android/java/org/chromium/chrome/browser/BraveFeatureList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */

package org.chromium.chrome.browser;

public abstract class BraveFeatureList {
public static final String BRAVE_REWARDS = "BraveRewards";
}
38 changes: 38 additions & 0 deletions chromium_src/chrome/browser/android/chrome_feature_list.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */

#include "brave/common/brave_features.h"

namespace chrome {
namespace android {

namespace {

const base::Feature* kBraveFeaturesExposedToJava[] = {
&features::kBraveRewards,
};

const base::Feature* BraveFindFeatureExposedToJava(
const std::string& feature_name) {
for (size_t i = 0; i < base::size(kBraveFeaturesExposedToJava); ++i) {
if (kBraveFeaturesExposedToJava[i]->name == feature_name)
return kBraveFeaturesExposedToJava[i];
}

return nullptr;
}

} // namespace

} // namespace android
} // namespace chrome

#define BRAVE_FIND_FEATURE_EXPOSED_TO_JAVA \
const base::Feature* feature = BraveFindFeatureExposedToJava(feature_name); \
if (feature) \
return feature;

#include "../../../../../chrome/browser/android/chrome_feature_list.cc"
#undef BRAVE_FIND_FEATURE_EXPOSED_TO_JAVA
2 changes: 2 additions & 0 deletions common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ source_set("common") {
sources = [
"brave_content_client.cc",
"brave_content_client.h",
"brave_features.cc",
"brave_features.h",
"brave_isolated_worlds.h",
"brave_paths.cc",
"brave_paths.h",
Expand Down
22 changes: 22 additions & 0 deletions common/brave_features.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */

#include "brave/common/brave_features.h"
#include "build/build_config.h"

namespace features {

#if defined(OS_ANDROID)
// Flag for Brave Rewards.
#if defined(ARCH_CPU_X86_FAMILY) && defined(OFFICIAL_BUILD)
const base::Feature kBraveRewards{"BraveRewards",
base::FEATURE_DISABLED_BY_DEFAULT};
#else
const base::Feature kBraveRewards{"BraveRewards",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif
#endif // defined(OS_ANDROID)

} // namespace features
22 changes: 22 additions & 0 deletions common/brave_features.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright (c) 2019 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 http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_COMMON_BRAVE_FEATURES_H_
#define BRAVE_COMMON_BRAVE_FEATURES_H_

#include "base/component_export.h"
#include "base/feature_list.h"
#include "build/build_config.h"

namespace features {

#if defined(OS_ANDROID)
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kBraveRewards;
#endif // defined(OS_ANDROID)

} // namespace features

#endif // BRAVE_COMMON_BRAVE_FEATURES_H_
12 changes: 12 additions & 0 deletions patches/chrome-browser-android-chrome_feature_list.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/chrome/browser/android/chrome_feature_list.cc b/chrome/browser/android/chrome_feature_list.cc
index 5a292bf4825f48e20513bcf6b313e080b0db5a9a..4e696dd969003256dae6ad2aa51e34b3f5f3d7f4 100644
--- a/chrome/browser/android/chrome_feature_list.cc
+++ b/chrome/browser/android/chrome_feature_list.cc
@@ -220,6 +220,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
};

const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) {
+ BRAVE_FIND_FEATURE_EXPOSED_TO_JAVA
for (size_t i = 0; i < base::size(kFeaturesExposedToJava); ++i) {
if (kFeaturesExposedToJava[i]->name == feature_name)
return kFeaturesExposedToJava[i];

0 comments on commit 8ecdac3

Please sign in to comment.