Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: chrome_frame/np_proxy_service.h

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/np_event_listener.cc ('k') | chrome_frame/np_proxy_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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_FRAME_NP_PROXY_SERVICE_H_
6 #define CHROME_FRAME_NP_PROXY_SERVICE_H_
7
8 #include <string>
9 #include <vector>
10 #include "base/values.h"
11 #include "base/scoped_ptr.h"
12
13 // Avoid conflicts with basictypes and the gecko sdk.
14 // (different definitions of uint32).
15 #define NO_NSPR_10_SUPPORT
16
17 #include "chrome_frame/chrome_frame_automation.h"
18 #include "chrome_frame/ns_associate_iid_win.h"
19 #include "chrome_frame/ns_isupports_impl.h"
20 #include "chrome_frame/scoped_ns_ptr_win.h"
21 #include "third_party/WebKit/WebCore/bridge/npapi.h"
22 #include "third_party/xulrunner-sdk/win/include/xpcom/nsIObserver.h"
23 #include "third_party/xulrunner-sdk/win/include/pref/nsIPrefBranch2.h"
24 #include "third_party/xulrunner-sdk/win/include/pref/nsIPrefService.h"
25 #include "third_party/xulrunner-sdk/win/include/xpcom/nsIServiceManager.h"
26
27 ASSOCIATE_IID(NS_IOBSERVER_IID_STR, nsIObserver);
28 ASSOCIATE_IID(NS_ISERVICEMANAGER_IID_STR, nsIServiceManager);
29 ASSOCIATE_IID(NS_IPREFSERVICE_IID_STR, nsIPrefService);
30 ASSOCIATE_IID(NS_IPREFBRANCH2_IID_STR, nsIPrefBranch2);
31
32 class nsIServiceManager;
33 class nsIPrefService;
34 class nsIPrefBranch2;
35
36 // This class reads in proxy settings from firefox.
37 // TODO(robertshield): The change notification code is currently broken.
38 // Fix it and implement calling back through to the automation proxy with
39 // proxy updates.
40 class NpProxyService : public NsISupportsImplBase<NpProxyService>,
41 public nsIObserver {
42 public:
43 // These values correspond to the integer network.proxy.type preference.
44 enum ProxyConfigType {
45 PROXY_CONFIG_DIRECT,
46 PROXY_CONFIG_MANUAL,
47 PROXY_CONFIG_PAC,
48 PROXY_CONFIG_DIRECT4X,
49 PROXY_CONFIG_WPAD,
50 PROXY_CONFIG_SYSTEM, // use system settings if available, otherwise DIRECT
51 PROXY_CONFIG_LAST
52 };
53
54 // nsISupports
55 NS_IMETHODIMP_(nsrefcnt) AddRef(void) {
56 return NsISupportsImplBase<NpProxyService>::AddRef();
57 }
58
59 NS_IMETHODIMP_(nsrefcnt) Release(void) {
60 return NsISupportsImplBase<NpProxyService>::Release();
61 }
62
63 NS_IMETHOD QueryInterface(REFNSIID iid, void** ptr) {
64 nsresult res =
65 NsISupportsImplBase<NpProxyService>::QueryInterface(iid, ptr);
66 if (NS_FAILED(res) &&
67 memcmp(&iid, &__uuidof(nsIObserver), sizeof(nsIID)) == 0) {
68 *ptr = static_cast<nsIObserver*>(this);
69 AddRef();
70 res = NS_OK;
71 }
72 return res;
73 }
74
75 // nsIObserver
76 NS_IMETHOD Observe(nsISupports* subject, const char* topic,
77 const PRUnichar* data);
78
79 NpProxyService();
80 ~NpProxyService();
81
82 virtual bool Initialize(NPP instance,
83 ChromeFrameAutomationClient* automation_client);
84 bool UnInitialize();
85
86 // Places the current Firefox settings as a JSON string suitable for posting
87 // over to Chromium into output. Returns true if the settings were correctly
88 // serialized into a JSON string, false otherwise.
89 // TODO(robertshield): I haven't yet nailed down how much of this should go
90 // here and how much should go in the AutomationProxy. Will do that in a
91 // near-future patch.
92 bool GetProxyValueJSONString(std::string* output);
93
94 private:
95 bool InitializePrefBranch(nsIPrefService* pref_service);
96 bool ReadProxySettings(nsIPrefBranch* pref_branch);
97
98 std::string GetStringPref(nsIPrefBranch* pref_branch, const char* pref_name);
99 int GetIntPref(nsIPrefBranch* pref_branch, const char* pref_name);
100 bool GetBoolPref(nsIPrefBranch* pref_branch, const char* pref_name);
101
102 void Reset();
103 DictionaryValue* BuildProxyValueSet();
104
105 ChromeFrameAutomationClient* automation_client_;
106
107 ScopedNsPtr<nsIServiceManager> service_manager_;
108 ScopedNsPtr<nsIPrefService> pref_service_;
109 ScopedNsPtr<nsIPrefBranch2> observer_pref_branch_;
110
111 struct ProxyNames {
112 // Proxy type (http, https, ftp, etc...).
113 const char* chrome_scheme;
114 // Firefox preference name of the URL for this proxy type.
115 const char* pref_name;
116 // Firefox preference name for the port for this proxy type.
117 const char* port_pref_name;
118 };
119 static const ProxyNames kProxyInfo[];
120
121 struct ManualProxyEntry {
122 std::string scheme;
123 std::string url;
124 int port;
125 };
126 typedef std::vector<ManualProxyEntry> ManualProxyList;
127
128 bool system_config_;
129 bool auto_detect_;
130 bool no_proxy_;
131 int type_;
132 std::string pac_url_;
133 std::string proxy_bypass_list_;
134 ManualProxyList manual_proxies_;
135 };
136
137 #endif // CHROME_FRAME_NP_PROXY_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome_frame/np_event_listener.cc ('k') | chrome_frame/np_proxy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698