OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/settings/cros_settings.h" | 5 #include "chrome/browser/chromeos/settings/cros_settings.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 settings_observers_[path] = | 321 settings_observers_[path] = |
322 base::MakeUnique<base::CallbackList<void(void)>>(); | 322 base::MakeUnique<base::CallbackList<void(void)>>(); |
323 registry = settings_observers_[path].get(); | 323 registry = settings_observers_[path].get(); |
324 } else { | 324 } else { |
325 registry = observer_iterator->second.get(); | 325 registry = observer_iterator->second.get(); |
326 } | 326 } |
327 | 327 |
328 return registry->Add(callback); | 328 return registry->Add(callback); |
329 } | 329 } |
330 | 330 |
| 331 void CrosSettings::ClearSettingsObservers(const std::string& path) { |
| 332 settings_observers_[path]->ClearAll(); |
| 333 } |
| 334 |
331 CrosSettingsProvider* CrosSettings::GetProvider( | 335 CrosSettingsProvider* CrosSettings::GetProvider( |
332 const std::string& path) const { | 336 const std::string& path) const { |
333 for (size_t i = 0; i < providers_.size(); ++i) { | 337 for (size_t i = 0; i < providers_.size(); ++i) { |
334 if (providers_[i]->HandlesSetting(path)) | 338 if (providers_[i]->HandlesSetting(path)) |
335 return providers_[i].get(); | 339 return providers_[i].get(); |
336 } | 340 } |
337 return nullptr; | 341 return nullptr; |
338 } | 342 } |
339 | 343 |
340 void CrosSettings::FireObservers(const std::string& path) { | 344 void CrosSettings::FireObservers(const std::string& path) { |
341 DCHECK(CalledOnValidThread()); | 345 DCHECK(CalledOnValidThread()); |
342 auto observer_iterator = settings_observers_.find(path); | 346 auto observer_iterator = settings_observers_.find(path); |
343 if (observer_iterator == settings_observers_.end()) | 347 if (observer_iterator == settings_observers_.end()) |
344 return; | 348 return; |
345 | 349 |
346 observer_iterator->second->Notify(); | 350 observer_iterator->second->Notify(); |
347 } | 351 } |
348 | 352 |
349 ScopedTestCrosSettings::ScopedTestCrosSettings() { | 353 ScopedTestCrosSettings::ScopedTestCrosSettings() { |
350 CrosSettings::Initialize(); | 354 CrosSettings::Initialize(); |
351 } | 355 } |
352 | 356 |
353 ScopedTestCrosSettings::~ScopedTestCrosSettings() { | 357 ScopedTestCrosSettings::~ScopedTestCrosSettings() { |
354 CrosSettings::Shutdown(); | 358 CrosSettings::Shutdown(); |
355 } | 359 } |
356 | 360 |
357 } // namespace chromeos | 361 } // namespace chromeos |
OLD | NEW |