Commit 92b77497 authored by Anna Malova's avatar Anna Malova Committed by Commit Bot

[aw] Move media_drm_storage pref to profile prefs from local_state.

The bug was introduced when aw_browser_context prefs
were splited up into profile-specific vs global.

media_drm_storage is supposed to be profile-specific.

Bug: 986965
Change-Id: I29b20f8e77fbe0a3dfa3472ac963bbb096fe3a8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720240
Commit-Queue: Anna Malova <amalova@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682213}
parent 1e3212f0
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "components/autofill/core/browser/autocomplete_history_manager.h" #include "components/autofill/core/browser/autocomplete_history_manager.h"
#include "components/autofill/core/common/autofill_prefs.h" #include "components/autofill/core/common/autofill_prefs.h"
#include "components/cdm/browser/media_drm_storage_impl.h"
#include "components/download/public/common/in_progress_download_manager.h" #include "components/download/public/common/in_progress_download_manager.h"
#include "components/keyed_service/core/simple_key_map.h" #include "components/keyed_service/core/simple_key_map.h"
#include "components/policy/core/browser/browser_policy_connector_base.h" #include "components/policy/core/browser/browser_policy_connector_base.h"
...@@ -53,6 +54,7 @@ ...@@ -53,6 +54,7 @@
#include "content/public/browser/ssl_host_state_delegate.h" #include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "media/mojo/buildflags.h"
#include "net/proxy_resolution/proxy_config_service_android.h" #include "net/proxy_resolution/proxy_config_service_android.h"
#include "net/proxy_resolution/proxy_resolution_service.h" #include "net/proxy_resolution/proxy_resolution_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
...@@ -122,6 +124,17 @@ base::FilePath AwBrowserContext::GetCacheDir() { ...@@ -122,6 +124,17 @@ base::FilePath AwBrowserContext::GetCacheDir() {
return cache_path; return cache_path;
} }
base::FilePath AwBrowserContext::GetPrefStorePath() {
FilePath pref_store_path;
base::PathService::Get(base::DIR_ANDROID_APP_DATA, &pref_store_path);
// TODO(amalova): Assign a proper file path for non-default profiles
// when we support multiple profiles
pref_store_path =
pref_store_path.Append(FILE_PATH_LITERAL("Default/Preferences"));
return pref_store_path;
}
// static // static
base::FilePath AwBrowserContext::GetCookieStorePath() { base::FilePath AwBrowserContext::GetCookieStorePath() {
FilePath cookie_store_path; FilePath cookie_store_path;
...@@ -162,6 +175,10 @@ void AwBrowserContext::RegisterPrefs(PrefRegistrySimple* registry) { ...@@ -162,6 +175,10 @@ void AwBrowserContext::RegisterPrefs(PrefRegistrySimple* registry) {
false); false);
registry->RegisterBooleanPref(autofill::prefs::kAutofillCreditCardEnabled, registry->RegisterBooleanPref(autofill::prefs::kAutofillCreditCardEnabled,
false); false);
#if BUILDFLAG(ENABLE_MOJO_CDM)
cdm::MediaDrmStorageImpl::RegisterProfilePrefs(registry);
#endif
} }
void AwBrowserContext::CreateUserPrefService() { void AwBrowserContext::CreateUserPrefService() {
...@@ -172,8 +189,16 @@ void AwBrowserContext::CreateUserPrefService() { ...@@ -172,8 +189,16 @@ void AwBrowserContext::CreateUserPrefService() {
RegisterPrefs(pref_registry.get()); RegisterPrefs(pref_registry.get());
PrefServiceFactory pref_service_factory; PrefServiceFactory pref_service_factory;
pref_service_factory.set_user_prefs(
base::MakeRefCounted<InMemoryPrefStore>()); std::set<std::string> persistent_prefs;
// Persisted to avoid having to provision MediaDrm every time the
// application tries to play protected content after restart.
persistent_prefs.insert(cdm::prefs::kMediaDrmStorage);
pref_service_factory.set_user_prefs(base::MakeRefCounted<SegregatedPrefStore>(
base::MakeRefCounted<InMemoryPrefStore>(),
base::MakeRefCounted<JsonPrefStore>(GetPrefStorePath()), persistent_prefs,
/*validation_delegate=*/nullptr));
policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry.get()); policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry.get());
pref_service_factory.set_managed_prefs( pref_service_factory.set_managed_prefs(
...@@ -185,9 +210,23 @@ void AwBrowserContext::CreateUserPrefService() { ...@@ -185,9 +210,23 @@ void AwBrowserContext::CreateUserPrefService() {
user_pref_service_ = pref_service_factory.Create(pref_registry); user_pref_service_ = pref_service_factory.Create(pref_registry);
// TODO(amalova): Do not call this method for non-default profile.
MigrateLocalStatePrefs();
user_prefs::UserPrefs::Set(this, user_pref_service_.get()); user_prefs::UserPrefs::Set(this, user_pref_service_.get());
} }
void AwBrowserContext::MigrateLocalStatePrefs() {
PrefService* local_state = AwBrowserProcess::GetInstance()->local_state();
if (!local_state->HasPrefPath(cdm::prefs::kMediaDrmStorage)) {
return;
}
user_pref_service_->Set(cdm::prefs::kMediaDrmStorage,
*(local_state->Get(cdm::prefs::kMediaDrmStorage)));
local_state->ClearPref(cdm::prefs::kMediaDrmStorage);
}
// static // static
std::vector<std::string> AwBrowserContext::GetAuthSchemes() { std::vector<std::string> AwBrowserContext::GetAuthSchemes() {
// In Chrome this is configurable via the AuthSchemes policy. For WebView // In Chrome this is configurable via the AuthSchemes policy. For WebView
......
...@@ -66,6 +66,7 @@ class AwBrowserContext : public content::BrowserContext, ...@@ -66,6 +66,7 @@ class AwBrowserContext : public content::BrowserContext,
content::WebContents* web_contents); content::WebContents* web_contents);
base::FilePath GetCacheDir(); base::FilePath GetCacheDir();
base::FilePath GetPrefStorePath();
static base::FilePath GetCookieStorePath(); static base::FilePath GetCookieStorePath();
static base::FilePath GetContextStoragePath(); static base::FilePath GetContextStoragePath();
...@@ -121,6 +122,7 @@ class AwBrowserContext : public content::BrowserContext, ...@@ -121,6 +122,7 @@ class AwBrowserContext : public content::BrowserContext,
private: private:
void CreateUserPrefService(); void CreateUserPrefService();
void MigrateLocalStatePrefs();
// The file path where data for this context is persisted. // The file path where data for this context is persisted.
base::FilePath context_storage_path_; base::FilePath context_storage_path_;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "components/autofill/core/common/autofill_prefs.h" #include "components/autofill/core/common/autofill_prefs.h"
#include "components/cdm/browser/media_drm_storage_impl.h"
#include "components/metrics/metrics_pref_names.h" #include "components/metrics/metrics_pref_names.h"
#include "components/metrics/metrics_service.h" #include "components/metrics/metrics_service.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
...@@ -38,7 +37,6 @@ ...@@ -38,7 +37,6 @@
#include "components/variations/pref_names.h" #include "components/variations/pref_names.h"
#include "components/variations/service/safe_seed_manager.h" #include "components/variations/service/safe_seed_manager.h"
#include "components/variations/service/variations_service.h" #include "components/variations/service/variations_service.h"
#include "media/mojo/buildflags.h"
#include "services/preferences/tracked/segregated_pref_store.h" #include "services/preferences/tracked/segregated_pref_store.h"
namespace android_webview { namespace android_webview {
...@@ -48,9 +46,6 @@ namespace { ...@@ -48,9 +46,6 @@ namespace {
// These prefs go in the JsonPrefStore, and will persist across runs. Other // These prefs go in the JsonPrefStore, and will persist across runs. Other
// prefs go in the InMemoryPrefStore, and will be lost when the process ends. // prefs go in the InMemoryPrefStore, and will be lost when the process ends.
const char* const kPersistentPrefsWhitelist[] = { const char* const kPersistentPrefsWhitelist[] = {
// Persisted to avoid having to provision MediaDrm every time the
// application tries to play protected content after restart.
cdm::prefs::kMediaDrmStorage,
// Randomly-generated GUID which pseudonymously identifies uploaded metrics. // Randomly-generated GUID which pseudonymously identifies uploaded metrics.
metrics::prefs::kMetricsClientID, metrics::prefs::kMetricsClientID,
// Random seed value for variation's entropy providers. Used to assign // Random seed value for variation's entropy providers. Used to assign
...@@ -77,9 +72,6 @@ std::unique_ptr<PrefService> CreatePrefService() { ...@@ -77,9 +72,6 @@ std::unique_ptr<PrefService> CreatePrefService() {
metrics::MetricsService::RegisterPrefs(pref_registry.get()); metrics::MetricsService::RegisterPrefs(pref_registry.get());
variations::VariationsService::RegisterPrefs(pref_registry.get()); variations::VariationsService::RegisterPrefs(pref_registry.get());
#if BUILDFLAG(ENABLE_MOJO_CDM)
cdm::MediaDrmStorageImpl::RegisterProfilePrefs(pref_registry.get());
#endif
AwBrowserProcess::RegisterNetworkContextLocalStatePrefs(pref_registry.get()); AwBrowserProcess::RegisterNetworkContextLocalStatePrefs(pref_registry.get());
PrefServiceFactory pref_service_factory; PrefServiceFactory pref_service_factory;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment