Fullscreen support for Lion.
[chromium-blink-merge.git] / chrome_frame / urlmon_url_request.h
blob496c33d53ae5ab227c29e4f2965b04aab1374ac9
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.
5 #ifndef CHROME_FRAME_URLMON_URL_REQUEST_H_
6 #define CHROME_FRAME_URLMON_URL_REQUEST_H_
8 #include <urlmon.h>
9 #include <atlbase.h>
10 #include <atlcom.h>
11 #include <map>
12 #include <string>
14 #include "base/threading/thread.h"
15 #include "chrome_frame/plugin_url_request.h"
16 #include "chrome_frame/urlmon_moniker.h"
17 #include "chrome_frame/utils.h"
19 class UrlmonUrlRequest;
21 class UrlmonUrlRequestManager
22 : public PluginUrlRequestManager,
23 public PluginUrlRequestDelegate {
24 public:
25 // Contains the privacy information for all requests issued by this instance.
26 struct PrivacyInfo {
27 public:
28 struct PrivacyEntry {
29 PrivacyEntry() : flags(0) {}
30 std::wstring policy_ref;
31 int32 flags;
34 typedef std::map<std::wstring, PrivacyEntry> PrivacyRecords;
36 PrivacyInfo() : privacy_impacted(false) {}
38 bool privacy_impacted;
39 PrivacyRecords privacy_records;
42 UrlmonUrlRequestManager();
43 ~UrlmonUrlRequestManager();
45 // Use specific bind context when Chrome request this url.
46 // Used from ChromeActiveDocument's implementation of IPersistMoniker::Load().
47 void SetInfoForUrl(const std::wstring& url,
48 IMoniker* moniker, LPBC bind_context);
50 // Returns a copy of the url privacy information for this instance.
51 PrivacyInfo privacy_info() {
52 return privacy_info_;
55 virtual void AddPrivacyDataForUrl(const std::string& url,
56 const std::string& policy_ref,
57 int32 flags);
59 // This function passes the window on which notifications are to be fired.
60 void put_notification_window(HWND window) {
61 notification_window_ = window;
64 // This function passes information on whether ChromeFrame is running in
65 // privileged mode.
66 void set_privileged_mode(bool privileged_mode) {
67 privileged_mode_ = privileged_mode;
70 void set_container(IUnknown* container) {
71 container_ = container;
74 private:
75 friend class MessageLoop;
76 friend struct RunnableMethodTraits<UrlmonUrlRequestManager>;
77 static bool ImplementsThreadSafeReferenceCounting() { return true; }
78 void AddRef() {}
79 void Release() {}
81 // PluginUrlRequestManager implementation.
82 virtual PluginUrlRequestManager::ThreadSafeFlags GetThreadSafeFlags();
83 virtual void StartRequest(int request_id,
84 const AutomationURLRequest& request_info);
85 virtual void ReadRequest(int request_id, int bytes_to_read);
86 virtual void EndRequest(int request_id);
87 virtual void DownloadRequestInHost(int request_id);
88 virtual void StopAll();
89 virtual void GetCookiesForUrl(const GURL& url, int cookie_id);
90 virtual void SetCookiesForUrl(const GURL& url, const std::string& cookie);
92 // PluginUrlRequestDelegate implementation
93 virtual void OnResponseStarted(int request_id, const char* mime_type,
94 const char* headers, int size,
95 base::Time last_modified,
96 const std::string& redirect_url,
97 int redirect_status,
98 const net::HostPortPair& socket_address);
99 virtual void OnReadComplete(int request_id, const std::string& data);
100 virtual void OnResponseEnd(int request_id,
101 const net::URLRequestStatus& status);
102 virtual void OnCookiesRetrieved(bool success, const GURL& url,
103 const std::string& cookie_string,
104 int cookie_id);
106 // This method is passed as a callback to UrlmonUrlRequest::TerminateBind.
107 // We simply forward moniker and bind_ctx to host ActiveX/ActiveDocument,
108 // so it may start NavigateWithBindContext.
109 void BindTerminated(IMoniker* moniker, IBindCtx* bind_ctx,
110 IStream* post_data, const char* request_headers);
112 // Map for (request_id <-> UrlmonUrlRequest)
113 typedef std::map<int, scoped_refptr<UrlmonUrlRequest> > RequestMap;
114 RequestMap request_map_;
115 scoped_refptr<UrlmonUrlRequest> LookupRequest(int request_id);
116 scoped_refptr<UrlmonUrlRequest> pending_request_;
118 bool stopping_;
119 int calling_delegate_; // re-entrancy protection (debug only check)
121 PrivacyInfo privacy_info_;
122 // The window to be used to fire notifications on.
123 HWND notification_window_;
124 // Set to true if the ChromeFrame instance is running in privileged mode.
125 bool privileged_mode_;
126 // A pointer to the containing object. We maintain a weak reference to avoid
127 // lifetime issues.
128 IUnknown* container_;
131 #endif // CHROME_FRAME_URLMON_URL_REQUEST_H_