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