Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: chrome/browser/prefs/preferences_service.cc

Issue 2698913005: Re-enable preferences service access for browser+ash (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/prefs/preferences_manifest.json ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/prefs/preferences_service.h" 5 #include "chrome/browser/prefs/preferences_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 15 matching lines...) Expand all
26 26
27 PreferencesService::~PreferencesService() {} 27 PreferencesService::~PreferencesService() {}
28 28
29 void PreferencesService::PreferenceChanged(const std::string& preference_name) { 29 void PreferencesService::PreferenceChanged(const std::string& preference_name) {
30 if (setting_preferences_) 30 if (setting_preferences_)
31 return; 31 return;
32 const PrefService::Preference* pref = 32 const PrefService::Preference* pref =
33 service_->FindPreference(preference_name); 33 service_->FindPreference(preference_name);
34 std::unique_ptr<base::DictionaryValue> dictionary = 34 std::unique_ptr<base::DictionaryValue> dictionary =
35 base::MakeUnique<base::DictionaryValue>(); 35 base::MakeUnique<base::DictionaryValue>();
36 dictionary->Set(preference_name, pref->GetValue()->CreateDeepCopy()); 36 dictionary->SetWithoutPathExpansion(preference_name,
37 pref->GetValue()->CreateDeepCopy());
37 client_->OnPreferencesChanged(std::move(dictionary)); 38 client_->OnPreferencesChanged(std::move(dictionary));
38 } 39 }
39 40
40 void PreferencesService::SetPreferences( 41 void PreferencesService::SetPreferences(
41 std::unique_ptr<base::DictionaryValue> preferences) { 42 std::unique_ptr<base::DictionaryValue> preferences) {
42 DCHECK(!setting_preferences_); 43 DCHECK(!setting_preferences_);
43 // We ignore preference changes caused by us. 44 // We ignore preference changes caused by us.
44 base::AutoReset<bool> setting_preferences(&setting_preferences_, true); 45 base::AutoReset<bool> setting_preferences(&setting_preferences_, true);
45 for (base::DictionaryValue::Iterator it(*preferences); !it.IsAtEnd(); 46 for (base::DictionaryValue::Iterator it(*preferences); !it.IsAtEnd();
46 it.Advance()) { 47 it.Advance()) {
(...skipping 19 matching lines...) Expand all
66 if (!pref) { 67 if (!pref) {
67 DLOG(ERROR) << "Preference " << it << " not found.\n"; 68 DLOG(ERROR) << "Preference " << it << " not found.\n";
68 continue; 69 continue;
69 } 70 }
70 // PreferenceManager lifetime is managed by a mojo::StrongBindingPtr owned 71 // PreferenceManager lifetime is managed by a mojo::StrongBindingPtr owned
71 // by PreferenceConnectionManager. It will outlive 72 // by PreferenceConnectionManager. It will outlive
72 // |preferences_change_registrar_| which it owns. 73 // |preferences_change_registrar_| which it owns.
73 preferences_change_registrar_->Add( 74 preferences_change_registrar_->Add(
74 it, base::Bind(&PreferencesService::PreferenceChanged, 75 it, base::Bind(&PreferencesService::PreferenceChanged,
75 base::Unretained(this))); 76 base::Unretained(this)));
76 dictionary->Set(it, pref->GetValue()->CreateDeepCopy()); 77 dictionary->SetWithoutPathExpansion(it, pref->GetValue()->CreateDeepCopy());
77 } 78 }
78 79
79 if (dictionary->empty()) 80 if (dictionary->empty())
80 return; 81 return;
81 client_->OnPreferencesChanged(std::move(dictionary)); 82 client_->OnPreferencesChanged(std::move(dictionary));
82 } 83 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/preferences_manifest.json ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698