Skip to content

Commit

Permalink
Goal is to securely expose Google Play Store purchase token for Brave…
Browse files Browse the repository at this point in the history
… VPN

to Brave owned websites (account.brave.com).

Part of overall change required to solve brave/brave-browser#21942
  • Loading branch information
bsclifton committed Jul 5, 2022
1 parent cf53061 commit 50edfc6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions browser/brave_vpn/brave_vpn_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ KeyedService* BraveVpnServiceFactory::BuildServiceInstanceFor(
#endif
return vpn_service;
#elif BUILDFLAG(IS_ANDROID)
// TODO(bsclifton): this needs to change here because it needs to init mojom
return new BraveVpnService(shared_url_loader_factory, callback);
#endif
}
Expand Down
15 changes: 15 additions & 0 deletions components/brave_vpn/brave_vpn_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ BraveVPNOSConnectionAPI* BraveVpnService::GetBraveVPNConnectionAPI() {
return BraveVPNOSConnectionAPI::GetInstance();
}

// NOTE(bsclifton): Desktop uses API to create a ticket.
// Android and iOS directly send an email.
void BraveVpnService::OnCreateSupportTicket(
CreateSupportTicketCallback callback,
int status,
Expand All @@ -870,6 +872,19 @@ void BraveVpnService::OnCreateSupportTicket(
}
#endif // !BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(IS_ANDROID)

void BraveVpnService::GetPurchaseToken(GetPurchaseTokenCallback callback) {
// TODO(bsclifton): get the real purchase token

std::move(callback).Run(
"oohdhbmbebmciddpbcicgnko.AO-J1OxJGS6-"
"tNYvzofx7RO2hJSEgQmi6tOrLHEB4zJ2OhsyhX3mhEe4QKS0MVxtJCBNIAlBP5jAgDPqdXDN"
"z15JhIXt5QYcIExIxe5H5ifbhAsHILlUXlE");
}

#endif

void BraveVpnService::AddObserver(
mojo::PendingRemote<mojom::ServiceObserver> observer) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Expand Down
4 changes: 4 additions & 0 deletions components/brave_vpn/brave_vpn_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class BraveVpnService :
void GetSupportData(GetSupportDataCallback callback) override;
#endif // !BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(IS_ANDROID)
void GetPurchaseToken(GetPurchaseTokenCallback callback) override;
#endif // BUILDFLAG(IS_ANDROID)

using ResponseCallback =
base::OnceCallback<void(const std::string&, bool success)>;

Expand Down
10 changes: 9 additions & 1 deletion components/brave_vpn/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@
#include "brave/components/brave_vpn/features.h"

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

namespace brave_vpn {

namespace features {

const base::Feature kBraveVPN{"BraveVPN", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kBraveVPN {
"BraveVPN",
#if BUILDFLAG(IS_ANDROID)
base::FEATURE_DISABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};

} // namespace features

Expand Down
3 changes: 3 additions & 0 deletions components/brave_vpn/mojom/brave_vpn.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ interface ServiceHandler {

[EnableIfNot=is_android]
CreateSupportTicket(string email, string subject, string body) => (bool success, string response);

[EnableIf=is_android]
GetPurchaseToken() => (string token);
};

// WebUI-side handler for requests from the browser.
Expand Down

0 comments on commit 50edfc6

Please sign in to comment.