| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
| 20 #include "extensions/browser/app_sorting.h" | 20 #include "extensions/browser/app_sorting.h" |
| 21 #include "extensions/browser/blacklist_state.h" | 21 #include "extensions/browser/blacklist_state.h" |
| 22 #include "extensions/browser/extension_scoped_prefs.h" | 22 #include "extensions/browser/extension_scoped_prefs.h" |
| 23 #include "extensions/browser/install_flag.h" |
| 23 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 24 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 25 #include "extensions/common/url_pattern_set.h" | 26 #include "extensions/common/url_pattern_set.h" |
| 26 #include "sync/api/string_ordinal.h" | 27 #include "sync/api/string_ordinal.h" |
| 27 | 28 |
| 28 class ExtensionPrefValueMap; | 29 class ExtensionPrefValueMap; |
| 29 class PrefService; | 30 class PrefService; |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 class BrowserContext; | 33 class BrowserContext; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 void SetToolbarOrder(const ExtensionIdList& extension_ids); | 178 void SetToolbarOrder(const ExtensionIdList& extension_ids); |
| 178 | 179 |
| 179 // Gets the set of known disabled extension IDs into |id_set_out|. Returns | 180 // Gets the set of known disabled extension IDs into |id_set_out|. Returns |
| 180 // false iff the set of known disabled extension IDs hasn't been set yet. | 181 // false iff the set of known disabled extension IDs hasn't been set yet. |
| 181 bool GetKnownDisabled(ExtensionIdSet* id_set_out); | 182 bool GetKnownDisabled(ExtensionIdSet* id_set_out); |
| 182 | 183 |
| 183 // Sets the set of known disabled extension IDs. | 184 // Sets the set of known disabled extension IDs. |
| 184 void SetKnownDisabled(const ExtensionIdSet& extension_ids); | 185 void SetKnownDisabled(const ExtensionIdSet& extension_ids); |
| 185 | 186 |
| 186 // Called when an extension is installed, so that prefs get created. | 187 // Called when an extension is installed, so that prefs get created. |
| 187 // |blacklisted_for_malware| should be set if the extension was included in a | 188 // If |page_ordinal| is invalid then a page will be found for the App. |
| 188 // blacklist due to being malware. If |page_ordinal| is an invalid ordinal, | 189 // |install_flags| are a bitmask of extension::InstallFlags. |
| 189 // then a page will be found for the App. | |
| 190 void OnExtensionInstalled(const Extension* extension, | 190 void OnExtensionInstalled(const Extension* extension, |
| 191 Extension::State initial_state, | 191 Extension::State initial_state, |
| 192 bool blacklisted_for_malware, | |
| 193 bool is_ephemeral, | |
| 194 const syncer::StringOrdinal& page_ordinal, | 192 const syncer::StringOrdinal& page_ordinal, |
| 193 int install_flags, |
| 195 const std::string& install_parameter); | 194 const std::string& install_parameter); |
| 195 // OnExtensionInstalled with no install flags. |
| 196 void OnExtensionInstalled(const Extension* extension, |
| 197 Extension::State initial_state, |
| 198 const syncer::StringOrdinal& page_ordinal, |
| 199 const std::string& install_parameter) { |
| 200 OnExtensionInstalled(extension, |
| 201 initial_state, |
| 202 page_ordinal, |
| 203 kInstallFlagNone, |
| 204 install_parameter); |
| 205 } |
| 196 | 206 |
| 197 // Called when an extension is uninstalled, so that prefs get cleaned up. | 207 // Called when an extension is uninstalled, so that prefs get cleaned up. |
| 198 void OnExtensionUninstalled(const std::string& extension_id, | 208 void OnExtensionUninstalled(const std::string& extension_id, |
| 199 const Manifest::Location& location, | 209 const Manifest::Location& location, |
| 200 bool external_uninstall); | 210 bool external_uninstall); |
| 201 | 211 |
| 202 // Called to change the extension's state when it is enabled/disabled. | 212 // Called to change the extension's state when it is enabled/disabled. |
| 203 void SetExtensionState(const std::string& extension_id, Extension::State); | 213 void SetExtensionState(const std::string& extension_id, Extension::State); |
| 204 | 214 |
| 205 // Called to change the extension's BlacklistState. Currently only used for | 215 // Called to change the extension's BlacklistState. Currently only used for |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // explicitly uninstalled. | 447 // explicitly uninstalled. |
| 438 scoped_ptr<ExtensionsInfo> GetUninstalledExtensionsInfo() const; | 448 scoped_ptr<ExtensionsInfo> GetUninstalledExtensionsInfo() const; |
| 439 | 449 |
| 440 // Returns the ExtensionInfo from the prefs for the given extension. If the | 450 // Returns the ExtensionInfo from the prefs for the given extension. If the |
| 441 // extension is not present, NULL is returned. | 451 // extension is not present, NULL is returned. |
| 442 scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo( | 452 scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo( |
| 443 const std::string& extension_id) const; | 453 const std::string& extension_id) const; |
| 444 | 454 |
| 445 // We've downloaded an updated .crx file for the extension, but are waiting | 455 // We've downloaded an updated .crx file for the extension, but are waiting |
| 446 // to install it. | 456 // to install it. |
| 457 // |
| 458 // |install_flags| are a bitmask of extension::InstallFlags. |
| 447 void SetDelayedInstallInfo(const Extension* extension, | 459 void SetDelayedInstallInfo(const Extension* extension, |
| 448 Extension::State initial_state, | 460 Extension::State initial_state, |
| 449 bool blacklisted_for_malware, | 461 int install_flags, |
| 450 bool is_ephemeral, | |
| 451 DelayReason delay_reason, | 462 DelayReason delay_reason, |
| 452 const syncer::StringOrdinal& page_ordinal, | 463 const syncer::StringOrdinal& page_ordinal, |
| 453 const std::string& install_parameter); | 464 const std::string& install_parameter); |
| 454 | 465 |
| 455 // Removes any delayed install information we have for the given | 466 // Removes any delayed install information we have for the given |
| 456 // |extension_id|. Returns true if there was info to remove; false otherwise. | 467 // |extension_id|. Returns true if there was info to remove; false otherwise. |
| 457 bool RemoveDelayedInstallInfo(const std::string& extension_id); | 468 bool RemoveDelayedInstallInfo(const std::string& extension_id); |
| 458 | 469 |
| 459 // Update the prefs to finish the update for an extension. | 470 // Update the prefs to finish the update for an extension. |
| 460 bool FinishDelayedInstallInfo(const std::string& extension_id); | 471 bool FinishDelayedInstallInfo(const std::string& extension_id); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 680 |
| 670 // Writes the list of strings contained in |strings| to |pref| in prefs. | 681 // Writes the list of strings contained in |strings| to |pref| in prefs. |
| 671 template <class ExtensionIdContainer> | 682 template <class ExtensionIdContainer> |
| 672 void SetExtensionPrefFromContainer(const char* pref, | 683 void SetExtensionPrefFromContainer(const char* pref, |
| 673 const ExtensionIdContainer& strings); | 684 const ExtensionIdContainer& strings); |
| 674 | 685 |
| 675 // Helper function to populate |extension_dict| with the values needed | 686 // Helper function to populate |extension_dict| with the values needed |
| 676 // by a newly installed extension. Work is broken up between this | 687 // by a newly installed extension. Work is broken up between this |
| 677 // function and FinishExtensionInfoPrefs() to accomodate delayed | 688 // function and FinishExtensionInfoPrefs() to accomodate delayed |
| 678 // installations. | 689 // installations. |
| 690 // |
| 691 // |install_flags| are a bitmask of extension::InstallFlags. |
| 679 void PopulateExtensionInfoPrefs(const Extension* extension, | 692 void PopulateExtensionInfoPrefs(const Extension* extension, |
| 680 const base::Time install_time, | 693 const base::Time install_time, |
| 681 Extension::State initial_state, | 694 Extension::State initial_state, |
| 682 bool blacklisted_for_malware, | 695 int install_flags, |
| 683 bool is_ephemeral, | |
| 684 const std::string& install_parameter, | 696 const std::string& install_parameter, |
| 685 base::DictionaryValue* extension_dict); | 697 base::DictionaryValue* extension_dict); |
| 686 | 698 |
| 687 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map); | 699 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map); |
| 688 | 700 |
| 689 // Helper function to complete initialization of the values in | 701 // Helper function to complete initialization of the values in |
| 690 // |extension_dict| for an extension install. Also see | 702 // |extension_dict| for an extension install. Also see |
| 691 // PopulateExtensionInfoPrefs(). | 703 // PopulateExtensionInfoPrefs(). |
| 692 void FinishExtensionInfoPrefs( | 704 void FinishExtensionInfoPrefs( |
| 693 const std::string& extension_id, | 705 const std::string& extension_id, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 715 bool extensions_disabled_; | 727 bool extensions_disabled_; |
| 716 | 728 |
| 717 ObserverList<ExtensionPrefsObserver> observer_list_; | 729 ObserverList<ExtensionPrefsObserver> observer_list_; |
| 718 | 730 |
| 719 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 731 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 720 }; | 732 }; |
| 721 | 733 |
| 722 } // namespace extensions | 734 } // namespace extensions |
| 723 | 735 |
| 724 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 736 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| OLD | NEW |