OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/version.h" | 9 #include "base/version.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 | 12 |
13 // A pending extension is an extension that hasn't been installed yet | 13 // A pending extension is an extension that hasn't been installed yet |
14 // and is intended to be installed in the next auto-update cycle. The | 14 // and is intended to be installed in the next auto-update cycle. The |
15 // update URL of a pending extension may be blank, in which case a | 15 // update URL of a pending extension may be blank, in which case a |
16 // default one is assumed. | 16 // default one is assumed. |
17 // TODO(skerner): Make this class an implementation detail of | 17 // TODO(skerner): Make this class an implementation detail of |
18 // PendingExtensionManager, and remove all other users. | 18 // PendingExtensionManager, and remove all other users. |
19 class PendingExtensionInfo { | 19 class PendingExtensionInfo { |
20 public: | 20 public: |
21 typedef bool (*ShouldAllowInstallPredicate)(const Extension&); | 21 typedef bool (*ShouldAllowInstallPredicate)(const extensions::Extension&); |
22 | 22 |
23 PendingExtensionInfo( | 23 PendingExtensionInfo( |
24 const GURL& update_url, | 24 const GURL& update_url, |
25 const Version& version, | 25 const Version& version, |
26 ShouldAllowInstallPredicate should_allow_install, | 26 ShouldAllowInstallPredicate should_allow_install, |
27 bool is_from_sync, | 27 bool is_from_sync, |
28 bool install_silently, | 28 bool install_silently, |
29 Extension::Location install_source); | 29 extensions::Extension::Location install_source); |
30 | 30 |
31 // Required for STL container membership. Should not be used directly. | 31 // Required for STL container membership. Should not be used directly. |
32 PendingExtensionInfo(); | 32 PendingExtensionInfo(); |
33 | 33 |
34 const GURL& update_url() const { return update_url_; } | 34 const GURL& update_url() const { return update_url_; } |
35 const Version& version() const { return version_; } | 35 const Version& version() const { return version_; } |
36 | 36 |
37 // ShouldAllowInstall() returns the result of running constructor argument | 37 // ShouldAllowInstall() returns the result of running constructor argument |
38 // |should_allow_install| on an extension. After an extension is unpacked, | 38 // |should_allow_install| on an extension. After an extension is unpacked, |
39 // this function is run. If it returns true, the extension is installed. | 39 // this function is run. If it returns true, the extension is installed. |
40 // If not, the extension is discarded. This allows creators of | 40 // If not, the extension is discarded. This allows creators of |
41 // PendingExtensionInfo objects to ensure that extensions meet some criteria | 41 // PendingExtensionInfo objects to ensure that extensions meet some criteria |
42 // that can only be tested once the extension is unpacked. | 42 // that can only be tested once the extension is unpacked. |
43 bool ShouldAllowInstall(const Extension& extension) const { | 43 bool ShouldAllowInstall(const extensions::Extension& extension) const { |
44 return should_allow_install_(extension); | 44 return should_allow_install_(extension); |
45 } | 45 } |
46 bool is_from_sync() const { return is_from_sync_; } | 46 bool is_from_sync() const { return is_from_sync_; } |
47 bool install_silently() const { return install_silently_; } | 47 bool install_silently() const { return install_silently_; } |
48 Extension::Location install_source() const { return install_source_; } | 48 extensions::Extension::Location install_source() const { |
| 49 return install_source_; |
| 50 } |
49 | 51 |
50 private: | 52 private: |
51 GURL update_url_; | 53 GURL update_url_; |
52 Version version_; | 54 Version version_; |
53 | 55 |
54 // When the extension is about to be installed, this function is | 56 // When the extension is about to be installed, this function is |
55 // called. If this function returns true, the install proceeds. If | 57 // called. If this function returns true, the install proceeds. If |
56 // this function returns false, the install is aborted. | 58 // this function returns false, the install is aborted. |
57 ShouldAllowInstallPredicate should_allow_install_; | 59 ShouldAllowInstallPredicate should_allow_install_; |
58 | 60 |
59 bool is_from_sync_; // This update check was initiated from sync. | 61 bool is_from_sync_; // This update check was initiated from sync. |
60 bool install_silently_; | 62 bool install_silently_; |
61 Extension::Location install_source_; | 63 extensions::Extension::Location install_source_; |
62 | 64 |
63 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync); | 65 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync); |
64 }; | 66 }; |
65 | 67 |
66 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ |
OLD | NEW |