summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_webrequest_api.h
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 15:36:45 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 15:36:45 +0000
commit90449abd576c6153650b7201f68da897f05b8717 (patch)
treec7e55ce93c20b3d9031ce8fa94268714b02cdd19 /chrome/browser/extensions/extension_webrequest_api.h
parentd7b175e8762301a1bfca9d17681111bbf5bf5c0a (diff)
downloadchromium_src-90449abd576c6153650b7201f68da897f05b8717.zip
chromium_src-90449abd576c6153650b7201f68da897f05b8717.tar.gz
chromium_src-90449abd576c6153650b7201f68da897f05b8717.tar.bz2
webRequest.onAuthRequired listeners can provide authentication credentials.
onAuthRequired listeners that specify "blocking" in the extraInfoSpec can return authentication credentials [username and password] in the BlockingResponse. If these are provided, Chrome will use these credentials rather than showing a login prompt for the user. If "blocking" is not specified, or an authCredentials object is not present in the BlockingResponse, then a login prompt will be displayed. Warning: If the authentication credentials are invalid, the extension may still present credentials for subsequent challenges. This could lead to infinite loops of bad credentials being entered without user intervention. BUG=32056 TEST=Write an extension which does a blocking onAuthRequired and provides correct credentials, validate that it works. Review URL: http://codereview.chromium.org/8015004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_webrequest_api.h')
-rw-r--r--chrome/browser/extensions/extension_webrequest_api.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_webrequest_api.h b/chrome/browser/extensions/extension_webrequest_api.h
index 268a4c2..5196818 100644
--- a/chrome/browser/extensions/extension_webrequest_api.h
+++ b/chrome/browser/extensions/extension_webrequest_api.h
@@ -18,6 +18,7 @@
#include "chrome/common/extensions/url_pattern_set.h"
#include "ipc/ipc_message.h"
#include "net/base/completion_callback.h"
+#include "net/base/network_delegate.h"
#include "net/http/http_request_headers.h"
#include "webkit/glue/resource_type.h"
@@ -32,6 +33,7 @@ class StringValue;
}
namespace net {
+class AuthCredentials;
class AuthChallengeInfo;
class HostPortPair;
class HttpRequestHeaders;
@@ -104,6 +106,7 @@ class ExtensionWebRequestEventRouter {
scoped_ptr<net::HttpRequestHeaders> request_headers;
// Contains all header lines after the status line, lines are \n separated.
std::string response_headers_string;
+ scoped_ptr<net::AuthCredentials> auth_credentials;
EventResponse(const std::string& extension_id,
const base::Time& extension_install_time);
@@ -135,6 +138,9 @@ class ExtensionWebRequestEventRouter {
// Complete set of response headers that will replace the original ones.
scoped_refptr<net::HttpResponseHeaders> new_response_headers;
+ // Authentication Credentials to use.
+ scoped_ptr<net::AuthCredentials> auth_credentials;
+
EventResponseDelta(const std::string& extension_id,
const base::Time& extension_install_time);
~EventResponseDelta();
@@ -192,11 +198,18 @@ class ExtensionWebRequestEventRouter {
net::HttpResponseHeaders* original_response_headers,
scoped_refptr<net::HttpResponseHeaders>* override_response_headers);
- // Dispatches the onAuthRequired event.
- void OnAuthRequired(void* profile,
+ // Dispatches the OnAuthRequired event to any extensions whose filters match
+ // the given request. If the listener is not registered as "blocking", then
+ // AUTH_REQUIRED_RESPONSE_OK is returned. Otherwise,
+ // AUTH_REQUIRED_RESPONSE_IO_PENDING is returned and |callback| will be
+ // invoked later.
+ net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
+ void* profile,
ExtensionInfoMap* extension_info_map,
net::URLRequest* request,
- const net::AuthChallengeInfo& auth_info);
+ const net::AuthChallengeInfo& auth_info,
+ const net::NetworkDelegate::AuthCallback& callback,
+ net::AuthCredentials* credentials);
// Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests
// only.
@@ -347,6 +360,16 @@ class ExtensionWebRequestEventRouter {
BlockedRequest* request,
std::list<std::string>* conflicting_extensions) const;
+ // Merge the responses of blocked onAuthRequired handlers. The first
+ // registered listener that supplies authentication credentials in a response,
+ // if any, will have its authentication credentials used. |request| must be
+ // non-NULL, and contain |deltas| that are sorted in decreasing order of
+ // precedence.
+ // Returns whether authentication credentials are set.
+ bool MergeOnAuthRequiredResponses(
+ BlockedRequest* request,
+ std::list<std::string>* conflicting_extensions) const;
+
// A map for each profile that maps an event name to a set of extensions that
// are listening to that event.
ListenerMap listeners_;