Home | History | Annotate | Download | only in prefs
      1 // Copyright (c) 2011 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 CHROME_BROWSER_PREFS_PROXY_CONFIG_DICTIONARY_H_
      6 #define CHROME_BROWSER_PREFS_PROXY_CONFIG_DICTIONARY_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/memory/scoped_ptr.h"
     13 #include "chrome/browser/prefs/proxy_prefs.h"
     14 
     15 class DictionaryValue;
     16 
     17 // Factory and wrapper for proxy config dictionaries that are stored
     18 // in the user preferences. The dictionary has the following structure:
     19 // {
     20 //   mode: string,
     21 //   server: string,
     22 //   pac_url: string,
     23 //   bypass_list: string
     24 // }
     25 // See proxy_config_dictionary.cc for the structure of the respective strings.
     26 class ProxyConfigDictionary {
     27  public:
     28   // Creates a deep copy of |dict| and leaves ownership to caller.
     29   explicit ProxyConfigDictionary(const DictionaryValue* dict);
     30   ~ProxyConfigDictionary();
     31 
     32   bool GetMode(ProxyPrefs::ProxyMode* out) const;
     33   bool GetPacUrl(std::string* out) const;
     34   bool GetProxyServer(std::string* out) const;
     35   bool GetBypassList(std::string* out) const;
     36   bool HasBypassList() const;
     37 
     38   static DictionaryValue* CreateDirect();
     39   static DictionaryValue* CreateAutoDetect();
     40   static DictionaryValue* CreatePacScript(const std::string& pac_url);
     41   static DictionaryValue* CreateFixedServers(
     42       const std::string& proxy_server,
     43       const std::string& bypass_list);
     44   static DictionaryValue* CreateSystem();
     45  private:
     46   static DictionaryValue* CreateDictionary(ProxyPrefs::ProxyMode mode,
     47                                            const std::string& pac_url,
     48                                            const std::string& proxy_server,
     49                                            const std::string& bypass_list);
     50 
     51   scoped_ptr<DictionaryValue> dict_;
     52 
     53   DISALLOW_COPY_AND_ASSIGN(ProxyConfigDictionary);
     54 };
     55 
     56 #endif  // CHROME_BROWSER_PREFS_PROXY_CONFIG_DICTIONARY_H_
     57