Home | History | Annotate | Download | only in browser
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_CONFIGURATOR_H_
      6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_CONFIGURATOR_H_
      7 
      8 #include <string>
      9 
     10 #include "base/macros.h"
     11 
     12 namespace data_reduction_proxy {
     13 
     14 // Interface for enabling and disabling the data reduction proxy configuration,
     15 // and for adding bypass rules. This is the interface that is used to set the
     16 // networking configuration that causes traffic to be proxied.
     17 class DataReductionProxyConfigurator {
     18  public:
     19   DataReductionProxyConfigurator() {}
     20   virtual ~DataReductionProxyConfigurator() {}
     21 
     22   // Enable the data reduction proxy. If |primary_restricted|, the
     23   // |primary_origin| may not be used. If |fallback_restricted|, the
     24   // |fallback_origin| may not be used. If both are restricted, then the
     25   // proxy configuration will be the same as when |Disable()| is called.
     26   // If |ssl_origin| is non-empty, it will be used used for HTTPS traffic.
     27   virtual void Enable(bool primary_restricted,
     28                       bool fallback_restricted,
     29                       const std::string& primary_origin,
     30                       const std::string& fallback_origin,
     31                       const std::string& ssl_origin) = 0;
     32 
     33   // Disable the data reduction proxy.
     34   virtual void Disable() = 0;
     35 
     36   // Adds a host pattern to bypass. This should follow the same syntax used
     37   // in net::ProxyBypassRules; that is, a hostname pattern, a hostname suffix
     38   // pattern, an IP literal, a CIDR block, or the magic string '<local>'.
     39   // Bypass settings persist for the life of this object and are applied
     40   // each time the proxy is enabled, but are not updated while it is enabled.
     41   virtual void AddHostPatternToBypass(const std::string& pattern) = 0;
     42 
     43   // Adds a URL pattern to bypass the proxy. The base implementation strips
     44   // everything in |pattern| after the first single slash and then treats it
     45   // as a hostname pattern.
     46   virtual void AddURLPatternToBypass(const std::string& pattern) = 0;
     47 
     48  private:
     49   DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfigurator);
     50 };
     51 
     52 }  // namespace data_reduction_proxy
     53 
     54 #endif  // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_CONFIGURATOR_H_
     55