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

Side by Side Diff: headless/lib/browser/headless_network_delegate.cc

Issue 1674263002: headless: Initial headless embedder API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add pak file generation. Created 4 years, 10 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "headless/lib/browser/headless_network_delegate.h"
6
7 #include "base/command_line.h"
8 #include "base/strings/string_util.h"
9 #include "content/public/common/content_switches.h"
10 #include "net/base/net_errors.h"
11 #include "net/base/static_cookie_policy.h"
12 #include "net/url_request/url_request.h"
13
14 namespace headless {
15
16 HeadlessNetworkDelegate::HeadlessNetworkDelegate() {}
17
18 HeadlessNetworkDelegate::~HeadlessNetworkDelegate() {}
19
20 int HeadlessNetworkDelegate::OnBeforeURLRequest(
21 net::URLRequest* request,
22 const net::CompletionCallback& callback,
23 GURL* new_url) {
24 return net::OK;
25 }
26
27 int HeadlessNetworkDelegate::OnBeforeSendHeaders(
28 net::URLRequest* request,
29 const net::CompletionCallback& callback,
30 net::HttpRequestHeaders* headers) {
31 return net::OK;
32 }
33
34 void HeadlessNetworkDelegate::OnSendHeaders(
35 net::URLRequest* request,
36 const net::HttpRequestHeaders& headers) {}
37
38 int HeadlessNetworkDelegate::OnHeadersReceived(
39 net::URLRequest* request,
40 const net::CompletionCallback& callback,
41 const net::HttpResponseHeaders* original_response_headers,
42 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
43 GURL* allowed_unsafe_redirect_url) {
44 return net::OK;
45 }
46
47 void HeadlessNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
48 const GURL& new_location) {}
49
50 void HeadlessNetworkDelegate::OnResponseStarted(net::URLRequest* request) {}
51
52 void HeadlessNetworkDelegate::OnCompleted(net::URLRequest* request,
53 bool started) {}
54
55 void HeadlessNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {}
56
57 void HeadlessNetworkDelegate::OnPACScriptError(int line_number,
58 const base::string16& error) {}
59
60 HeadlessNetworkDelegate::AuthRequiredResponse
61 HeadlessNetworkDelegate::OnAuthRequired(net::URLRequest* request,
62 const net::AuthChallengeInfo& auth_info,
63 const AuthCallback& callback,
64 net::AuthCredentials* credentials) {
65 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
66 }
67
68 bool HeadlessNetworkDelegate::OnCanGetCookies(
69 const net::URLRequest& request,
70 const net::CookieList& cookie_list) {
71 // TODO(skyostil): Make this configurable.
72 net::StaticCookiePolicy::Type policy_type =
73 net::StaticCookiePolicy::ALLOW_ALL_COOKIES;
74 net::StaticCookiePolicy policy(policy_type);
75 int rv =
76 policy.CanGetCookies(request.url(), request.first_party_for_cookies());
77 return rv == net::OK;
78 }
79
80 bool HeadlessNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
81 const std::string& cookie_line,
82 net::CookieOptions* options) {
83 // TODO(skyostil): Make this configurable.
84 net::StaticCookiePolicy::Type policy_type =
85 net::StaticCookiePolicy::ALLOW_ALL_COOKIES;
86 net::StaticCookiePolicy policy(policy_type);
87 int rv =
88 policy.CanSetCookie(request.url(), request.first_party_for_cookies());
89 return rv == net::OK;
90 }
91
92 bool HeadlessNetworkDelegate::OnCanAccessFile(
93 const net::URLRequest& request,
94 const base::FilePath& path) const {
95 // TODO(skyostil): Make this configurable.
96 return true;
97 }
98
99 bool HeadlessNetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
100 return base::CommandLine::ForCurrentProcess()->HasSwitch(
101 switches::kEnableExperimentalWebPlatformFeatures);
102 }
103
104 bool HeadlessNetworkDelegate::OnAreStrictSecureCookiesEnabled() const {
105 return OnAreExperimentalCookieFeaturesEnabled();
106 }
107
108 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698