-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6828 from brave/crypto-dot-com-1.16
Adding Crypto.com widget to the NTP [1.16]
- Loading branch information
Showing
68 changed files
with
3,680 additions
and
23 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
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,47 @@ | ||
/* Copyright (c) 2020 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/browser/crypto_dot_com/crypto_dot_com_service_factory.h" | ||
|
||
#include "brave/browser/profiles/profile_util.h" | ||
#include "brave/components/crypto_dot_com/browser/crypto_dot_com_service.h" | ||
#include "chrome/browser/profiles/incognito_helpers.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "components/keyed_service/content/browser_context_dependency_manager.h" | ||
|
||
// static | ||
CryptoDotComServiceFactory* CryptoDotComServiceFactory::GetInstance() { | ||
return base::Singleton<CryptoDotComServiceFactory>::get(); | ||
} | ||
|
||
// static | ||
CryptoDotComService*CryptoDotComServiceFactory::GetForProfile( | ||
Profile* profile) { | ||
if (!brave::IsRegularProfile(profile)) { | ||
return nullptr; | ||
} | ||
|
||
return static_cast<CryptoDotComService*>( | ||
GetInstance()->GetServiceForBrowserContext(profile, true)); | ||
} | ||
|
||
CryptoDotComServiceFactory::CryptoDotComServiceFactory() | ||
: BrowserContextKeyedServiceFactory( | ||
"CryptoDotComService", | ||
BrowserContextDependencyManager::GetInstance()) { | ||
} | ||
|
||
CryptoDotComServiceFactory::~CryptoDotComServiceFactory() { | ||
} | ||
|
||
KeyedService* CryptoDotComServiceFactory::BuildServiceInstanceFor( | ||
content::BrowserContext* context) const { | ||
return new CryptoDotComService(Profile::FromBrowserContext(context)); | ||
} | ||
|
||
content::BrowserContext* CryptoDotComServiceFactory::GetBrowserContextToUse( | ||
content::BrowserContext* context) const { | ||
return chrome::GetBrowserContextRedirectedInIncognito(context); | ||
} |
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,35 @@ | ||
/* Copyright (c) 2020 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_BROWSER_CRYPTO_DOT_COM_CRYPTO_DOT_COM_SERVICE_FACTORY_H_ | ||
#define BRAVE_BROWSER_CRYPTO_DOT_COM_CRYPTO_DOT_COM_SERVICE_FACTORY_H_ | ||
|
||
#include "base/memory/singleton.h" | ||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" | ||
|
||
class CryptoDotComService; | ||
class Profile; | ||
|
||
class CryptoDotComServiceFactory : public BrowserContextKeyedServiceFactory { | ||
public: | ||
static CryptoDotComService* GetForProfile(Profile* profile); | ||
static CryptoDotComServiceFactory* GetInstance(); | ||
|
||
private: | ||
friend struct base::DefaultSingletonTraits<CryptoDotComServiceFactory>; | ||
|
||
CryptoDotComServiceFactory(); | ||
~CryptoDotComServiceFactory() override; | ||
|
||
// BrowserContextKeyedServiceFactory overrides: | ||
KeyedService* BuildServiceInstanceFor( | ||
content::BrowserContext* context) const override; | ||
content::BrowserContext* GetBrowserContextToUse( | ||
content::BrowserContext* context) const override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(CryptoDotComServiceFactory); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_CRYPTO_DOT_COM_CRYPTO_DOT_COM_SERVICE_FACTORY_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.