Skip to content

Commit

Permalink
New Tab Page: add brave://flags feature to force dummy content for Br…
Browse files Browse the repository at this point in the history
…anded Wallpaper
  • Loading branch information
antonok-edm authored and petemill committed Dec 12, 2019
1 parent 7c7eb7a commit 4c3165e
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "brave/common/pref_names.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "content/public/browser/browser_context.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" // NOLINT
Expand Down Expand Up @@ -77,7 +78,9 @@ NewTabPageBrandedViewCounter::NewTabPageBrandedViewCounter(Profile* profile)
// TODO(petemill): Update the private var when the data source gets
// new content, when we have a data source!
// Set demo wallpaper if a flag is set.
current_wallpaper_ = GetDemoWallpaper();
if (base::FeatureList::IsEnabled(features::kBraveNTPBrandedWallpaperDemo)) {
current_wallpaper_ = GetDemoWallpaper();
}
// Observe relevant preferences that affect whether we should show
// wallpaper or count views.
SetShouldShowFromPreferences();
Expand Down
6 changes: 6 additions & 0 deletions chromium_src/chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* 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/. */

#define BRAVE_FEATURE_ENTRIES \
{"brave-ntp-branded-wallpaper-demo", \
flag_descriptions::kBraveNTPBrandedWallpaperDemoName, \
flag_descriptions::kBraveNTPBrandedWallpaperDemoDescription, kOsAll, \
FEATURE_VALUE_TYPE(features::kBraveNTPBrandedWallpaperDemo)},

#define SetFeatureEntryEnabled SetFeatureEntryEnabled_ChromiumImpl
#include "../../../../chrome/browser/about_flags.cc" // NOLINT
#include "../../../../components/flags_ui/flags_state.cc" // NOLINT
Expand Down
15 changes: 15 additions & 0 deletions chromium_src/chrome/browser/flag_descriptions.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* 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 "../../../../chrome/browser/flag_descriptions.cc"

namespace flag_descriptions {
const char kBraveNTPBrandedWallpaperDemoName[] =
"New Tab Page Demo Branded Wallpaper";
const char kBraveNTPBrandedWallpaperDemoDescription[] =
"Force dummy data for the Branded Wallpaper New Tab Page Experience. "
"View rate and user opt-in conditionals will still be followed to decide "
"when to display the Branded Wallpaper.";
}
16 changes: 16 additions & 0 deletions chromium_src/chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* 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_CHROMIUM_SRC_CHROME_BROWSER_FLAG_DESCRIPTIONS_H_
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_FLAG_DESCRIPTIONS_H_

#include "../../../../chrome/browser/flag_descriptions.h"

namespace flag_descriptions {
extern const char kBraveNTPBrandedWallpaperDemoName[];
extern const char kBraveNTPBrandedWallpaperDemoDescription[];
}

#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_FLAG_DESCRIPTIONS_H_
12 changes: 12 additions & 0 deletions chromium_src/chrome/common/chrome_features.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* 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 "../../../../chrome/common/chrome_features.cc"

namespace features {
const base::Feature kBraveNTPBrandedWallpaperDemo{
"BraveNTPBrandedWallpaperDemoName",
base::FEATURE_DISABLED_BY_DEFAULT};
}
16 changes: 16 additions & 0 deletions chromium_src/chrome/common/chrome_features.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* 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_CHROMIUM_SRC_CHROME_COMMON_CHROME_FEATURES_H_
#define BRAVE_CHROMIUM_SRC_CHROME_COMMON_CHROME_FEATURES_H_

#include "../../../../chrome/common/chrome_features.h"

namespace features {
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kBraveNTPBrandedWallpaperDemo;
}

#endif // BRAVE_CHROMIUM_SRC_CHROME_COMMON_CHROME_FEATURES_H_
8 changes: 8 additions & 0 deletions patches/chrome-browser-about_flags.cc.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ index 0ab55be2f96853137cec8928621360e9f639b467..34e01378c8e413af12399bc3ca30188b

const FeatureEntry::Choice kPassiveListenersChoices[] = {
{flags_ui::kGenericExperimentChoiceDefault, "", ""},
@@ -4688,6 +4688,7 @@ const FeatureEntry kFeatureEntries[] = {
// "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag
// Histograms" in tools/metrics/histograms/README.md (run the
// AboutFlagsHistogramTest unit test to verify this process).
+ BRAVE_FEATURE_ENTRIES
};

class FlagsStateSingleton {

0 comments on commit 4c3165e

Please sign in to comment.