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

Side by Side Diff: extensions/browser/external_provider_interface.h

Issue 1495403002: Observe adding external extensions via windows registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: guard updater_->CheckNow() call, rework Provider->ExtensionService interaction Created 4 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_EXTERNAL_PROVIDER_INTERFACE_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_
6 #define EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_ 6 #define EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/version.h"
11 #include "extensions/common/manifest.h" 13 #include "extensions/common/manifest.h"
14 #include "url/gurl.h"
12 15
13 class GURL; 16 class GURL;
14 17
15 namespace base { 18 namespace base {
16 class FilePath; 19 class FilePath;
17 class Version; 20 // class Version;
18 } 21 }
19 22
20 namespace extensions { 23 namespace extensions {
21 24
22 // This class is an abstract class for implementing external extensions 25 // This class is an abstract class for implementing external extensions
23 // providers. 26 // providers.
24 class ExternalProviderInterface { 27 class ExternalProviderInterface {
25 public: 28 public:
29 struct ExternalExtensionInfo {
lazyboy 2016/01/22 07:52:41 These structs basically hold the information from
asargent_no_longer_on_chrome 2016/01/25 18:50:52 Acknowledged.
30 std::string extension_id;
31 int creation_flags;
32 bool mark_acknowledged;
33 ExternalExtensionInfo(const std::string& extension_id,
34 int creation_flags,
35 bool mark_acknowledged)
36 : extension_id(extension_id),
37 creation_flags(creation_flags),
38 mark_acknowledged(mark_acknowledged) {}
39
40 private:
41 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionInfo);
42 };
43
44 // Carries information about an external extension installation
45 // through a crx file location.
46 struct FileExtensionInfo : ExternalExtensionInfo {
47 FileExtensionInfo(const std::string& extension_id,
48 scoped_ptr<base::Version> version,
49 const base::FilePath& path,
50 Manifest::Location crx_location,
51 bool mark_acknowledged,
52 int creation_flags,
53 bool install_immediately)
54 : ExternalExtensionInfo(extension_id,
55 creation_flags,
56 mark_acknowledged),
57 version(std::move(version)),
58 path(path),
59 crx_location(crx_location),
60 install_immediately(install_immediately) {}
61
62 scoped_ptr<base::Version> version;
63 base::FilePath path;
64 Manifest::Location crx_location;
65 bool install_immediately;
66 };
67
68 // Carries information about an external extension installation
69 // through an update_url.
70 struct UpdateUrlExtensionInfo : ExternalExtensionInfo {
71 UpdateUrlExtensionInfo(const std::string& extension_id,
72 const std::string& install_parameter,
73 scoped_ptr<GURL> update_url,
74 Manifest::Location download_location,
75 int creation_flags,
76 bool mark_acknowledged)
77 : ExternalExtensionInfo(extension_id,
78 creation_flags,
79 mark_acknowledged),
80 install_parameter(install_parameter),
81 update_url(std::move(update_url)),
82 download_location(download_location) {}
83
84 std::string install_parameter;
85 scoped_ptr<GURL> update_url;
86 Manifest::Location download_location;
87 };
88
26 // ExternalProvider uses this interface to communicate back to the 89 // ExternalProvider uses this interface to communicate back to the
27 // caller what extensions are registered, and which |id|, |version| and |path| 90 // caller what extensions are registered, and which |id|, |version| and |path|
28 // they have. See also VisitRegisteredExtension below. Ownership of |version| 91 // they have. See also VisitRegisteredExtension below. Ownership of |version|
29 // is not transferred to the visitor. Callers of the methods below must 92 // is not transferred to the visitor. Callers of the methods below must
30 // ensure that |id| is a valid extension id (use 93 // ensure that |id| is a valid extension id (use
31 // crx_file::id_util::IdIsValid(id)). 94 // crx_file::id_util::IdIsValid(id)).
32 class VisitorInterface { 95 class VisitorInterface {
33 public: 96 public:
34 // Return true if the extension install will proceed. Install will not 97 // Return true if the extension install will proceed. Install will not
35 // proceed if the extension is already installed from a higher priority 98 // proceed if the extension is already installed from a higher priority
36 // location. 99 // location.
37 virtual bool OnExternalExtensionFileFound( 100 virtual bool OnExternalExtensionFileFound(FileExtensionInfo* info) = 0;
38 const std::string& id,
39 const base::Version* version,
40 const base::FilePath& path,
41 Manifest::Location location,
42 int creation_flags,
43 bool mark_acknowledged,
44 bool install_immediately) = 0;
45 101
46 // Return true if the extension install will proceed. Install might not 102 // Return true if the extension install will proceed. Install might not
47 // proceed if the extension is already installed from a higher priority 103 // proceed if the extension is already installed from a higher priority
48 // location. 104 // location.
49 virtual bool OnExternalExtensionUpdateUrlFound( 105 virtual bool OnExternalExtensionUpdateUrlFound(UpdateUrlExtensionInfo* info,
50 const std::string& id, 106 bool is_initial_load) = 0;
51 const std::string& install_parameter,
52 const GURL& update_url,
53 Manifest::Location location,
54 int creation_flags,
55 bool mark_acknowledged) = 0;
56 107
57 // Called after all the external extensions have been reported 108 // Called after all the external extensions have been reported
58 // through the above two methods. |provider| is a pointer to the 109 // through the above two methods. |provider| is a pointer to the
59 // provider that is now ready (typically this), and the 110 // provider that is now ready (typically this), and the
60 // implementation of OnExternalProviderReady() should be able to 111 // implementation of OnExternalProviderReady() should be able to
61 // safely assert that provider->IsReady(). 112 // safely assert that provider->IsReady().
62 virtual void OnExternalProviderReady( 113 virtual void OnExternalProviderReady(
63 const ExternalProviderInterface* provider) = 0; 114 const ExternalProviderInterface* provider) = 0;
64 115
116 // Once this provider becomes "ready", it can send additional external
117 // extensions it learns about later on through
118 // OnExternalExtensionUpdateUrlFound() or OnExternalExtensionFileFound().
119 // This method will be called each time the provider finds a set of
120 // updated external extensions.
121 virtual void OnExternalProviderUpdateComplete(
122 const ExternalProviderInterface* provider,
123 const ScopedVector<UpdateUrlExtensionInfo>& update_url_extensions,
124 const ScopedVector<FileExtensionInfo>& file_extensions,
125 const std::set<std::string>& removed_extensions) = 0;
126
65 protected: 127 protected:
66 virtual ~VisitorInterface() {} 128 virtual ~VisitorInterface() {}
67 }; 129 };
68 130
69 virtual ~ExternalProviderInterface() {} 131 virtual ~ExternalProviderInterface() {}
70 132
71 // The visitor (ExtensionsService) calls this function before it goes away. 133 // The visitor (ExtensionsService) calls this function before it goes away.
72 virtual void ServiceShutdown() = 0; 134 virtual void ServiceShutdown() = 0;
73 135
74 // Enumerate registered extensions, calling 136 // Enumerate registered extensions, calling
(...skipping 17 matching lines...) Expand all
92 // from its source. 154 // from its source.
93 virtual bool IsReady() const = 0; 155 virtual bool IsReady() const = 0;
94 }; 156 };
95 157
96 typedef std::vector<linked_ptr<ExternalProviderInterface> > 158 typedef std::vector<linked_ptr<ExternalProviderInterface> >
97 ProviderCollection; 159 ProviderCollection;
98 160
99 } // namespace extensions 161 } // namespace extensions
100 162
101 #endif // EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_ 163 #endif // EXTENSIONS_BROWSER_EXTERNAL_PROVIDER_INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698