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

Unified Diff: chrome/browser/extensions/updater/extension_downloader.h

Issue 434493002: OAuth2 support for Webstore downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ExternalCache on chromeos Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/updater/extension_downloader.h
diff --git a/chrome/browser/extensions/updater/extension_downloader.h b/chrome/browser/extensions/updater/extension_downloader.h
index a40427da068a7daf901ac88af19dd33419202bcb..244f379a218c38c5c48323c4302b86b08780bd67 100644
--- a/chrome/browser/extensions/updater/extension_downloader.h
+++ b/chrome/browser/extensions/updater/extension_downloader.h
@@ -23,9 +23,12 @@
#include "chrome/browser/extensions/updater/request_queue.h"
#include "chrome/common/extensions/update_manifest.h"
#include "extensions/common/extension.h"
+#include "google_apis/gaia/oauth2_token_service.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
+class IdentityProvider;
+
namespace net {
class URLFetcher;
class URLRequestContextGetter;
@@ -44,17 +47,23 @@ struct UpdateDetails {
class ExtensionCache;
class ExtensionUpdaterTest;
+class WebstoreOAuth2TokenProvider;
// A class that checks for updates of a given list of extensions, and downloads
// the crx file when updates are found. It uses a |ExtensionDownloaderDelegate|
// that takes ownership of the downloaded crx files, and handles events during
// the update check.
-class ExtensionDownloader : public net::URLFetcherDelegate {
+class ExtensionDownloader
+ : public net::URLFetcherDelegate,
+ public OAuth2TokenService::Consumer {
public:
// |delegate| is stored as a raw pointer and must outlive the
- // ExtensionDownloader.
+ // ExtensionDownloader. |webstore_identity_provider| may be NULL if this
+ // ExtensionDownloader does not need OAuth2 support; if not NULL, the
+ // given IdentityProvider must outlive this ExtensionDownloader.
ExtensionDownloader(ExtensionDownloaderDelegate* delegate,
- net::URLRequestContextGetter* request_context);
+ net::URLRequestContextGetter* request_context,
+ IdentityProvider* webstore_identity_provider);
virtual ~ExtensionDownloader();
// Adds |extension| to the list of extensions to check for updates.
@@ -130,8 +139,18 @@ class ExtensionDownloader : public net::URLFetcherDelegate {
std::string version;
std::set<int> request_ids;
- // Indicates whether or not the fetch is known to require credentials.
- bool is_protected;
+ enum CredentialsMode {
+ CREDENTIALS_NONE = 0,
+ CREDENTIALS_OAUTH2_TOKEN,
+ CREDENTIALS_COOKIES,
+ };
+
+ // Indicates the type of credentials to include with this fetch.
+ CredentialsMode credentials;
+
+ // Counts the number of times OAuth2 authentication has been attempted for
+ // this fetch.
+ int oauth2_attempt_count;
};
// Helper for AddExtension() and AddPendingExtension().
@@ -204,6 +223,20 @@ class ExtensionDownloader : public net::URLFetcherDelegate {
const base::FilePath& crx_path,
bool file_ownership_passed);
+ // Potentially updates an ExtensionFetch's authentication state and returns
+ // |true| if the fetch should be retried. Returns |false| if the failure was
+ // not related to authentication, leaving the ExtensionFetch data unmodified.
+ bool IterateFetchCredentialsAfterFailure(ExtensionFetch* fetch,
+ const net::URLRequestStatus& status,
+ int response_code);
+
+ // OAuth2TokenService::Consumer implementation.
+ virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
+ const std::string& access_token,
+ const base::Time& expiration_time) OVERRIDE;
+ virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
+ const GoogleServiceAuthError& error) OVERRIDE;
+
// The delegate that receives the crx files downloaded by the
// ExtensionDownloader, and that fills in optional ping and update url data.
ExtensionDownloaderDelegate* delegate_;
@@ -240,6 +273,17 @@ class ExtensionDownloader : public net::URLFetcherDelegate {
// Cache for .crx files.
ExtensionCache* extension_cache_;
+ // An IdentityProvider which may be used for authentication on protected
+ // download requests. May be NULL.
+ IdentityProvider* identity_provider_;
+
+ // A Webstore download-scoped access token for the |identity_provider_|'s
+ // active account, if any.
+ std::string access_token_;
+
+ // A pending token fetch request.
+ scoped_ptr<OAuth2TokenService::Request> access_token_request_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader);
};
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/updater/extension_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698