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

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: 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..14c5881187a6e5de2b6d012375de6133a89a0672 100644
--- a/chrome/browser/extensions/updater/extension_downloader.h
+++ b/chrome/browser/extensions/updater/extension_downloader.h
@@ -26,6 +26,8 @@
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
+class IdentityProvider;
+
namespace net {
class URLFetcher;
class URLRequestContextGetter;
@@ -44,6 +46,7 @@ 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|
@@ -52,9 +55,12 @@ class ExtensionUpdaterTest;
class ExtensionDownloader : public net::URLFetcherDelegate {
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 +136,14 @@ 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;
};
// Helper for AddExtension() and AddPendingExtension().
@@ -204,6 +216,16 @@ 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
Roger Tawa OOO till Jul 10th 2014/08/07 01:35:15 true| --> |true|
Ken Rockot(use gerrit already) 2014/08/07 16:49:09 Done.
+ // not related to authentication, leaving the ExtensionFetch data unmodified.
+ bool IterateFetchCredentialsAfterFailure(ExtensionFetch* fetch,
+ const net::URLRequestStatus& status,
+ int response_code);
+
+ // Receives an OAuth2 token to authenticate a Webstore CRX fetch.
+ void OnWebstoreOAuth2TokenReceived(bool success, const std::string& token);
Roger Tawa OOO till Jul 10th 2014/08/07 01:35:15 Nit: rename |token| to |access_token|, so its not
+
// 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 +262,9 @@ class ExtensionDownloader : public net::URLFetcherDelegate {
// Cache for .crx files.
ExtensionCache* extension_cache_;
+ // Acquires access tokens for webstore download URLs.
+ scoped_ptr<WebstoreOAuth2TokenProvider> webstore_token_provider_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader);
};

Powered by Google App Engine
This is Rietveld 408576698