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_UPDATER_EXTENSION_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/version.h" | 20 #include "base/version.h" |
21 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" | 21 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" |
22 #include "chrome/browser/extensions/updater/manifest_fetch_data.h" | |
23 #include "chrome/browser/extensions/updater/request_queue.h" | 22 #include "chrome/browser/extensions/updater/request_queue.h" |
| 23 #include "extensions/browser/updater/manifest_fetch_data.h" |
24 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
25 #include "extensions/common/update_manifest.h" | 25 #include "extensions/common/update_manifest.h" |
26 #include "google_apis/gaia/oauth2_token_service.h" | 26 #include "google_apis/gaia/oauth2_token_service.h" |
27 #include "net/url_request/url_fetcher_delegate.h" | 27 #include "net/url_request/url_fetcher_delegate.h" |
28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
29 | 29 |
30 class IdentityProvider; | 30 class IdentityProvider; |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 class URLFetcher; | 33 class URLFetcher; |
34 class URLRequestContextGetter; | 34 class URLRequestContextGetter; |
35 class URLRequestStatus; | 35 class URLRequestStatus; |
36 } | 36 } |
37 | 37 |
38 namespace extensions { | 38 namespace extensions { |
39 | 39 |
40 struct UpdateDetails { | 40 struct UpdateDetails { |
41 UpdateDetails(const std::string& id, const base::Version& version); | 41 UpdateDetails(const std::string& id, const base::Version& version); |
42 ~UpdateDetails(); | 42 ~UpdateDetails(); |
43 | 43 |
44 std::string id; | 44 std::string id; |
45 base::Version version; | 45 base::Version version; |
46 }; | 46 }; |
47 | 47 |
48 class ExtensionCache; | 48 class ExtensionCache; |
49 class ExtensionUpdaterTest; | 49 class ExtensionUpdaterTest; |
| 50 class ManifestFetchDataDelegate; |
50 | 51 |
51 // A class that checks for updates of a given list of extensions, and downloads | 52 // A class that checks for updates of a given list of extensions, and downloads |
52 // the crx file when updates are found. It uses a |ExtensionDownloaderDelegate| | 53 // the crx file when updates are found. It uses a |ExtensionDownloaderDelegate| |
53 // that takes ownership of the downloaded crx files, and handles events during | 54 // that takes ownership of the downloaded crx files, and handles events during |
54 // the update check. | 55 // the update check. |
55 class ExtensionDownloader | 56 class ExtensionDownloader |
56 : public net::URLFetcherDelegate, | 57 : public net::URLFetcherDelegate, |
57 public OAuth2TokenService::Consumer { | 58 public OAuth2TokenService::Consumer { |
58 public: | 59 public: |
59 // A closure which constructs a new ExtensionDownloader to be owned by the | 60 // A closure which constructs a new ExtensionDownloader to be owned by the |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Schedules an update check of the blacklist. | 94 // Schedules an update check of the blacklist. |
94 void StartBlacklistUpdate(const std::string& version, | 95 void StartBlacklistUpdate(const std::string& version, |
95 const ManifestFetchData::PingData& ping_data, | 96 const ManifestFetchData::PingData& ping_data, |
96 int request_id); | 97 int request_id); |
97 | 98 |
98 // Sets an IdentityProvider to be used for OAuth2 authentication on protected | 99 // Sets an IdentityProvider to be used for OAuth2 authentication on protected |
99 // Webstore downloads. | 100 // Webstore downloads. |
100 void SetWebstoreIdentityProvider( | 101 void SetWebstoreIdentityProvider( |
101 scoped_ptr<IdentityProvider> identity_provider); | 102 scoped_ptr<IdentityProvider> identity_provider); |
102 | 103 |
| 104 // Sets a new delegate for update manifest fetches. |
| 105 void SetManifestFetchDataDelegate( |
| 106 scoped_ptr<ManifestFetchDataDelegate> delegate); |
| 107 |
103 // These are needed for unit testing, to help identify the correct mock | 108 // These are needed for unit testing, to help identify the correct mock |
104 // URLFetcher objects. | 109 // URLFetcher objects. |
105 static const int kManifestFetcherId = 1; | 110 static const int kManifestFetcherId = 1; |
106 static const int kExtensionFetcherId = 2; | 111 static const int kExtensionFetcherId = 2; |
107 | 112 |
108 // Update AppID for extension blacklist. | 113 // Update AppID for extension blacklist. |
109 static const char kBlacklistAppID[]; | 114 static const char kBlacklistAppID[]; |
110 | 115 |
111 static const int kMaxRetries = 10; | 116 static const int kMaxRetries = 10; |
112 | 117 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // download requests. May be NULL. | 289 // download requests. May be NULL. |
285 scoped_ptr<IdentityProvider> identity_provider_; | 290 scoped_ptr<IdentityProvider> identity_provider_; |
286 | 291 |
287 // A Webstore download-scoped access token for the |identity_provider_|'s | 292 // A Webstore download-scoped access token for the |identity_provider_|'s |
288 // active account, if any. | 293 // active account, if any. |
289 std::string access_token_; | 294 std::string access_token_; |
290 | 295 |
291 // A pending token fetch request. | 296 // A pending token fetch request. |
292 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 297 scoped_ptr<OAuth2TokenService::Request> access_token_request_; |
293 | 298 |
| 299 // A delegate which controls details related to update manifest retrieval. |
| 300 scoped_ptr<ManifestFetchDataDelegate> manifest_fetch_data_delegate_; |
| 301 |
294 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); | 302 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); |
295 }; | 303 }; |
296 | 304 |
297 } // namespace extensions | 305 } // namespace extensions |
298 | 306 |
299 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ | 307 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
OLD | NEW |