Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / android_webview / browser / net / aw_network_delegate.cc
blob7d55045301d7e2958884cd6407a5a27ade2c8355
1 // Copyright (c) 2012 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.
5 #include "android_webview/browser/net/aw_network_delegate.h"
7 #include "android_webview/browser/aw_contents_io_thread_client.h"
8 #include "android_webview/browser/aw_cookie_access_policy.h"
9 #include "base/android/build_info.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/resource_request_info.h"
12 #include "net/base/net_errors.h"
13 #include "net/base/completion_callback.h"
14 #include "net/http/http_response_headers.h"
15 #include "net/proxy/proxy_info.h"
16 #include "net/proxy/proxy_server.h"
17 #include "net/url_request/url_request.h"
19 using content::BrowserThread;
21 namespace android_webview {
23 AwNetworkDelegate::AwNetworkDelegate() {
26 AwNetworkDelegate::~AwNetworkDelegate() {
29 int AwNetworkDelegate::OnBeforeURLRequest(
30 net::URLRequest* request,
31 const net::CompletionCallback& callback,
32 GURL* new_url) {
33 return net::OK;
36 int AwNetworkDelegate::OnBeforeSendHeaders(
37 net::URLRequest* request,
38 const net::CompletionCallback& callback,
39 net::HttpRequestHeaders* headers) {
41 DCHECK(headers);
42 headers->SetHeaderIfMissing(
43 "X-Requested-With",
44 base::android::BuildInfo::GetInstance()->package_name());
45 return net::OK;
48 void AwNetworkDelegate::OnSendHeaders(net::URLRequest* request,
49 const net::HttpRequestHeaders& headers) {
52 int AwNetworkDelegate::OnHeadersReceived(
53 net::URLRequest* request,
54 const net::CompletionCallback& callback,
55 const net::HttpResponseHeaders* original_response_headers,
56 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
57 GURL* allowed_unsafe_redirect_url) {
58 DCHECK_CURRENTLY_ON(BrowserThread::IO);
59 int render_process_id, render_frame_id;
60 if (original_response_headers->response_code() >= 400 &&
61 content::ResourceRequestInfo::GetRenderFrameForRequest(
62 request, &render_process_id, &render_frame_id)) {
63 scoped_ptr<AwContentsIoThreadClient> io_thread_client =
64 AwContentsIoThreadClient::FromID(render_process_id, render_frame_id);
65 if (io_thread_client.get()) {
66 io_thread_client->OnReceivedHttpError(request, original_response_headers);
69 return net::OK;
72 void AwNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
73 const GURL& new_location) {
76 void AwNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
79 void AwNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
80 int bytes_read) {
83 void AwNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
86 void AwNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
89 void AwNetworkDelegate::OnPACScriptError(int line_number,
90 const base::string16& error) {
93 net::NetworkDelegate::AuthRequiredResponse AwNetworkDelegate::OnAuthRequired(
94 net::URLRequest* request,
95 const net::AuthChallengeInfo& auth_info,
96 const AuthCallback& callback,
97 net::AuthCredentials* credentials) {
98 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
101 bool AwNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
102 const net::CookieList& cookie_list) {
103 return AwCookieAccessPolicy::GetInstance()->OnCanGetCookies(request,
104 cookie_list);
107 bool AwNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
108 const std::string& cookie_line,
109 net::CookieOptions* options) {
110 return AwCookieAccessPolicy::GetInstance()->OnCanSetCookie(request,
111 cookie_line,
112 options);
115 bool AwNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
116 const base::FilePath& path) const {
117 return true;
120 bool AwNetworkDelegate::OnCanThrottleRequest(
121 const net::URLRequest& request) const {
122 return false;
125 } // namespace android_webview