| 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 CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // default one is assumed. | 23 // default one is assumed. |
| 24 // TODO(skerner): Make this class an implementation detail of | 24 // TODO(skerner): Make this class an implementation detail of |
| 25 // PendingExtensionManager, and remove all other users. | 25 // PendingExtensionManager, and remove all other users. |
| 26 class PendingExtensionInfo { | 26 class PendingExtensionInfo { |
| 27 public: | 27 public: |
| 28 typedef bool (*ShouldAllowInstallPredicate)(const Extension*); | 28 typedef bool (*ShouldAllowInstallPredicate)(const Extension*); |
| 29 | 29 |
| 30 PendingExtensionInfo(const std::string& id, | 30 PendingExtensionInfo(const std::string& id, |
| 31 const std::string& install_parameter, | 31 const std::string& install_parameter, |
| 32 const GURL& update_url, | 32 const GURL& update_url, |
| 33 const Version& version, | 33 const base::Version& version, |
| 34 ShouldAllowInstallPredicate should_allow_install, | 34 ShouldAllowInstallPredicate should_allow_install, |
| 35 bool is_from_sync, | 35 bool is_from_sync, |
| 36 Manifest::Location install_source, | 36 Manifest::Location install_source, |
| 37 int creation_flags, | 37 int creation_flags, |
| 38 bool mark_acknowledged, | 38 bool mark_acknowledged, |
| 39 bool remote_install); | 39 bool remote_install); |
| 40 | 40 |
| 41 // Required for STL container membership. Should not be used directly. | 41 // Required for STL container membership. Should not be used directly. |
| 42 PendingExtensionInfo(); | 42 PendingExtensionInfo(); |
| 43 | 43 |
| 44 PendingExtensionInfo(const PendingExtensionInfo& other); | 44 PendingExtensionInfo(const PendingExtensionInfo& other); |
| 45 | 45 |
| 46 ~PendingExtensionInfo(); | 46 ~PendingExtensionInfo(); |
| 47 | 47 |
| 48 // Consider two PendingExtensionInfos equal if their ids are equal. | 48 // Consider two PendingExtensionInfos equal if their ids are equal. |
| 49 bool operator==(const PendingExtensionInfo& rhs) const; | 49 bool operator==(const PendingExtensionInfo& rhs) const; |
| 50 | 50 |
| 51 const std::string& id() const { return id_; } | 51 const std::string& id() const { return id_; } |
| 52 const GURL& update_url() const { return update_url_; } | 52 const GURL& update_url() const { return update_url_; } |
| 53 const Version& version() const { return version_; } | 53 const base::Version& version() const { return version_; } |
| 54 const std::string& install_parameter() const { return install_parameter_; } | 54 const std::string& install_parameter() const { return install_parameter_; } |
| 55 | 55 |
| 56 // ShouldAllowInstall() returns the result of running constructor argument | 56 // ShouldAllowInstall() returns the result of running constructor argument |
| 57 // |should_allow_install| on an extension. After an extension is unpacked, | 57 // |should_allow_install| on an extension. After an extension is unpacked, |
| 58 // this function is run. If it returns true, the extension is installed. | 58 // this function is run. If it returns true, the extension is installed. |
| 59 // If not, the extension is discarded. This allows creators of | 59 // If not, the extension is discarded. This allows creators of |
| 60 // PendingExtensionInfo objects to ensure that extensions meet some criteria | 60 // PendingExtensionInfo objects to ensure that extensions meet some criteria |
| 61 // that can only be tested once the extension is unpacked. | 61 // that can only be tested once the extension is unpacked. |
| 62 bool ShouldAllowInstall(const Extension* extension) const { | 62 bool ShouldAllowInstall(const Extension* extension) const { |
| 63 return should_allow_install_(extension); | 63 return should_allow_install_(extension); |
| 64 } | 64 } |
| 65 bool is_from_sync() const { return is_from_sync_; } | 65 bool is_from_sync() const { return is_from_sync_; } |
| 66 Manifest::Location install_source() const { return install_source_; } | 66 Manifest::Location install_source() const { return install_source_; } |
| 67 int creation_flags() const { return creation_flags_; } | 67 int creation_flags() const { return creation_flags_; } |
| 68 bool mark_acknowledged() const { return mark_acknowledged_; } | 68 bool mark_acknowledged() const { return mark_acknowledged_; } |
| 69 bool remote_install() const { return remote_install_; } | 69 bool remote_install() const { return remote_install_; } |
| 70 | 70 |
| 71 // Returns -1, 0 or 1 if |this| has lower, equal or higher precedence than | 71 // Returns -1, 0 or 1 if |this| has lower, equal or higher precedence than |
| 72 // |other|, respectively. "Equal" precedence means that the version and the | 72 // |other|, respectively. "Equal" precedence means that the version and the |
| 73 // install source match. "Higher" precedence means that the version is newer, | 73 // install source match. "Higher" precedence means that the version is newer, |
| 74 // or the version matches but the install source has higher priority. | 74 // or the version matches but the install source has higher priority. |
| 75 // It is only valid to invoke this when the ids match. | 75 // It is only valid to invoke this when the ids match. |
| 76 int CompareTo(const PendingExtensionInfo& other) const; | 76 int CompareTo(const PendingExtensionInfo& other) const; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 std::string id_; | 79 std::string id_; |
| 80 | 80 |
| 81 GURL update_url_; | 81 GURL update_url_; |
| 82 Version version_; | 82 base::Version version_; |
| 83 std::string install_parameter_; | 83 std::string install_parameter_; |
| 84 | 84 |
| 85 // When the extension is about to be installed, this function is | 85 // When the extension is about to be installed, this function is |
| 86 // called. If this function returns true, the install proceeds. If | 86 // called. If this function returns true, the install proceeds. If |
| 87 // this function returns false, the install is aborted. | 87 // this function returns false, the install is aborted. |
| 88 ShouldAllowInstallPredicate should_allow_install_; | 88 ShouldAllowInstallPredicate should_allow_install_; |
| 89 | 89 |
| 90 bool is_from_sync_; // This update check was initiated from sync. | 90 bool is_from_sync_; // This update check was initiated from sync. |
| 91 Manifest::Location install_source_; | 91 Manifest::Location install_source_; |
| 92 int creation_flags_; | 92 int creation_flags_; |
| 93 bool mark_acknowledged_; | 93 bool mark_acknowledged_; |
| 94 bool remote_install_; | 94 bool remote_install_; |
| 95 | 95 |
| 96 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, AddPendingExtensionFromSync); | 96 FRIEND_TEST_ALL_PREFIXES(::ExtensionServiceTest, AddPendingExtensionFromSync); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace extensions | 99 } // namespace extensions |
| 100 | 100 |
| 101 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ | 101 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ |
| OLD | NEW |