OLD | NEW |
| (Empty) |
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_FRAME_URLMON_URL_REQUEST_H_ | |
6 #define CHROME_FRAME_URLMON_URL_REQUEST_H_ | |
7 | |
8 #include <urlmon.h> | |
9 #include <atlbase.h> | |
10 #include <atlcom.h> | |
11 #include <map> | |
12 #include <string> | |
13 | |
14 #include "chrome_frame/plugin_url_request.h" | |
15 #include "chrome_frame/urlmon_moniker.h" | |
16 #include "chrome_frame/utils.h" | |
17 | |
18 namespace base { | |
19 class MessageLoop; | |
20 class Thread; | |
21 } | |
22 | |
23 class UrlmonUrlRequest; | |
24 | |
25 class UrlmonUrlRequestManager | |
26 : public PluginUrlRequestManager, | |
27 public PluginUrlRequestDelegate { | |
28 public: | |
29 // Contains the privacy information for all requests issued by this instance. | |
30 struct PrivacyInfo { | |
31 public: | |
32 struct PrivacyEntry { | |
33 PrivacyEntry() : flags(0) {} | |
34 std::wstring policy_ref; | |
35 int32 flags; | |
36 }; | |
37 | |
38 typedef std::map<std::wstring, PrivacyEntry> PrivacyRecords; | |
39 | |
40 PrivacyInfo() : privacy_impacted(false) {} | |
41 | |
42 bool privacy_impacted; | |
43 PrivacyRecords privacy_records; | |
44 }; | |
45 | |
46 UrlmonUrlRequestManager(); | |
47 ~UrlmonUrlRequestManager(); | |
48 | |
49 // Use specific bind context when Chrome request this url. | |
50 // Used from ChromeActiveDocument's implementation of IPersistMoniker::Load(). | |
51 void SetInfoForUrl(const std::wstring& url, | |
52 IMoniker* moniker, LPBC bind_context); | |
53 | |
54 // Returns a copy of the url privacy information for this instance. | |
55 PrivacyInfo privacy_info() { | |
56 return privacy_info_; | |
57 } | |
58 | |
59 virtual void AddPrivacyDataForUrl(const std::string& url, | |
60 const std::string& policy_ref, | |
61 int32 flags); | |
62 | |
63 // This function passes the window on which notifications are to be fired. | |
64 void put_notification_window(HWND window) { | |
65 notification_window_ = window; | |
66 } | |
67 | |
68 // This function passes information on whether ChromeFrame is running in | |
69 // privileged mode. | |
70 void set_privileged_mode(bool privileged_mode) { | |
71 privileged_mode_ = privileged_mode; | |
72 } | |
73 | |
74 void set_container(IUnknown* container) { | |
75 container_ = container; | |
76 } | |
77 | |
78 private: | |
79 friend class base::MessageLoop; | |
80 | |
81 // PluginUrlRequestManager implementation. | |
82 virtual PluginUrlRequestManager::ThreadSafeFlags GetThreadSafeFlags(); | |
83 | |
84 // This method is passed as a callback to UrlmonUrlRequest::TerminateBind. | |
85 // We simply forward moniker and bind_ctx to host ActiveX/ActiveDocument, | |
86 // so it may start NavigateWithBindContext. | |
87 void BindTerminated(IMoniker* moniker, IBindCtx* bind_ctx, | |
88 IStream* post_data, const char* request_headers); | |
89 | |
90 // Map for (request_id <-> UrlmonUrlRequest) | |
91 typedef std::map<int, scoped_refptr<UrlmonUrlRequest> > RequestMap; | |
92 RequestMap request_map_; | |
93 RequestMap background_request_map_; | |
94 | |
95 // The caller is responsible for acquiring any locks needed to access the | |
96 // request map. | |
97 scoped_refptr<UrlmonUrlRequest> LookupRequest(int request_id, | |
98 RequestMap* request_map); | |
99 // The background_request_map_ is referenced from multiple threads. Lock to | |
100 // synchronize access. | |
101 base::Lock background_resource_map_lock_; | |
102 | |
103 scoped_refptr<UrlmonUrlRequest> pending_request_; | |
104 scoped_ptr<base::Thread> background_thread_; | |
105 | |
106 bool stopping_; | |
107 | |
108 // Controls whether we download subresources on the page in a background | |
109 // worker thread. | |
110 bool background_worker_thread_enabled_; | |
111 | |
112 PrivacyInfo privacy_info_; | |
113 // The window to be used to fire notifications on. | |
114 HWND notification_window_; | |
115 // Set to true if the ChromeFrame instance is running in privileged mode. | |
116 bool privileged_mode_; | |
117 // A pointer to the containing object. We maintain a weak reference to avoid | |
118 // lifetime issues. | |
119 IUnknown* container_; | |
120 }; | |
121 | |
122 #endif // CHROME_FRAME_URLMON_URL_REQUEST_H_ | |
OLD | NEW |