Chromium Code Reviews| 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( | |
| 201 extension, initial_state, page_ordinal, install_parameter); | |
|
xiyuan
2014/06/10 17:07:28
Seems missing the default install flags to call th
not at google - send to devlin
2014/06/10 17:08:42
yes, this is ... a terrifying infinite loop. thank
| |
| 202 } | |
| 196 | 203 |
| 197 // Called when an extension is uninstalled, so that prefs get cleaned up. | 204 // Called when an extension is uninstalled, so that prefs get cleaned up. |
| 198 void OnExtensionUninstalled(const std::string& extension_id, | 205 void OnExtensionUninstalled(const std::string& extension_id, |
| 199 const Manifest::Location& location, | 206 const Manifest::Location& location, |
| 200 bool external_uninstall); | 207 bool external_uninstall); |
| 201 | 208 |
| 202 // Called to change the extension's state when it is enabled/disabled. | 209 // Called to change the extension's state when it is enabled/disabled. |
| 203 void SetExtensionState(const std::string& extension_id, Extension::State); | 210 void SetExtensionState(const std::string& extension_id, Extension::State); |
| 204 | 211 |
| 205 // Called to change the extension's BlacklistState. Currently only used for | 212 // 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. | 444 // explicitly uninstalled. |
| 438 scoped_ptr<ExtensionsInfo> GetUninstalledExtensionsInfo() const; | 445 scoped_ptr<ExtensionsInfo> GetUninstalledExtensionsInfo() const; |
| 439 | 446 |
| 440 // Returns the ExtensionInfo from the prefs for the given extension. If the | 447 // Returns the ExtensionInfo from the prefs for the given extension. If the |
| 441 // extension is not present, NULL is returned. | 448 // extension is not present, NULL is returned. |
| 442 scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo( | 449 scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo( |
| 443 const std::string& extension_id) const; | 450 const std::string& extension_id) const; |
| 444 | 451 |
| 445 // We've downloaded an updated .crx file for the extension, but are waiting | 452 // We've downloaded an updated .crx file for the extension, but are waiting |
| 446 // to install it. | 453 // to install it. |
| 454 // | |
| 455 // |install_flags| are a bitmask of extension::InstallFlags. | |
| 447 void SetDelayedInstallInfo(const Extension* extension, | 456 void SetDelayedInstallInfo(const Extension* extension, |
| 448 Extension::State initial_state, | 457 Extension::State initial_state, |
| 449 bool blacklisted_for_malware, | 458 int install_flags, |
| 450 bool is_ephemeral, | |
| 451 DelayReason delay_reason, | 459 DelayReason delay_reason, |
| 452 const syncer::StringOrdinal& page_ordinal, | 460 const syncer::StringOrdinal& page_ordinal, |
| 453 const std::string& install_parameter); | 461 const std::string& install_parameter); |
| 454 | 462 |
| 455 // Removes any delayed install information we have for the given | 463 // Removes any delayed install information we have for the given |
| 456 // |extension_id|. Returns true if there was info to remove; false otherwise. | 464 // |extension_id|. Returns true if there was info to remove; false otherwise. |
| 457 bool RemoveDelayedInstallInfo(const std::string& extension_id); | 465 bool RemoveDelayedInstallInfo(const std::string& extension_id); |
| 458 | 466 |
| 459 // Update the prefs to finish the update for an extension. | 467 // Update the prefs to finish the update for an extension. |
| 460 bool FinishDelayedInstallInfo(const std::string& extension_id); | 468 bool FinishDelayedInstallInfo(const std::string& extension_id); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 | 677 |
| 670 // Writes the list of strings contained in |strings| to |pref| in prefs. | 678 // Writes the list of strings contained in |strings| to |pref| in prefs. |
| 671 template <class ExtensionIdContainer> | 679 template <class ExtensionIdContainer> |
| 672 void SetExtensionPrefFromContainer(const char* pref, | 680 void SetExtensionPrefFromContainer(const char* pref, |
| 673 const ExtensionIdContainer& strings); | 681 const ExtensionIdContainer& strings); |
| 674 | 682 |
| 675 // Helper function to populate |extension_dict| with the values needed | 683 // Helper function to populate |extension_dict| with the values needed |
| 676 // by a newly installed extension. Work is broken up between this | 684 // by a newly installed extension. Work is broken up between this |
| 677 // function and FinishExtensionInfoPrefs() to accomodate delayed | 685 // function and FinishExtensionInfoPrefs() to accomodate delayed |
| 678 // installations. | 686 // installations. |
| 687 // | |
| 688 // |install_flags| are a bitmask of extension::InstallFlags. | |
| 679 void PopulateExtensionInfoPrefs(const Extension* extension, | 689 void PopulateExtensionInfoPrefs(const Extension* extension, |
| 680 const base::Time install_time, | 690 const base::Time install_time, |
| 681 Extension::State initial_state, | 691 Extension::State initial_state, |
| 682 bool blacklisted_for_malware, | 692 int install_flags, |
| 683 bool is_ephemeral, | |
| 684 const std::string& install_parameter, | 693 const std::string& install_parameter, |
| 685 base::DictionaryValue* extension_dict); | 694 base::DictionaryValue* extension_dict); |
| 686 | 695 |
| 687 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map); | 696 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map); |
| 688 | 697 |
| 689 // Helper function to complete initialization of the values in | 698 // Helper function to complete initialization of the values in |
| 690 // |extension_dict| for an extension install. Also see | 699 // |extension_dict| for an extension install. Also see |
| 691 // PopulateExtensionInfoPrefs(). | 700 // PopulateExtensionInfoPrefs(). |
| 692 void FinishExtensionInfoPrefs( | 701 void FinishExtensionInfoPrefs( |
| 693 const std::string& extension_id, | 702 const std::string& extension_id, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 715 bool extensions_disabled_; | 724 bool extensions_disabled_; |
| 716 | 725 |
| 717 ObserverList<ExtensionPrefsObserver> observer_list_; | 726 ObserverList<ExtensionPrefsObserver> observer_list_; |
| 718 | 727 |
| 719 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 728 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 720 }; | 729 }; |
| 721 | 730 |
| 722 } // namespace extensions | 731 } // namespace extensions |
| 723 | 732 |
| 724 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 733 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| OLD | NEW |