cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ios / chrome / browser / content_settings / cookie_settings_factory.cc
blob2d7c8c8d95ea871c6bd51245e71df32d8233bcc9
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/content_settings/cookie_settings_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/content_settings/core/browser/cookie_settings.h"
9 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
10 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
11 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
13 namespace {
14 const char kDummyExtensionScheme[] = ":no-extension-scheme:";
17 namespace ios {
19 // static
20 scoped_refptr<content_settings::CookieSettings>
21 CookieSettingsFactory::GetForBrowserState(
22 ios::ChromeBrowserState* browser_state) {
23 return static_cast<content_settings::CookieSettings*>(
24 GetInstance()->GetServiceForBrowserState(browser_state, true).get());
27 // static
28 CookieSettingsFactory* CookieSettingsFactory::GetInstance() {
29 return Singleton<CookieSettingsFactory>::get();
32 CookieSettingsFactory::CookieSettingsFactory()
33 : RefcountedBrowserStateKeyedServiceFactory(
34 "CookieSettings",
35 BrowserStateDependencyManager::GetInstance()) {
38 CookieSettingsFactory::~CookieSettingsFactory() {
41 void CookieSettingsFactory::RegisterBrowserStatePrefs(
42 user_prefs::PrefRegistrySyncable* registry) {
43 content_settings::CookieSettings::RegisterProfilePrefs(registry);
46 web::BrowserState* CookieSettingsFactory::GetBrowserStateToUse(
47 web::BrowserState* context) const {
48 // The incognito browser state has its own content settings map. Therefore, it
49 // should get its own CookieSettings.
50 return GetBrowserStateOwnInstanceInIncognito(context);
53 scoped_refptr<RefcountedKeyedService>
54 CookieSettingsFactory::BuildServiceInstanceFor(
55 web::BrowserState* context) const {
56 ios::ChromeBrowserState* browser_state =
57 ios::ChromeBrowserState::FromBrowserState(context);
58 return new content_settings::CookieSettings(
59 browser_state->GetHostContentSettingsMap(), browser_state->GetPrefs(),
60 kDummyExtensionScheme);
63 } // namespace ios