Add Google SafeSearch support (issue #1917)

This commit is contained in:
Marshall Greenblatt
2016-06-07 14:44:59 -04:00
parent 107d4799c4
commit 8a258afa7d
7 changed files with 68 additions and 8 deletions

View File

@ -120,6 +120,10 @@ CefURLRequestContextGetterImpl::CefURLRequestContextGetterImpl(
std::swap(protocol_handlers_, *protocol_handlers);
force_google_safesearch_.Init(prefs::kForceGoogleSafeSearch, pref_service);
force_google_safesearch_.MoveToThread(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
#if defined(OS_POSIX) && !defined(OS_ANDROID)
gsapi_library_name_ = pref_service->GetString(prefs::kGSSAPILibraryName);
#endif
@ -134,6 +138,11 @@ CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
storage_->set_proxy_service(NULL);
}
void CefURLRequestContextGetterImpl::ShutdownOnUIThread() {
CEF_REQUIRE_UIT();
force_google_safesearch_.Destroy();
}
net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
CEF_REQUIRE_IOT();
@ -152,7 +161,10 @@ net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
SetCookieStoragePath(cache_path,
settings_.persist_session_cookies ? true : false);
storage_->set_network_delegate(base::WrapUnique(new CefNetworkDelegate));
std::unique_ptr<CefNetworkDelegate> network_delegate(
new CefNetworkDelegate());
network_delegate->set_force_google_safesearch(&force_google_safesearch_);
storage_->set_network_delegate(std::move(network_delegate));
storage_->set_channel_id_service(make_scoped_ptr(
new net::ChannelIDService(