summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-29 08:18:17 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-29 08:18:17 +0000
commit33bc28352e9ac4f750163f15f10f2625d1e1256f (patch)
tree0fc85442a293ff21321543a03542a01000620b1b
parentc488e1e6549cacff899d47d9515d211b725d502f (diff)
downloadchromium_src-33bc28352e9ac4f750163f15f10f2625d1e1256f.zip
chromium_src-33bc28352e9ac4f750163f15f10f2625d1e1256f.tar.gz
chromium_src-33bc28352e9ac4f750163f15f10f2625d1e1256f.tar.bz2
Add ShellNetworkDelegate so content_shell can use cookies (again)
BUG=none TEST=try to log in to some site using content_shell Review URL: https://chromiumcodereview.appspot.com/9701023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129589 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/content_shell.gypi2
-rw-r--r--content/shell/shell_network_delegate.cc85
-rw-r--r--content/shell/shell_network_delegate.h62
-rw-r--r--content/shell/shell_url_request_context_getter.cc6
-rw-r--r--content/shell/shell_url_request_context_getter.h2
5 files changed, 155 insertions, 2 deletions
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index 49fdafb..47a5c0b 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -87,6 +87,8 @@
'shell/shell_main_delegate.h',
'shell/shell_messages.cc',
'shell/shell_messages.h',
+ 'shell/shell_network_delegate.cc',
+ 'shell/shell_network_delegate.h',
'shell/shell_render_process_observer.cc',
'shell/shell_render_process_observer.h',
'shell/shell_render_view_host_observer.cc',
diff --git a/content/shell/shell_network_delegate.cc b/content/shell/shell_network_delegate.cc
new file mode 100644
index 0000000..91bd349
--- /dev/null
+++ b/content/shell/shell_network_delegate.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/shell_network_delegate.h"
+
+#include "net/base/net_errors.h"
+
+namespace content {
+
+ShellNetworkDelegate::ShellNetworkDelegate() {
+}
+
+ShellNetworkDelegate::~ShellNetworkDelegate() {
+}
+
+int ShellNetworkDelegate::OnBeforeURLRequest(
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ GURL* new_url) {
+ return net::OK;
+}
+
+int ShellNetworkDelegate::OnBeforeSendHeaders(
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpRequestHeaders* headers) {
+ return net::OK;
+}
+
+void ShellNetworkDelegate::OnSendHeaders(
+ net::URLRequest* request,
+ const net::HttpRequestHeaders& headers) {
+}
+
+int ShellNetworkDelegate::OnHeadersReceived(
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpResponseHeaders* original_response_headers,
+ scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
+ return net::OK;
+}
+
+void ShellNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
+ const GURL& new_location) {
+}
+
+void ShellNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
+}
+
+void ShellNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
+ int bytes_read) {
+}
+
+void ShellNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
+}
+
+void ShellNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
+}
+
+void ShellNetworkDelegate::OnPACScriptError(int line_number,
+ const string16& error) {
+}
+
+ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired(
+ net::URLRequest* request,
+ const net::AuthChallengeInfo& auth_info,
+ const AuthCallback& callback,
+ net::AuthCredentials* credentials) {
+ return AUTH_REQUIRED_RESPONSE_NO_ACTION;
+}
+
+bool ShellNetworkDelegate::CanGetCookies(
+ const net::URLRequest* request,
+ const net::CookieList& cookie_list) {
+ return true;
+}
+
+bool ShellNetworkDelegate::CanSetCookie(const net::URLRequest* request,
+ const std::string& cookie_line,
+ net::CookieOptions* options) {
+ return true;
+}
+
+} // namespace content
diff --git a/content/shell/shell_network_delegate.h b/content/shell/shell_network_delegate.h
new file mode 100644
index 0000000..c9b92f8
--- /dev/null
+++ b/content/shell/shell_network_delegate.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_SHELL_SHELL_NETWORK_DELEGATE_H_
+#define CONTENT_SHELL_SHELL_NETWORK_DELEGATE_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "net/base/network_delegate.h"
+
+namespace content {
+
+class ShellNetworkDelegate : public net::NetworkDelegate {
+ public:
+ ShellNetworkDelegate();
+ virtual ~ShellNetworkDelegate();
+
+ private:
+ // net::NetworkDelegate implementation.
+ virtual int OnBeforeURLRequest(net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ GURL* new_url) OVERRIDE;
+ virtual int OnBeforeSendHeaders(net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpRequestHeaders* headers) OVERRIDE;
+ virtual void OnSendHeaders(net::URLRequest* request,
+ const net::HttpRequestHeaders& headers) OVERRIDE;
+ virtual int OnHeadersReceived(
+ net::URLRequest* request,
+ const net::CompletionCallback& callback,
+ net::HttpResponseHeaders* original_response_headers,
+ scoped_refptr<net::HttpResponseHeaders>*
+ override_response_headers) OVERRIDE;
+ virtual void OnBeforeRedirect(net::URLRequest* request,
+ const GURL& new_location) OVERRIDE;
+ virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
+ virtual void OnRawBytesRead(const net::URLRequest& request,
+ int bytes_read) OVERRIDE;
+ virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
+ virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
+ virtual void OnPACScriptError(int line_number,
+ const string16& error) OVERRIDE;
+ virtual AuthRequiredResponse OnAuthRequired(
+ net::URLRequest* request,
+ const net::AuthChallengeInfo& auth_info,
+ const AuthCallback& callback,
+ net::AuthCredentials* credentials) OVERRIDE;
+ virtual bool CanGetCookies(
+ const net::URLRequest* request,
+ const net::CookieList& cookie_list) OVERRIDE;
+ virtual bool CanSetCookie(const net::URLRequest* request,
+ const std::string& cookie_line,
+ net::CookieOptions* options) OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellNetworkDelegate);
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_SHELL_NETWORK_DELEGATE_H_
diff --git a/content/shell/shell_url_request_context_getter.cc b/content/shell/shell_url_request_context_getter.cc
index e8ff16c..4270006 100644
--- a/content/shell/shell_url_request_context_getter.cc
+++ b/content/shell/shell_url_request_context_getter.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/string_split.h"
#include "content/public/browser/browser_thread.h"
+#include "content/shell/shell_network_delegate.h"
#include "net/base/cert_verifier.h"
#include "net/base/default_server_bound_cert_store.h"
#include "net/base/host_resolver.h"
@@ -49,8 +50,9 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
if (!url_request_context_) {
url_request_context_ = new net::URLRequestContext();
+ network_delegate_.reset(new ShellNetworkDelegate);
+ url_request_context_->set_network_delegate(network_delegate_.get());
storage_.reset(new net::URLRequestContextStorage(url_request_context_));
-
storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL)));
@@ -92,7 +94,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
"", // ssl_session_cache_shard
url_request_context_->ssl_config_service(),
url_request_context_->http_auth_handler_factory(),
- NULL, // network_delegate
+ url_request_context_->network_delegate(),
url_request_context_->http_server_properties(),
NULL,
main_backend);
diff --git a/content/shell/shell_url_request_context_getter.h b/content/shell/shell_url_request_context_getter.h
index 7a7b8e7..9f70dc6 100644
--- a/content/shell/shell_url_request_context_getter.h
+++ b/content/shell/shell_url_request_context_getter.h
@@ -16,6 +16,7 @@ class MessageLoop;
namespace net {
class HostResolver;
+class NetworkDelegate;
class ProxyConfigService;
class URLRequestContextStorage;
}
@@ -46,6 +47,7 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter {
scoped_refptr<net::URLRequestContext> url_request_context_;
scoped_ptr<net::URLRequestContextStorage> storage_;
+ scoped_ptr<net::NetworkDelegate> network_delegate_;
DISALLOW_COPY_AND_ASSIGN(ShellURLRequestContextGetter);
};