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

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: ExtensionInstallUI -> ExtensionInstallPrompt Created 8 years, 6 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 extensions::Extension&); 21 typedef bool (*ShouldAllowInstallPredicate)(const extensions::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 extensions::Extension::Location install_source); 30 extensions::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 // Consider two PendingExtensionInfos equal if their ids are equal.
36 bool operator==(const PendingExtensionInfo& rhs) const;
37
38 const std::string& id() const { return id_; }
34 const GURL& update_url() const { return update_url_; } 39 const GURL& update_url() const { return update_url_; }
35 const Version& version() const { return version_; } 40 const Version& version() const { return version_; }
36 41
37 // ShouldAllowInstall() returns the result of running constructor argument 42 // ShouldAllowInstall() returns the result of running constructor argument
38 // |should_allow_install| on an extension. After an extension is unpacked, 43 // |should_allow_install| on an extension. After an extension is unpacked,
39 // this function is run. If it returns true, the extension is installed. 44 // this function is run. If it returns true, the extension is installed.
40 // If not, the extension is discarded. This allows creators of 45 // If not, the extension is discarded. This allows creators of
41 // PendingExtensionInfo objects to ensure that extensions meet some criteria 46 // PendingExtensionInfo objects to ensure that extensions meet some criteria
42 // that can only be tested once the extension is unpacked. 47 // that can only be tested once the extension is unpacked.
43 bool ShouldAllowInstall(const extensions::Extension& extension) const { 48 bool ShouldAllowInstall(const extensions::Extension& extension) const {
44 return should_allow_install_(extension); 49 return should_allow_install_(extension);
45 } 50 }
46 bool is_from_sync() const { return is_from_sync_; } 51 bool is_from_sync() const { return is_from_sync_; }
47 bool install_silently() const { return install_silently_; } 52 bool install_silently() const { return install_silently_; }
48 extensions::Extension::Location install_source() const { 53 extensions::Extension::Location install_source() const {
49 return install_source_; 54 return install_source_;
50 } 55 }
51 56
52 private: 57 private:
58 std::string id_;
59
53 GURL update_url_; 60 GURL update_url_;
54 Version version_; 61 Version version_;
55 62
56 // When the extension is about to be installed, this function is 63 // When the extension is about to be installed, this function is
57 // called. If this function returns true, the install proceeds. If 64 // called. If this function returns true, the install proceeds. If
58 // this function returns false, the install is aborted. 65 // this function returns false, the install is aborted.
59 ShouldAllowInstallPredicate should_allow_install_; 66 ShouldAllowInstallPredicate should_allow_install_;
60 67
61 bool is_from_sync_; // This update check was initiated from sync. 68 bool is_from_sync_; // This update check was initiated from sync.
62 bool install_silently_; 69 bool install_silently_;
63 extensions::Extension::Location install_source_; 70 extensions::Extension::Location install_source_;
64 71
65 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync); 72 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync);
66 }; 73 };
67 74
68 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ 75 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/pending_extension_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698