| 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" |
| 22 #include "chrome/browser/extensions/updater/request_queue.h" | 23 #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; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // Schedules an update check of the blacklist. | 93 // Schedules an update check of the blacklist. |
| 94 void StartBlacklistUpdate(const std::string& version, | 94 void StartBlacklistUpdate(const std::string& version, |
| 95 const ManifestFetchData::PingData& ping_data, | 95 const ManifestFetchData::PingData& ping_data, |
| 96 int request_id); | 96 int request_id); |
| 97 | 97 |
| 98 // Sets an IdentityProvider to be used for OAuth2 authentication on protected | 98 // Sets an IdentityProvider to be used for OAuth2 authentication on protected |
| 99 // Webstore downloads. | 99 // Webstore downloads. |
| 100 void SetWebstoreIdentityProvider( | 100 void SetWebstoreIdentityProvider( |
| 101 scoped_ptr<IdentityProvider> identity_provider); | 101 scoped_ptr<IdentityProvider> identity_provider); |
| 102 | 102 |
| 103 void set_brand_code(const std::string& brand_code) { | |
| 104 brand_code_ = brand_code; | |
| 105 } | |
| 106 | |
| 107 void set_manifest_query_params(const std::string& params) { | |
| 108 manifest_query_params_ = params; | |
| 109 } | |
| 110 | |
| 111 void set_ping_enabled_domain(const std::string& domain) { | |
| 112 ping_enabled_domain_ = domain; | |
| 113 } | |
| 114 | |
| 115 void set_enable_extra_update_metrics(bool enable) { | |
| 116 enable_extra_update_metrics_ = enable; | |
| 117 } | |
| 118 | |
| 119 // These are needed for unit testing, to help identify the correct mock | 103 // These are needed for unit testing, to help identify the correct mock |
| 120 // URLFetcher objects. | 104 // URLFetcher objects. |
| 121 static const int kManifestFetcherId = 1; | 105 static const int kManifestFetcherId = 1; |
| 122 static const int kExtensionFetcherId = 2; | 106 static const int kExtensionFetcherId = 2; |
| 123 | 107 |
| 124 // Update AppID for extension blacklist. | 108 // Update AppID for extension blacklist. |
| 125 static const char kBlacklistAppID[]; | 109 static const char kBlacklistAppID[]; |
| 126 | 110 |
| 127 static const int kMaxRetries = 10; | 111 static const int kMaxRetries = 10; |
| 128 | 112 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 const net::URLRequestStatus& status, | 237 const net::URLRequestStatus& status, |
| 254 int response_code); | 238 int response_code); |
| 255 | 239 |
| 256 // OAuth2TokenService::Consumer implementation. | 240 // OAuth2TokenService::Consumer implementation. |
| 257 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 241 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 258 const std::string& access_token, | 242 const std::string& access_token, |
| 259 const base::Time& expiration_time) OVERRIDE; | 243 const base::Time& expiration_time) OVERRIDE; |
| 260 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 244 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 261 const GoogleServiceAuthError& error) OVERRIDE; | 245 const GoogleServiceAuthError& error) OVERRIDE; |
| 262 | 246 |
| 263 ManifestFetchData* CreateManifestFetchData(const GURL& update_url, | |
| 264 int request_id); | |
| 265 | |
| 266 // The delegate that receives the crx files downloaded by the | 247 // The delegate that receives the crx files downloaded by the |
| 267 // ExtensionDownloader, and that fills in optional ping and update url data. | 248 // ExtensionDownloader, and that fills in optional ping and update url data. |
| 268 ExtensionDownloaderDelegate* delegate_; | 249 ExtensionDownloaderDelegate* delegate_; |
| 269 | 250 |
| 270 // The request context to use for the URLFetchers. | 251 // The request context to use for the URLFetchers. |
| 271 scoped_refptr<net::URLRequestContextGetter> request_context_; | 252 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 272 | 253 |
| 273 // Used to create WeakPtrs to |this|. | 254 // Used to create WeakPtrs to |this|. |
| 274 base::WeakPtrFactory<ExtensionDownloader> weak_ptr_factory_; | 255 base::WeakPtrFactory<ExtensionDownloader> weak_ptr_factory_; |
| 275 | 256 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 303 // download requests. May be NULL. | 284 // download requests. May be NULL. |
| 304 scoped_ptr<IdentityProvider> identity_provider_; | 285 scoped_ptr<IdentityProvider> identity_provider_; |
| 305 | 286 |
| 306 // A Webstore download-scoped access token for the |identity_provider_|'s | 287 // A Webstore download-scoped access token for the |identity_provider_|'s |
| 307 // active account, if any. | 288 // active account, if any. |
| 308 std::string access_token_; | 289 std::string access_token_; |
| 309 | 290 |
| 310 // A pending token fetch request. | 291 // A pending token fetch request. |
| 311 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 292 scoped_ptr<OAuth2TokenService::Request> access_token_request_; |
| 312 | 293 |
| 313 // Brand code to include with manifest fetch queries if sending ping data. | |
| 314 std::string brand_code_; | |
| 315 | |
| 316 // Baseline parameters to include with manifest fetch queries. | |
| 317 std::string manifest_query_params_; | |
| 318 | |
| 319 // Domain to enable ping data. Ping data will be sent with manifest fetches | |
| 320 // to update URLs which match this domain. Defaults to empty (no domain). | |
| 321 std::string ping_enabled_domain_; | |
| 322 | |
| 323 // Indicates whether or not extra metrics should be included with ping data. | |
| 324 // Defaults to |false|. | |
| 325 bool enable_extra_update_metrics_; | |
| 326 | |
| 327 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); | 294 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); |
| 328 }; | 295 }; |
| 329 | 296 |
| 330 } // namespace extensions | 297 } // namespace extensions |
| 331 | 298 |
| 332 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ | 299 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
| OLD | NEW |