Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: chrome/browser/extensions/pending_extension_info.h

Issue 9595001: Apps on NTP should be in order of installation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit test fixes Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Extension&);
22 22
23 PendingExtensionInfo( 23 PendingExtensionInfo(
24 const std::string& id,
24 const GURL& update_url, 25 const GURL& update_url,
25 const Version& version, 26 const Version& version,
26 ShouldAllowInstallPredicate should_allow_install, 27 ShouldAllowInstallPredicate should_allow_install,
27 bool is_from_sync, 28 bool is_from_sync,
28 bool install_silently, 29 bool install_silently,
29 Extension::Location install_source); 30 Extension::Location install_source);
30 31
31 // Required for STL container membership. Should not be used directly. 32 // Required for STL container membership. Should not be used directly.
32 PendingExtensionInfo(); 33 PendingExtensionInfo();
33 34
35 const std::string& id() const { return id_; }
34 const GURL& update_url() const { return update_url_; } 36 const GURL& update_url() const { return update_url_; }
35 const Version& version() const { return version_; } 37 const Version& version() const { return version_; }
36 38
37 // ShouldAllowInstall() returns the result of running constructor argument 39 // ShouldAllowInstall() returns the result of running constructor argument
38 // |should_allow_install| on an extension. After an extension is unpacked, 40 // |should_allow_install| on an extension. After an extension is unpacked,
39 // this function is run. If it returns true, the extension is installed. 41 // this function is run. If it returns true, the extension is installed.
40 // If not, the extension is discarded. This allows creators of 42 // If not, the extension is discarded. This allows creators of
41 // PendingExtensionInfo objects to ensure that extensions meet some criteria 43 // PendingExtensionInfo objects to ensure that extensions meet some criteria
42 // that can only be tested once the extension is unpacked. 44 // that can only be tested once the extension is unpacked.
43 bool ShouldAllowInstall(const Extension& extension) const { 45 bool ShouldAllowInstall(const Extension& extension) const {
44 return should_allow_install_(extension); 46 return should_allow_install_(extension);
45 } 47 }
46 bool is_from_sync() const { return is_from_sync_; } 48 bool is_from_sync() const { return is_from_sync_; }
47 bool install_silently() const { return install_silently_; } 49 bool install_silently() const { return install_silently_; }
48 Extension::Location install_source() const { return install_source_; } 50 Extension::Location install_source() const { return install_source_; }
49 51
50 private: 52 private:
53 const std::string& id_;
54
51 GURL update_url_; 55 GURL update_url_;
52 Version version_; 56 Version version_;
53 57
54 // When the extension is about to be installed, this function is 58 // When the extension is about to be installed, this function is
55 // called. If this function returns true, the install proceeds. If 59 // called. If this function returns true, the install proceeds. If
56 // this function returns false, the install is aborted. 60 // this function returns false, the install is aborted.
57 ShouldAllowInstallPredicate should_allow_install_; 61 ShouldAllowInstallPredicate should_allow_install_;
58 62
59 bool is_from_sync_; // This update check was initiated from sync. 63 bool is_from_sync_; // This update check was initiated from sync.
60 bool install_silently_; 64 bool install_silently_;
61 Extension::Location install_source_; 65 Extension::Location install_source_;
62 66
63 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync); 67 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync);
64 }; 68 };
65 69
66 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ 70 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698