OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_FRAME_HTTP_NEGOTIATE_H_ | 5 #ifndef CHROME_FRAME_HTTP_NEGOTIATE_H_ |
6 #define CHROME_FRAME_HTTP_NEGOTIATE_H_ | 6 #define CHROME_FRAME_HTTP_NEGOTIATE_H_ |
7 | 7 |
8 #include <shdeprecated.h> | 8 #include <shdeprecated.h> |
| 9 #include <string> |
9 #include <urlmon.h> | 10 #include <urlmon.h> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/scoped_comptr_win.h" |
12 | 14 |
13 // Typedefs for IHttpNegotiate methods. | 15 // Typedefs for IHttpNegotiate methods. |
14 typedef HRESULT (STDMETHODCALLTYPE* IHttpNegotiate_BeginningTransaction_Fn)( | 16 typedef HRESULT (STDMETHODCALLTYPE* IHttpNegotiate_BeginningTransaction_Fn)( |
15 IHttpNegotiate* me, LPCWSTR url, LPCWSTR headers, DWORD reserved, | 17 IHttpNegotiate* me, LPCWSTR url, LPCWSTR headers, DWORD reserved, |
16 LPWSTR* additional_headers); | 18 LPWSTR* additional_headers); |
17 typedef HRESULT (STDMETHODCALLTYPE* IHttpNegotiate_OnResponse_Fn)( | 19 typedef HRESULT (STDMETHODCALLTYPE* IHttpNegotiate_OnResponse_Fn)( |
18 IHttpNegotiate* me, DWORD response_code, LPCWSTR response_header, | 20 IHttpNegotiate* me, DWORD response_code, LPCWSTR response_header, |
19 LPCWSTR request_header, LPWSTR* additional_request_headers); | 21 LPCWSTR request_header, LPWSTR* additional_request_headers); |
20 | 22 |
21 // Typedefs for IBindStatusCallback methods. | 23 // Typedefs for IBindStatusCallback methods. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Attempts to get to the associated browser service for an active request. | 71 // Attempts to get to the associated browser service for an active request. |
70 HRESULT GetBrowserServiceFromProtocolSink(IInternetProtocolSink* sink, | 72 HRESULT GetBrowserServiceFromProtocolSink(IInternetProtocolSink* sink, |
71 IBrowserService** browser_service); | 73 IBrowserService** browser_service); |
72 | 74 |
73 // From the latest urlmon.h. Symbol name prepended with LOCAL_ to | 75 // From the latest urlmon.h. Symbol name prepended with LOCAL_ to |
74 // avoid conflict (and therefore build errors) for those building with | 76 // avoid conflict (and therefore build errors) for those building with |
75 // a newer Windows SDK. | 77 // a newer Windows SDK. |
76 // TODO(robertshield): Remove this once we update our SDK version. | 78 // TODO(robertshield): Remove this once we update our SDK version. |
77 extern const int LOCAL_BINDSTATUS_SERVER_MIMETYPEAVAILABLE; | 79 extern const int LOCAL_BINDSTATUS_SERVER_MIMETYPEAVAILABLE; |
78 | 80 |
| 81 // Scans |additional_headers| and |headers| for User-Agent header or grabs |
| 82 // the default User-Agent if none is found. Append "chromeframe" at the end |
| 83 // of the string. Returns the original content of |additional_headers| but |
| 84 // with the new User-Agent header. Somewhat unusual interface is dictated |
| 85 // because we use it in IHttpNegotiate::BeginningTransaction. |
| 86 // The function is a public since we want to use it from |
| 87 // UrlmonUrlRequest::BeginningTransaction for the unusual but yet possible case |
| 88 // when |headers| contains an User-Agent string. |
| 89 // TODO(stoyan): Add unit test. |
| 90 std::string AppendCFUserAgentString(LPCWSTR headers, |
| 91 LPCWSTR additional_headers); |
| 92 // Simple class that wraps IHttpNegotiate interface and adds "chromeframe" |
| 93 // to User-agent Http header. |
| 94 class UserAgentAddOn : public IHttpNegotiate { |
| 95 public: |
| 96 UserAgentAddOn() {} |
| 97 ~UserAgentAddOn() {} |
| 98 void set_delegate(IHttpNegotiate* delegate) { |
| 99 delegate_ = delegate; |
| 100 } |
| 101 |
| 102 bool has_delegate() const { |
| 103 return delegate_ != NULL; |
| 104 } |
| 105 |
| 106 protected: |
| 107 // IHttpNegotiate |
| 108 STDMETHOD(BeginningTransaction)(LPCWSTR url, LPCWSTR headers, DWORD reserved, |
| 109 LPWSTR* additional_headers); |
| 110 STDMETHOD(OnResponse)(DWORD response_code, LPCWSTR response_headers, |
| 111 LPCWSTR request_headers, LPWSTR* additional_headers); |
| 112 ScopedComPtr<IHttpNegotiate> delegate_; |
| 113 }; |
| 114 |
79 #endif // CHROME_FRAME_HTTP_NEGOTIATE_H_ | 115 #endif // CHROME_FRAME_HTTP_NEGOTIATE_H_ |
OLD | NEW |