Chromium Code Reviews| Index: chrome/browser/extensions/extension_pref_store.h | 
| diff --git a/chrome/browser/extensions/extension_pref_store.h b/chrome/browser/extensions/extension_pref_store.h | 
| index f2db8096692e56a7523af315865ee76d8d2d0b5c..a469ee091bd2e854c30a60687e64458453286f92 100644 | 
| --- a/chrome/browser/extensions/extension_pref_store.h | 
| +++ b/chrome/browser/extensions/extension_pref_store.h | 
| @@ -1,4 +1,4 @@ | 
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| +// 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. | 
| @@ -6,31 +6,64 @@ | 
| #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ | 
| #pragma once | 
| -#include "chrome/browser/prefs/value_map_pref_store.h" | 
| +#include <map> | 
| +#include <set> | 
| -// A PrefStore implementation that holds preferences set by extensions. | 
| -class ExtensionPrefStore : public ValueMapPrefStore { | 
| - public: | 
| - ExtensionPrefStore(); | 
| - virtual ~ExtensionPrefStore() {} | 
| +#include "base/time.h" | 
| +#include "chrome/browser/prefs/value_map_pref_store.h" | 
| - // Set an extension preference |value| for |key|. Takes ownership of |value|. | 
| - void SetExtensionPref(const std::string& key, Value* value); | 
| +class ExtensionPrefValueMap; | 
| - // Remove the extension preference value for |key|. | 
| - void RemoveExtensionPref(const std::string& key); | 
| +// A (non-persistent) PrefStore implementation that holds preferences set by | 
| +// extensions. | 
| +// The semantics of the ExtensionPrefStore are: | 
| +// - The precedence of extensions is determined by their installation time. | 
| +// The extension that has been installed later takes higher precedence. | 
| +// - If two extensions set a value for the same preference, the following | 
| +// rules determine which value becomes effective (visible). | 
| +// - The effective regular extension pref value is determined by the regular | 
| +// extension pref value of the extension with the highest precedence. | 
| +// - The effective incognito extension pref value is determined by the incognito | 
| +// extension pref value of the extension with the highest precedence, unless | 
| +// another extension with higher precedence overrides it with a regular | 
| +// extension pref value. | 
| +// | 
| +// The following table illustrates the behavior: | 
| +// A.reg | A.inc | B.reg | B.inc | E.reg | E.inc | 
| +// 1 | - | - | - | 1 | 1 | 
| +// 1 | 2 | - | - | 1 | 2 | 
| +// 1 | - | 3 | - | 3 | 3 | 
| +// 1 | - | - | 4 | 1 | 4 | 
| +// 1 | 2 | 3 | - | 3 | 3(!) | 
| +// 1 | 2 | - | 4 | 1 | 4 | 
| +// 1 | 2 | 3 | 4 | 3 | 4 | 
| +// A = extension A, B = extension B, E = effective value | 
| +// .reg = regular value | 
| +// .inc = incognito value | 
| +// Extension B has higher precedence than A. | 
| +// | 
| +// Large parts of ExtensionPrefStore's logic are implemented in | 
| +// ExtensionPrefValueMap. | 
| 
 
Mattias Nissler (ping if slow)
2011/01/05 12:08:07
Maybe it's useful to put the semantics comment abo
 
battre
2011/01/05 20:23:08
Done.
 
 | 
| +class ExtensionPrefStore : public ValueMapPrefStore, | 
| + public PrefStore::Observer { | 
| + public: | 
| + // Constructs an ExtensionPrefStore for a regular or an incognito profile. | 
| + explicit ExtensionPrefStore(bool incognito_pref_store); | 
| + virtual ~ExtensionPrefStore(); | 
| - // Tell the store it's now fully initialized. | 
| - void OnInitializationCompleted(); | 
| + // Does not assume ownership of |extension_pref_value_map|. | 
| + void SetExtensionPrefValueMap( | 
| + ExtensionPrefValueMap* extension_pref_value_map); | 
| 
 
Mattias Nissler (ping if slow)
2011/01/05 12:08:07
Why can't we pass this to the constructor?
 
battre
2011/01/05 20:23:08
Done.
 
 | 
| private: | 
| - // PrefStore overrides: | 
| - virtual bool IsInitializationComplete() const; | 
| + // Overrides for PrefStore::Observer: | 
| + virtual void OnInitializationCompleted(); | 
| + virtual void OnPrefValueChanged(const std::string& key); | 
| - bool initialization_complete_; | 
| + ExtensionPrefValueMap* extension_pref_value_map_; // Weak pointer. | 
| + bool incognito_pref_store_; | 
| DISALLOW_COPY_AND_ASSIGN(ExtensionPrefStore); | 
| }; | 
| - | 
| #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_STORE_H_ |