15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "base/basictypes.h" 9ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "base/memory/scoped_ptr.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 11ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochnamespace net { 12ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochclass ProxyConfigService; 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 15ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// Interface for a class that tracks proxy preferences. The purpose of the 16ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// concrete class is to track changes in the Preferences, to translates the 17ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// preferences to net::ProxyConfig and to push the result over to a 18ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch// net::ProxyConfigService onto the IO thread. 19ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochclass PrefProxyConfigTracker { 20ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch public: 21ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch PrefProxyConfigTracker(); 22ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual ~PrefProxyConfigTracker(); 23ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 24ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Creates a net::ProxyConfigService and keeps a pointer to it. After this 25ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // call, this tracker forwards any changes of proxy preferences to the created 26ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // ProxyConfigService. The returned ProxyConfigService must not be deleted 27ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // before DetachFromPrefService was called. Takes ownership of the passed 28ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // |base_service|, which can be NULL. This |base_service| provides the proxy 29ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // settings of the OS (except of ChromeOS). This must be called on the 30ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // UI thread. 31ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual scoped_ptr<net::ProxyConfigService> CreateTrackingProxyConfigService( 32ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch scoped_ptr<net::ProxyConfigService> base_service) = 0; 33ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 34ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Releases the PrefService passed upon construction and the |base_service| 35ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // passed to CreateTrackingProxyConfigService. This must be called on the UI 36ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // thread. 37ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void DetachFromPrefService() = 0; 38ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 39ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch private: 40ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTracker); 41ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch}; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_NET_PREF_PROXY_CONFIG_TRACKER_H_ 44