123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // 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-CHROMIUM file.
- #include "brightray/browser/network_delegate.h"
- #include <string>
- #include <vector>
- #include "base/command_line.h"
- #include "base/strings/string_split.h"
- #include "net/base/load_flags.h"
- #include "net/base/net_errors.h"
- #include "net/url_request/url_request.h"
- namespace brightray {
- namespace {
- // Ignore the limit of 6 connections per host.
- const char kIgnoreConnectionsLimit[] = "ignore-connections-limit";
- } // namespace
- NetworkDelegate::NetworkDelegate() {
- auto* command_line = base::CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(kIgnoreConnectionsLimit)) {
- std::string value =
- command_line->GetSwitchValueASCII(kIgnoreConnectionsLimit);
- ignore_connections_limit_domains_ = base::SplitString(
- value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
- }
- }
- NetworkDelegate::~NetworkDelegate() {}
- int NetworkDelegate::OnBeforeURLRequest(net::URLRequest* request,
- const net::CompletionCallback& callback,
- GURL* new_url) {
- for (const auto& domain : ignore_connections_limit_domains_) {
- if (request->url().DomainIs(domain)) {
- // Allow unlimited concurrent connections.
- request->SetPriority(net::MAXIMUM_PRIORITY);
- request->SetLoadFlags(request->load_flags() | net::LOAD_IGNORE_LIMITS);
- break;
- }
- }
- return net::OK;
- }
- int NetworkDelegate::OnBeforeStartTransaction(
- net::URLRequest* request,
- const net::CompletionCallback& callback,
- net::HttpRequestHeaders* headers) {
- return net::OK;
- }
- void NetworkDelegate::OnStartTransaction(
- net::URLRequest* request,
- const net::HttpRequestHeaders& headers) {}
- void NetworkDelegate::OnBeforeSendHeaders(
- net::URLRequest* request,
- const net::ProxyInfo& proxy_info,
- const net::ProxyRetryInfoMap& proxy_retry_info,
- net::HttpRequestHeaders* headers) {}
- int NetworkDelegate::OnHeadersReceived(
- net::URLRequest* request,
- const net::CompletionCallback& callback,
- const net::HttpResponseHeaders* original_response_headers,
- scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
- GURL* allowed_unsafe_redirect_url) {
- return net::OK;
- }
- void NetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
- const GURL& new_location) {}
- void NetworkDelegate::OnResponseStarted(net::URLRequest* request) {}
- void NetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request,
- int64_t bytes_read) {}
- void NetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
- int64_t bytes_sent) {}
- void NetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {}
- void NetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {}
- void NetworkDelegate::OnPACScriptError(int line_number,
- const base::string16& error) {}
- NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired(
- net::URLRequest* request,
- const net::AuthChallengeInfo& auth_info,
- const AuthCallback& callback,
- net::AuthCredentials* credentials) {
- return AUTH_REQUIRED_RESPONSE_NO_ACTION;
- }
- bool NetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
- const net::CookieList& cookie_list) {
- return true;
- }
- bool NetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
- const std::string& cookie_line,
- net::CookieOptions* options) {
- return true;
- }
- bool NetworkDelegate::OnCanAccessFile(
- const net::URLRequest& request,
- const base::FilePath& original_path,
- const base::FilePath& absolute_path) const {
- return true;
- }
- bool NetworkDelegate::OnCanEnablePrivacyMode(
- const GURL& url,
- const GURL& first_party_for_cookies) const {
- return false;
- }
- bool NetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const {
- return true;
- }
- bool NetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader(
- const net::URLRequest& request,
- const GURL& target_url,
- const GURL& referrer_url) const {
- return false;
- }
- // TODO(deepak1556) : Enable after hooking into the reporting service
- // https://crbug.com/704259
- bool NetworkDelegate::OnCanQueueReportingReport(
- const url::Origin& origin) const {
- return false;
- }
- bool NetworkDelegate::OnCanSendReportingReport(
- const url::Origin& origin) const {
- return false;
- }
- bool NetworkDelegate::OnCanSetReportingClient(const url::Origin& origin,
- const GURL& endpoint) const {
- return false;
- }
- bool NetworkDelegate::OnCanUseReportingClient(const url::Origin& origin,
- const GURL& endpoint) const {
- return false;
- }
- } // namespace brightray
|