| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/web_view/internal/criwv_browser_state.h" | 5 #include "ios/web_view/internal/criwv_browser_state.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ios/web_view/internal/criwv_url_request_context_getter.h" | 21 #include "ios/web_view/internal/criwv_url_request_context_getter.h" |
| 22 #include "ios/web_view/internal/pref_names.h" | 22 #include "ios/web_view/internal/pref_names.h" |
| 23 #include "ui/base/l10n/l10n_util_mac.h" | 23 #include "ui/base/l10n/l10n_util_mac.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 const char kPreferencesFilename[] = FILE_PATH_LITERAL("Preferences"); | 26 const char kPreferencesFilename[] = FILE_PATH_LITERAL("Preferences"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace ios_web_view { | 29 namespace ios_web_view { |
| 30 | 30 |
| 31 CRIWVBrowserState::CRIWVBrowserState() : web::BrowserState() { | 31 CRIWVBrowserState::CRIWVBrowserState(bool off_the_record) |
| 32 : web::BrowserState(), off_the_record_(off_the_record) { |
| 32 CHECK(PathService::Get(base::DIR_APP_DATA, &path_)); | 33 CHECK(PathService::Get(base::DIR_APP_DATA, &path_)); |
| 33 | 34 |
| 34 request_context_getter_ = new CRIWVURLRequestContextGetter( | 35 request_context_getter_ = new CRIWVURLRequestContextGetter( |
| 35 GetStatePath(), | 36 GetStatePath(), |
| 36 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), | 37 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), |
| 37 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), | 38 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), |
| 38 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)); | 39 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)); |
| 39 | 40 |
| 40 // Initialize prefs. | 41 // Initialize prefs. |
| 41 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry = | 42 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 return prefs_.get(); | 61 return prefs_.get(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 // static | 64 // static |
| 64 CRIWVBrowserState* CRIWVBrowserState::FromBrowserState( | 65 CRIWVBrowserState* CRIWVBrowserState::FromBrowserState( |
| 65 web::BrowserState* browser_state) { | 66 web::BrowserState* browser_state) { |
| 66 return static_cast<CRIWVBrowserState*>(browser_state); | 67 return static_cast<CRIWVBrowserState*>(browser_state); |
| 67 } | 68 } |
| 68 | 69 |
| 69 bool CRIWVBrowserState::IsOffTheRecord() const { | 70 bool CRIWVBrowserState::IsOffTheRecord() const { |
| 70 return false; | 71 return off_the_record_; |
| 71 } | 72 } |
| 72 | 73 |
| 73 base::FilePath CRIWVBrowserState::GetStatePath() const { | 74 base::FilePath CRIWVBrowserState::GetStatePath() const { |
| 74 return path_; | 75 return path_; |
| 75 } | 76 } |
| 76 | 77 |
| 77 net::URLRequestContextGetter* CRIWVBrowserState::GetRequestContext() { | 78 net::URLRequestContextGetter* CRIWVBrowserState::GetRequestContext() { |
| 78 return request_context_getter_.get(); | 79 return request_context_getter_.get(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void CRIWVBrowserState::RegisterPrefs( | 82 void CRIWVBrowserState::RegisterPrefs( |
| 82 user_prefs::PrefRegistrySyncable* pref_registry) { | 83 user_prefs::PrefRegistrySyncable* pref_registry) { |
| 83 // TODO(crbug.com/679895): Find a good value for the kAcceptLanguages pref. | 84 // TODO(crbug.com/679895): Find a good value for the kAcceptLanguages pref. |
| 84 // TODO(crbug.com/679895): Pass this value to the network stack somehow, for | 85 // TODO(crbug.com/679895): Pass this value to the network stack somehow, for |
| 85 // the HTTP header. | 86 // the HTTP header. |
| 86 pref_registry->RegisterStringPref(prefs::kAcceptLanguages, | 87 pref_registry->RegisterStringPref(prefs::kAcceptLanguages, |
| 87 l10n_util::GetLocaleOverride()); | 88 l10n_util::GetLocaleOverride()); |
| 88 pref_registry->RegisterBooleanPref(prefs::kEnableTranslate, true); | 89 pref_registry->RegisterBooleanPref(prefs::kEnableTranslate, true); |
| 89 translate::TranslatePrefs::RegisterProfilePrefs(pref_registry); | 90 translate::TranslatePrefs::RegisterProfilePrefs(pref_registry); |
| 90 } | 91 } |
| 91 | 92 |
| 92 } // namespace ios_web_view | 93 } // namespace ios_web_view |
| OLD | NEW |