| 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> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Sets the set of known disabled extension IDs. | 174 // Sets the set of known disabled extension IDs. |
| 175 void SetKnownDisabled(const ExtensionIdSet& extension_ids); | 175 void SetKnownDisabled(const ExtensionIdSet& extension_ids); |
| 176 | 176 |
| 177 // Called when an extension is installed, so that prefs get created. | 177 // Called when an extension is installed, so that prefs get created. |
| 178 // |blacklisted_for_malware| should be set if the extension was included in a | 178 // |blacklisted_for_malware| should be set if the extension was included in a |
| 179 // blacklist due to being malware. If |page_ordinal| is an invalid ordinal, | 179 // blacklist due to being malware. If |page_ordinal| is an invalid ordinal, |
| 180 // then a page will be found for the App. | 180 // then a page will be found for the App. |
| 181 void OnExtensionInstalled(const Extension* extension, | 181 void OnExtensionInstalled(const Extension* extension, |
| 182 Extension::State initial_state, | 182 Extension::State initial_state, |
| 183 bool blacklisted_for_malware, | 183 bool blacklisted_for_malware, |
| 184 const syncer::StringOrdinal& page_ordinal); | 184 const syncer::StringOrdinal& page_ordinal, |
| 185 const std::string& install_parameter); |
| 185 | 186 |
| 186 // Called when an extension is uninstalled, so that prefs get cleaned up. | 187 // Called when an extension is uninstalled, so that prefs get cleaned up. |
| 187 void OnExtensionUninstalled(const std::string& extension_id, | 188 void OnExtensionUninstalled(const std::string& extension_id, |
| 188 const Manifest::Location& location, | 189 const Manifest::Location& location, |
| 189 bool external_uninstall); | 190 bool external_uninstall); |
| 190 | 191 |
| 191 // Called to change the extension's state when it is enabled/disabled. | 192 // Called to change the extension's state when it is enabled/disabled. |
| 192 void SetExtensionState(const std::string& extension_id, Extension::State); | 193 void SetExtensionState(const std::string& extension_id, Extension::State); |
| 193 | 194 |
| 194 // Called to change the extension's BlacklistState. Currently only used for | 195 // Called to change the extension's BlacklistState. Currently only used for |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // extension is not present, NULL is returned. | 412 // extension is not present, NULL is returned. |
| 412 scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo( | 413 scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo( |
| 413 const std::string& extension_id) const; | 414 const std::string& extension_id) const; |
| 414 | 415 |
| 415 // We've downloaded an updated .crx file for the extension, but are waiting | 416 // We've downloaded an updated .crx file for the extension, but are waiting |
| 416 // to install it. | 417 // to install it. |
| 417 void SetDelayedInstallInfo(const Extension* extension, | 418 void SetDelayedInstallInfo(const Extension* extension, |
| 418 Extension::State initial_state, | 419 Extension::State initial_state, |
| 419 bool blacklisted_for_malware, | 420 bool blacklisted_for_malware, |
| 420 DelayReason delay_reason, | 421 DelayReason delay_reason, |
| 421 const syncer::StringOrdinal& page_ordinal); | 422 const syncer::StringOrdinal& page_ordinal, |
| 423 const std::string& install_parameter); |
| 422 | 424 |
| 423 // Removes any delayed install information we have for the given | 425 // Removes any delayed install information we have for the given |
| 424 // |extension_id|. Returns true if there was info to remove; false otherwise. | 426 // |extension_id|. Returns true if there was info to remove; false otherwise. |
| 425 bool RemoveDelayedInstallInfo(const std::string& extension_id); | 427 bool RemoveDelayedInstallInfo(const std::string& extension_id); |
| 426 | 428 |
| 427 // Update the prefs to finish the update for an extension. | 429 // Update the prefs to finish the update for an extension. |
| 428 bool FinishDelayedInstallInfo(const std::string& extension_id); | 430 bool FinishDelayedInstallInfo(const std::string& extension_id); |
| 429 | 431 |
| 430 // Returns the ExtensionInfo from the prefs for delayed install information | 432 // Returns the ExtensionInfo from the prefs for delayed install information |
| 431 // for |extension_id|, if we have any. Otherwise returns NULL. | 433 // for |extension_id|, if we have any. Otherwise returns NULL. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // found. | 473 // found. |
| 472 base::Time GetInstallTime(const std::string& extension_id) const; | 474 base::Time GetInstallTime(const std::string& extension_id) const; |
| 473 | 475 |
| 474 // Gets/sets the last launch time of an extension. | 476 // Gets/sets the last launch time of an extension. |
| 475 base::Time GetLastLaunchTime(const std::string& extension_id) const; | 477 base::Time GetLastLaunchTime(const std::string& extension_id) const; |
| 476 void SetLastLaunchTime(const std::string& extension_id, | 478 void SetLastLaunchTime(const std::string& extension_id, |
| 477 const base::Time& time); | 479 const base::Time& time); |
| 478 | 480 |
| 479 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 481 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 480 | 482 |
| 481 bool extensions_disabled() { return extensions_disabled_; } | 483 bool extensions_disabled() const { return extensions_disabled_; } |
| 482 | 484 |
| 483 ContentSettingsStore* content_settings_store() { | 485 ContentSettingsStore* content_settings_store() { |
| 484 return content_settings_store_.get(); | 486 return content_settings_store_.get(); |
| 485 } | 487 } |
| 486 | 488 |
| 487 // The underlying PrefService. | 489 // The underlying PrefService. |
| 488 PrefService* pref_service() const { return prefs_; } | 490 PrefService* pref_service() const { return prefs_; } |
| 489 | 491 |
| 490 // The underlying AppSorting. | 492 // The underlying AppSorting. |
| 491 AppSorting* app_sorting() const { return app_sorting_.get(); } | 493 AppSorting* app_sorting() const { return app_sorting_.get(); } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 505 const base::DictionaryValue* GetGeometryCache( | 507 const base::DictionaryValue* GetGeometryCache( |
| 506 const std::string& extension_id) const; | 508 const std::string& extension_id) const; |
| 507 void SetGeometryCache(const std::string& extension_id, | 509 void SetGeometryCache(const std::string& extension_id, |
| 508 scoped_ptr<base::DictionaryValue> cache); | 510 scoped_ptr<base::DictionaryValue> cache); |
| 509 | 511 |
| 510 // Used for verification of installed extension ids. For the Set method, pass | 512 // Used for verification of installed extension ids. For the Set method, pass |
| 511 // null to remove the preference. | 513 // null to remove the preference. |
| 512 const base::DictionaryValue* GetInstallSignature(); | 514 const base::DictionaryValue* GetInstallSignature(); |
| 513 void SetInstallSignature(const base::DictionaryValue* signature); | 515 void SetInstallSignature(const base::DictionaryValue* signature); |
| 514 | 516 |
| 517 // The installation parameter associated with the extension. |
| 518 std::string GetInstallParam(const std::string& extension_id) const; |
| 519 void SetInstallParam(const std::string& extension_id, |
| 520 const std::string& install_parameter); |
| 521 |
| 515 private: | 522 private: |
| 516 friend class ExtensionPrefsBlacklistedExtensions; // Unit test. | 523 friend class ExtensionPrefsBlacklistedExtensions; // Unit test. |
| 517 friend class ExtensionPrefsUninstallExtension; // Unit test. | 524 friend class ExtensionPrefsUninstallExtension; // Unit test. |
| 518 | 525 |
| 519 // See the Create methods. | 526 // See the Create methods. |
| 520 ExtensionPrefs(PrefService* prefs, | 527 ExtensionPrefs(PrefService* prefs, |
| 521 const base::FilePath& root_dir, | 528 const base::FilePath& root_dir, |
| 522 ExtensionPrefValueMap* extension_pref_value_map, | 529 ExtensionPrefValueMap* extension_pref_value_map, |
| 523 scoped_ptr<AppSorting> app_sorting, | 530 scoped_ptr<AppSorting> app_sorting, |
| 524 scoped_ptr<TimeProvider> time_provider, | 531 scoped_ptr<TimeProvider> time_provider, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 const ExtensionIdContainer& strings); | 612 const ExtensionIdContainer& strings); |
| 606 | 613 |
| 607 // Helper function to populate |extension_dict| with the values needed | 614 // Helper function to populate |extension_dict| with the values needed |
| 608 // by a newly installed extension. Work is broken up between this | 615 // by a newly installed extension. Work is broken up between this |
| 609 // function and FinishExtensionInfoPrefs() to accomodate delayed | 616 // function and FinishExtensionInfoPrefs() to accomodate delayed |
| 610 // installations. | 617 // installations. |
| 611 void PopulateExtensionInfoPrefs(const Extension* extension, | 618 void PopulateExtensionInfoPrefs(const Extension* extension, |
| 612 const base::Time install_time, | 619 const base::Time install_time, |
| 613 Extension::State initial_state, | 620 Extension::State initial_state, |
| 614 bool blacklisted_for_malware, | 621 bool blacklisted_for_malware, |
| 622 const std::string& install_parameter, |
| 615 base::DictionaryValue* extension_dict); | 623 base::DictionaryValue* extension_dict); |
| 616 | 624 |
| 617 // Helper function to complete initialization of the values in | 625 // Helper function to complete initialization of the values in |
| 618 // |extension_dict| for an extension install. Also see | 626 // |extension_dict| for an extension install. Also see |
| 619 // PopulateExtensionInfoPrefs(). | 627 // PopulateExtensionInfoPrefs(). |
| 620 void FinishExtensionInfoPrefs( | 628 void FinishExtensionInfoPrefs( |
| 621 const std::string& extension_id, | 629 const std::string& extension_id, |
| 622 const base::Time install_time, | 630 const base::Time install_time, |
| 623 bool needs_sort_ordinal, | 631 bool needs_sort_ordinal, |
| 624 const syncer::StringOrdinal& suggested_page_ordinal, | 632 const syncer::StringOrdinal& suggested_page_ordinal, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 643 scoped_ptr<TimeProvider> time_provider_; | 651 scoped_ptr<TimeProvider> time_provider_; |
| 644 | 652 |
| 645 bool extensions_disabled_; | 653 bool extensions_disabled_; |
| 646 | 654 |
| 647 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 655 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 648 }; | 656 }; |
| 649 | 657 |
| 650 } // namespace extensions | 658 } // namespace extensions |
| 651 | 659 |
| 652 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 660 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| OLD | NEW |