Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_OBSERVER_H_ | |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/id_map.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "components/content_settings/core/browser/content_settings_observer.h" | |
| 12 #include "components/content_settings/core/common/content_settings.h" | |
| 13 #include "components/keyed_service/core/keyed_service.h" | |
| 14 | |
| 15 class Profile; | |
| 16 | |
| 17 class PermissionObserver : public KeyedService, | |
| 18 public content_settings::Observer { | |
| 19 public: | |
| 20 using PermissionChangeCallback = base::Callback<void(ContentSetting)>; | |
| 21 | |
| 22 explicit PermissionObserver(Profile* profile); | |
| 23 ~PermissionObserver() override; | |
| 24 | |
| 25 int Subscribe(ContentSettingsType content_type, | |
| 26 const GURL& requesting_origin, | |
| 27 const GURL& embedding_origin, | |
| 28 const PermissionChangeCallback& callback); | |
| 29 void Unsubscribe(int subscription_id); | |
| 30 | |
| 31 private: | |
| 32 struct Subscription; | |
| 33 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; | |
| 34 | |
| 35 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | |
|
Bernhard Bauer
2015/03/11 14:06:18
Add // content_settings::Observer implementation.
mlamouri (slow - plz ping)
2015/03/18 16:24:40
Done.
| |
| 36 const ContentSettingsPattern& secondary_pattern, | |
| 37 ContentSettingsType content_type, | |
| 38 std::string resource_identifier) override; | |
| 39 | |
| 40 Profile* profile_; | |
| 41 SubscriptionsMap subscriptions_; | |
| 42 | |
| 43 DISALLOW_COPY_AND_ASSIGN(PermissionObserver); | |
| 44 }; | |
| 45 | |
| 46 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_OBSERVER_H_ | |
| OLD | NEW |