Chromium Code Reviews| Index: chrome/browser/content_settings/permission_observer.h |
| diff --git a/chrome/browser/content_settings/permission_observer.h b/chrome/browser/content_settings/permission_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1afc1333fffd99954f113b1c32e08088edd284b7 |
| --- /dev/null |
| +++ b/chrome/browser/content_settings/permission_observer.h |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_OBSERVER_H_ |
| +#define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_OBSERVER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/id_map.h" |
| +#include "base/macros.h" |
| +#include "components/content_settings/core/browser/content_settings_observer.h" |
| +#include "components/content_settings/core/common/content_settings.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| + |
| +class Profile; |
| + |
| +class PermissionObserver : public KeyedService, |
| + public content_settings::Observer { |
| + public: |
| + using PermissionChangeCallback = base::Callback<void(ContentSetting)>; |
| + |
| + explicit PermissionObserver(Profile* profile); |
| + ~PermissionObserver() override; |
| + |
| + int Subscribe(ContentSettingsType content_type, |
| + const GURL& requesting_origin, |
| + const GURL& embedding_origin, |
| + const PermissionChangeCallback& callback); |
| + void Unsubscribe(int subscription_id); |
| + |
| + private: |
| + struct Subscription; |
| + using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; |
| + |
| + 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.
|
| + const ContentSettingsPattern& secondary_pattern, |
| + ContentSettingsType content_type, |
| + std::string resource_identifier) override; |
| + |
| + Profile* profile_; |
| + SubscriptionsMap subscriptions_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PermissionObserver); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_OBSERVER_H_ |