This source file includes following definitions.
- IsHistorySyncEnabled
- GetInstance
- GetForProfile
- BuildServiceInstanceFor
#include "chrome/browser/history/web_history_service_factory.h"
#include "base/command_line.h"
#include "chrome/browser/content_settings/cookie_settings.h"
#include "chrome/browser/history/web_history_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace {
bool IsHistorySyncEnabled(Profile* profile) {
ProfileSyncService* sync =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
return sync &&
sync->sync_initialized() &&
sync->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES);
}
}
WebHistoryServiceFactory* WebHistoryServiceFactory::GetInstance() {
return Singleton<WebHistoryServiceFactory>::get();
}
history::WebHistoryService* WebHistoryServiceFactory::GetForProfile(
Profile* profile) {
if (IsHistorySyncEnabled(profile)) {
return static_cast<history::WebHistoryService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
return NULL;
}
KeyedService* WebHistoryServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);
return IsHistorySyncEnabled(profile) ?
new history::WebHistoryService(profile) : NULL;
}
WebHistoryServiceFactory::WebHistoryServiceFactory()
: BrowserContextKeyedServiceFactory(
"WebHistoryServiceFactory",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(CookieSettings::Factory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
}
WebHistoryServiceFactory::~WebHistoryServiceFactory() {
}