| 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/extensions/api/content_settings/content_settings_store.
h" | 5 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 | 349 |
| 350 void ContentSettingsStore::RemoveObserver(Observer* observer) { | 350 void ContentSettingsStore::RemoveObserver(Observer* observer) { |
| 351 DCHECK(OnCorrectThread()); | 351 DCHECK(OnCorrectThread()); |
| 352 observers_.RemoveObserver(observer); | 352 observers_.RemoveObserver(observer); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void ContentSettingsStore::NotifyOfContentSettingChanged( | 355 void ContentSettingsStore::NotifyOfContentSettingChanged( |
| 356 const std::string& extension_id, | 356 const std::string& extension_id, |
| 357 bool incognito) { | 357 bool incognito) { |
| 358 FOR_EACH_OBSERVER( | 358 for (auto& observer : observers_) |
| 359 ContentSettingsStore::Observer, | 359 observer.OnContentSettingChanged(extension_id, incognito); |
| 360 observers_, | |
| 361 OnContentSettingChanged(extension_id, incognito)); | |
| 362 } | 360 } |
| 363 | 361 |
| 364 bool ContentSettingsStore::OnCorrectThread() { | 362 bool ContentSettingsStore::OnCorrectThread() { |
| 365 // If there is no UI thread, we're most likely in a unit test. | 363 // If there is no UI thread, we're most likely in a unit test. |
| 366 return !BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 364 return !BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| 367 BrowserThread::CurrentlyOn(BrowserThread::UI); | 365 BrowserThread::CurrentlyOn(BrowserThread::UI); |
| 368 } | 366 } |
| 369 | 367 |
| 370 ContentSettingsStore::ExtensionEntryMap::iterator | 368 ContentSettingsStore::ExtensionEntryMap::iterator |
| 371 ContentSettingsStore::FindEntry(const std::string& ext_id) { | 369 ContentSettingsStore::FindEntry(const std::string& ext_id) { |
| 372 ExtensionEntryMap::iterator i; | 370 ExtensionEntryMap::iterator i; |
| 373 for (i = entries_.begin(); i != entries_.end(); ++i) { | 371 for (i = entries_.begin(); i != entries_.end(); ++i) { |
| 374 if (i->second->id == ext_id) | 372 if (i->second->id == ext_id) |
| 375 return i; | 373 return i; |
| 376 } | 374 } |
| 377 return entries_.end(); | 375 return entries_.end(); |
| 378 } | 376 } |
| 379 | 377 |
| 380 ContentSettingsStore::ExtensionEntryMap::const_iterator | 378 ContentSettingsStore::ExtensionEntryMap::const_iterator |
| 381 ContentSettingsStore::FindEntry(const std::string& ext_id) const { | 379 ContentSettingsStore::FindEntry(const std::string& ext_id) const { |
| 382 ExtensionEntryMap::const_iterator i; | 380 ExtensionEntryMap::const_iterator i; |
| 383 for (i = entries_.begin(); i != entries_.end(); ++i) { | 381 for (i = entries_.begin(); i != entries_.end(); ++i) { |
| 384 if (i->second->id == ext_id) | 382 if (i->second->id == ext_id) |
| 385 return i; | 383 return i; |
| 386 } | 384 } |
| 387 return entries_.end(); | 385 return entries_.end(); |
| 388 } | 386 } |
| 389 | 387 |
| 390 } // namespace extensions | 388 } // namespace extensions |
| OLD | NEW |