Home | History | Annotate | Download | only in content_settings
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
      6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "base/synchronization/lock.h"
     10 #include "chrome/browser/content_settings/content_settings_observable_provider.h"
     11 #include "chrome/browser/content_settings/content_settings_origin_identifier_value_map.h"
     12 #include "chrome/common/content_settings.h"
     13 #include "content/public/browser/notification_observer.h"
     14 #include "content/public/browser/notification_registrar.h"
     15 
     16 class ExtensionService;
     17 
     18 namespace extensions {
     19 class Extension;
     20 }
     21 
     22 namespace content_settings {
     23 
     24 // A content settings provider which disables certain plugins for platform apps.
     25 class InternalExtensionProvider : public ObservableProvider,
     26                             public content::NotificationObserver {
     27  public:
     28   explicit InternalExtensionProvider(ExtensionService* extension_service);
     29 
     30   virtual ~InternalExtensionProvider();
     31 
     32   // ProviderInterface methods:
     33   virtual RuleIterator* GetRuleIterator(
     34       ContentSettingsType content_type,
     35       const ResourceIdentifier& resource_identifier,
     36       bool incognito) const OVERRIDE;
     37 
     38   virtual bool SetWebsiteSetting(
     39       const ContentSettingsPattern& primary_pattern,
     40       const ContentSettingsPattern& secondary_pattern,
     41       ContentSettingsType content_type,
     42       const ResourceIdentifier& resource_identifier,
     43       Value* value) OVERRIDE;
     44 
     45   virtual void ClearAllContentSettingsRules(ContentSettingsType content_type)
     46       OVERRIDE;
     47 
     48   virtual void ShutdownOnUIThread() OVERRIDE;
     49 
     50   // content::NotificationObserver implementation.
     51   virtual void Observe(int type,
     52                        const content::NotificationSource& source,
     53                        const content::NotificationDetails& details) OVERRIDE;
     54  private:
     55   void SetContentSettingForExtension(const extensions::Extension* extension,
     56                                      ContentSetting setting);
     57 
     58   OriginIdentifierValueMap value_map_;
     59 
     60   // Used around accesses to the |value_map_| list to guarantee thread safety.
     61   mutable base::Lock lock_;
     62   scoped_ptr<content::NotificationRegistrar> registrar_;
     63 
     64   DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider);
     65 };
     66 
     67 }  // namespace content_settings
     68 
     69 #endif  // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
     70