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

Side by Side Diff: ios/web/shell/shell_network_delegate.cc

Issue 1149323004: Upstream the iOS web_shell and supporting code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-thread-impl
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/shell/browser/shell_network_delegate.h" 5 #include "ios/web/shell/shell_network_delegate.h"
6 6
7 #include "base/command_line.h"
8 #include "content/public/common/content_switches.h"
9 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
10 #include "net/base/static_cookie_policy.h"
11 #include "net/url_request/url_request.h"
12 8
13 namespace content { 9 namespace web {
14
15 namespace {
16 bool g_accept_all_cookies = true;
17 }
18 10
19 ShellNetworkDelegate::ShellNetworkDelegate() { 11 ShellNetworkDelegate::ShellNetworkDelegate() {
20 } 12 }
21 13
22 ShellNetworkDelegate::~ShellNetworkDelegate() { 14 ShellNetworkDelegate::~ShellNetworkDelegate() {
23 } 15 }
24 16
25 void ShellNetworkDelegate::SetAcceptAllCookies(bool accept) {
26 g_accept_all_cookies = accept;
27 }
28
29 int ShellNetworkDelegate::OnBeforeURLRequest( 17 int ShellNetworkDelegate::OnBeforeURLRequest(
30 net::URLRequest* request, 18 net::URLRequest* request,
31 const net::CompletionCallback& callback, 19 const net::CompletionCallback& callback,
32 GURL* new_url) { 20 GURL* new_url) {
33 return net::OK; 21 return net::OK;
34 } 22 }
35 23
36 int ShellNetworkDelegate::OnBeforeSendHeaders( 24 int ShellNetworkDelegate::OnBeforeSendHeaders(
37 net::URLRequest* request, 25 net::URLRequest* request,
38 const net::CompletionCallback& callback, 26 const net::CompletionCallback& callback,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired( 66 ShellNetworkDelegate::AuthRequiredResponse ShellNetworkDelegate::OnAuthRequired(
79 net::URLRequest* request, 67 net::URLRequest* request,
80 const net::AuthChallengeInfo& auth_info, 68 const net::AuthChallengeInfo& auth_info,
81 const AuthCallback& callback, 69 const AuthCallback& callback,
82 net::AuthCredentials* credentials) { 70 net::AuthCredentials* credentials) {
83 return AUTH_REQUIRED_RESPONSE_NO_ACTION; 71 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
84 } 72 }
85 73
86 bool ShellNetworkDelegate::OnCanGetCookies(const net::URLRequest& request, 74 bool ShellNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
87 const net::CookieList& cookie_list) { 75 const net::CookieList& cookie_list) {
88 net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? 76 return true;
89 net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
90 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
91 net::StaticCookiePolicy policy(policy_type);
92 int rv = policy.CanGetCookies(
93 request.url(), request.first_party_for_cookies());
94 return rv == net::OK;
95 } 77 }
96 78
97 bool ShellNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, 79 bool ShellNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
98 const std::string& cookie_line, 80 const std::string& cookie_line,
99 net::CookieOptions* options) { 81 net::CookieOptions* options) {
100 net::StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? 82 return true;
101 net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
102 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES;
103 net::StaticCookiePolicy policy(policy_type);
104 int rv = policy.CanSetCookie(
105 request.url(), request.first_party_for_cookies());
106 return rv == net::OK;
107 } 83 }
108 84
109 bool ShellNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, 85 bool ShellNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
110 const base::FilePath& path) const { 86 const base::FilePath& path) const {
111 return true; 87 return true;
112 } 88 }
113 89
114 bool ShellNetworkDelegate::OnCanThrottleRequest( 90 bool ShellNetworkDelegate::OnCanThrottleRequest(
115 const net::URLRequest& request) const { 91 const net::URLRequest& request) const {
116 return false; 92 return false;
117 } 93 }
118 94
119 bool ShellNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabled() const { 95 } // namespace web
120 return base::CommandLine::ForCurrentProcess()->HasSwitch(
121 switches::kEnableExperimentalWebPlatformFeatures);
122 }
123
124 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698