-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
132 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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/. | ||
|
||
import wallpaperImageUrl from '../data/dummy-branded-backgrounds/2560x1440.png' | ||
import brandingImageUrl from '../data/dummy-branded-backgrounds/branding.png' | ||
|
||
export function getHasBrandedWallpaper () { | ||
return Promise.resolve(true) | ||
} | ||
|
||
export function getBrandedWallpaper (): Promise<NewTab.BrandedWallpaper> { | ||
return Promise.resolve({ | ||
wallpaperImageUrl, | ||
logo: { | ||
image: brandingImageUrl, | ||
alt: 'my logo', | ||
destinationUrl: 'https://brave.com' | ||
} | ||
}) | ||
} | ||
|
||
const viewsTillShouldShowStorageKey = 'NTP.BrandedWallpaper.ViewsTillShouldShow' | ||
const maxViewCountUntilBranded = 4 | ||
|
||
export function getShouldShow (): boolean { | ||
const valueRaw = localStorage.getItem(viewsTillShouldShowStorageKey) | ||
const value = valueRaw ? parseInt(valueRaw) : NaN | ||
if (Number.isInteger(value)) { | ||
return value === 1 | ||
} | ||
return false | ||
} | ||
|
||
export function registerViewCount (): void { | ||
// TODO: keep this value as singleton in C++ since we want it to show on the | ||
// 2nd view (after wallpapers and branded wallpapers are enabled) and then | ||
// every 4 views | ||
const valueRaw = localStorage.getItem(viewsTillShouldShowStorageKey) | ||
const value = valueRaw ? parseInt(valueRaw) : NaN | ||
let newValue = maxViewCountUntilBranded | ||
if (Number.isInteger(value)) { | ||
if (value > 1 && value <= maxViewCountUntilBranded) { | ||
newValue = value - 1 | ||
} | ||
} | ||
localStorage.setItem(viewsTillShouldShowStorageKey, newValue.toString()) | ||
} |
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
Binary file added
BIN
+11 KB
components/brave_new_tab_ui/data/dummy-branded-backgrounds/2560x1440.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.7 KB
components/brave_new_tab_ui/data/dummy-branded-backgrounds/branding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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