Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome/browser/extensions/extension_content_settings_store.h

Issue 6927028: TODO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_content_settings_store.h
diff --git a/chrome/browser/extensions/extension_content_settings_store.h b/chrome/browser/extensions/extension_content_settings_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..6de6adbd33700f0e8ddfab5af54a9ea1cc99bcfe
--- /dev/null
+++ b/chrome/browser/extensions/extension_content_settings_store.h
@@ -0,0 +1,146 @@
+// Copyright (c) 2011 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_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_
+
+#include <list>
+#include <map>
+#include <string>
+
+#include "base/observer_list.h"
+#include "base/time.h"
+#include "base/tuple.h"
+#include "chrome/browser/content_settings/content_settings_base.h"
+#include "chrome/browser/content_settings/content_settings_pattern.h"
+#include "chrome/common/content_settings.h"
+#include "googleurl/src/gurl.h"
+
+class ExtensionContentSettingsStore {
+ public:
+
+ class Observer {
+ public:
+ virtual ~Observer();
+
+ // Called when a default setting changes in the
+ // ExtensionContentSettingsStore.
+ virtual void OnDefaultContentSettingChanged(
+ const ContentSettingsType& type,
+ ContentSetting setting) = 0;
+
+ // Called when a content setting changes in the
+ // ExtensionContentSettingsStore.
+ virtual void OnContentSettingChanged(
+ const ContentSettingsPattern& pattern,
+ const ContentSettingsPattern& embedder_pattern,
+ const ContentSettingsType& type,
+ const content_settings::ResourceIdentifier& identifier,
+ ContentSetting setting,
+ bool incognito) = 0;
+
+ // Called when the ExtensionContentSettingsStore is being destroyed. When
+ // called, observers must unsubscribe.
+ virtual void OnDestruction() = 0;
+ };
+
+ ExtensionContentSettingsStore();
+ virtual ~ExtensionContentSettingsStore();
+
+ // //////////////////////////////////////////////////////////////////////////
+
+ void SetExtensionDefaultContentSetting(ContentSettingsType content_type,
+ ContentSetting setting);
+
+ ContentSetting GetEffectiveDefaultContentSetting(
+ ContentSettingsType content_type);
+
+ // Sets the content |setting| for |pattern| of extension |ext_id|. The
+ // |incognito| flag allow to set whether the provided setting is for
+ // incognito mode only.
+ // Precondition: the extension must be registered.
+ void SetExtensionContentSetting(
+ const std::string& ext_id,
+ const ContentSettingsPattern& pattern,
+ const ContentSettingsPattern& embedder_pattern,
+ const ContentSettingsType& type,
+ const content_settings::ResourceIdentifier& identifier,
+ ContentSetting setting,
+ bool incognito);
+
+ ContentSetting GetEffectiveContentSetting(
+ const GURL& url,
+ const GURL& embedder_url,
+ const ContentSettingsType& type,
+ const content_settings::ResourceIdentifier& identifier,
+ bool incognito) const;
+
+ // TODO(markusheintz): More content settings API backend stuff goes here.
+
+ // //////////////////////////////////////////////////////////////////////////
+
+ // Registers the time when an extension |ext_id| is installed.
+ void RegisterExtension(const std::string& ext_id,
+ const base::Time& install_time,
+ bool is_enabled);
+
+ // Deletes all entries related to extension |ext_id|.
+ void UnregisterExtension(const std::string& ext_id);
+
+ // Hides or makes the extension content settings of the specified extension
+ // visible.
+ void SetExtensionState(const std::string& ext_id, bool is_enabled);
+
+ // Adds |observer|.
+ void AddObserver(Observer* observer);
+
+ // Remove |observer|.
+ void RemoveObserver(Observer* observer);
+
+ private:
+ struct ExtensionEntry;
+
+ typedef std::map<std::string, ExtensionEntry*> ExtensionEntryMap;
+
+ typedef Tuple5<ContentSettingsPattern,
+ ContentSettingsPattern,
+ ContentSettingsType,
+ content_settings::ResourceIdentifier,
+ ContentSetting> ContentSettingSpec;
+
+ typedef std::list<ContentSettingSpec> ContentSettingSpecList;
+
+ ContentSetting GetContentSettingFrom (
+ const GURL& url,
+ const GURL& embedder_url,
+ const ContentSettingsType& type,
+ const content_settings::ResourceIdentifier& identifier,
+ const ContentSettingSpecList* setting_spec_list) const;
+
+ ContentSettingSpecList* GetContentSettingSpecList(
+ const std::string& ext_id,
+ bool incognito);
+
+ const ContentSettingSpecList* GetContentSettingSpecList(
+ const std::string& ext_id,
+ bool incognito) const;
+
+ void NotifyOfContentSettingChanged(
+ const ContentSettingsPattern& pattern,
+ const ContentSettingsPattern& embedder_pattern,
+ const ContentSettingsType& type,
+ const content_settings::ResourceIdentifier& identifier,
+ ContentSetting setting,
+ bool incognito);
+
+ void NotifyOfDestruction();
+
+ ExtensionEntryMap entries_;
+
+ ObserverList<Observer, true> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsStore);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_

Powered by Google App Engine
This is Rietveld 408576698