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