[email protected] | 8ee65ba | 2011-04-12 20:53:23 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 965722ff | 2010-10-20 15:50:30 | [diff] [blame] | 5 | #ifndef CHROME_FRAME_BIND_CONTEXT_INFO_H_ |
6 | #define CHROME_FRAME_BIND_CONTEXT_INFO_H_ | ||||
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 7 | |
8 | #include <atlbase.h> | ||||
9 | #include <atlcom.h> | ||||
10 | |||||
[email protected] | 965722ff | 2010-10-20 15:50:30 | [diff] [blame] | 11 | #include "base/win/scoped_comptr.h" |
[email protected] | ce2b9f9 | 2010-06-09 16:54:12 | [diff] [blame] | 12 | #include "chrome_frame/protocol_sink_wrap.h" |
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 13 | |
[email protected] | 25299f2 | 2010-05-13 17:46:43 | [diff] [blame] | 14 | class __declspec(uuid("71CC3EC7-7E8A-457f-93BC-1090CF31CC18")) |
15 | IBindContextInfoInternal : public IUnknown { | ||||
16 | public: | ||||
17 | STDMETHOD(GetCppObject)(void** me) = 0; | ||||
18 | }; | ||||
19 | |||||
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 20 | // This class maintains contextual information used by ChromeFrame. |
21 | // This information is maintained in the bind context. | ||||
[email protected] | 77d7aee | 2010-05-14 20:31:55 | [diff] [blame] | 22 | // Association with GUID_NULL is for convenience. |
23 | class __declspec(uuid("00000000-0000-0000-0000-000000000000")) BindContextInfo | ||||
24 | : public CComObjectRootEx<CComMultiThreadModel>, | ||||
25 | public IBindContextInfoInternal { | ||||
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 26 | public: |
27 | BindContextInfo(); | ||||
[email protected] | 25299f2 | 2010-05-13 17:46:43 | [diff] [blame] | 28 | ~BindContextInfo(); |
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 29 | |
30 | BEGIN_COM_MAP(BindContextInfo) | ||||
[email protected] | 25299f2 | 2010-05-13 17:46:43 | [diff] [blame] | 31 | COM_INTERFACE_ENTRY(IBindContextInfoInternal) |
32 | COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, ftm_) | ||||
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 33 | END_COM_MAP() |
34 | |||||
35 | // Returns the BindContextInfo instance associated with the bind | ||||
36 | // context. Creates it if needed. | ||||
[email protected] | 77d7aee | 2010-05-14 20:31:55 | [diff] [blame] | 37 | // The returned info object will be AddRef-ed on return, so use |
[email protected] | 8ee65ba | 2011-04-12 20:53:23 | [diff] [blame] | 38 | // base::win::ScopedComPtr<>::Receive() to receive this pointer. |
[email protected] | 77d7aee | 2010-05-14 20:31:55 | [diff] [blame] | 39 | static HRESULT FromBindContext(IBindCtx* bind_context, |
40 | BindContextInfo** info); | ||||
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 41 | |
42 | void set_chrome_request(bool chrome_request) { | ||||
43 | chrome_request_ = chrome_request; | ||||
44 | } | ||||
45 | |||||
46 | bool chrome_request() const { | ||||
47 | return chrome_request_; | ||||
48 | } | ||||
49 | |||||
50 | void set_no_cache(bool no_cache) { | ||||
51 | no_cache_ = no_cache; | ||||
52 | } | ||||
53 | |||||
54 | bool no_cache() const { | ||||
55 | return no_cache_; | ||||
56 | } | ||||
57 | |||||
58 | bool is_switching() const { | ||||
59 | return is_switching_; | ||||
60 | } | ||||
61 | |||||
62 | void SetToSwitch(IStream* cache); | ||||
63 | |||||
64 | IStream* cache() { | ||||
65 | return cache_; | ||||
66 | } | ||||
67 | |||||
[email protected] | ce2b9f9 | 2010-06-09 16:54:12 | [diff] [blame] | 68 | void set_prot_data(ProtData* data) { |
69 | prot_data_ = data; | ||||
70 | } | ||||
71 | |||||
72 | scoped_refptr<ProtData> get_prot_data() { | ||||
73 | return prot_data_; | ||||
74 | } | ||||
75 | |||||
[email protected] | 5aef0fa | 2010-08-02 17:10:57 | [diff] [blame] | 76 | bool has_prot_data() const { |
77 | return prot_data_.get() != NULL; | ||||
78 | } | ||||
79 | |||||
[email protected] | 98c26e13 | 2010-10-25 20:04:27 | [diff] [blame] | 80 | void set_protocol(IInternetProtocol* protocol) { |
81 | protocol_ = protocol; | ||||
82 | } | ||||
83 | |||||
84 | IInternetProtocol* protocol() { | ||||
85 | return protocol_.get(); | ||||
86 | } | ||||
87 | |||||
[email protected] | 4f45d458 | 2011-02-22 23:27:27 | [diff] [blame] | 88 | // Returns the url being navigated to. We retrieve the url from the ProtData |
89 | // instance which wraps the underlying protocol sink. | ||||
90 | std::wstring GetUrl(); | ||||
91 | |||||
[email protected] | 25299f2 | 2010-05-13 17:46:43 | [diff] [blame] | 92 | protected: |
93 | STDMETHOD(GetCppObject)(void** me) { | ||||
94 | DCHECK(me); | ||||
[email protected] | 77d7aee | 2010-05-14 20:31:55 | [diff] [blame] | 95 | AddRef(); |
[email protected] | 25299f2 | 2010-05-13 17:46:43 | [diff] [blame] | 96 | *me = static_cast<BindContextInfo*>(this); |
97 | return S_OK; | ||||
98 | } | ||||
99 | |||||
100 | HRESULT Initialize(IBindCtx* bind_ctx); | ||||
101 | |||||
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 102 | private: |
[email protected] | 965722ff | 2010-10-20 15:50:30 | [diff] [blame] | 103 | base::win::ScopedComPtr<IStream> cache_; |
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 104 | bool no_cache_; |
105 | bool chrome_request_; | ||||
106 | bool is_switching_; | ||||
[email protected] | 965722ff | 2010-10-20 15:50:30 | [diff] [blame] | 107 | base::win::ScopedComPtr<IUnknown> ftm_; |
[email protected] | ce2b9f9 | 2010-06-09 16:54:12 | [diff] [blame] | 108 | scoped_refptr<ProtData> prot_data_; |
[email protected] | 8ee65ba | 2011-04-12 20:53:23 | [diff] [blame] | 109 | base::win::ScopedComPtr<IInternetProtocol> protocol_; |
[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame] | 110 | |
111 | DISALLOW_COPY_AND_ASSIGN(BindContextInfo); | ||||
112 | }; | ||||
113 | |||||
[email protected] | 965722ff | 2010-10-20 15:50:30 | [diff] [blame] | 114 | #endif // CHROME_FRAME_BIND_CONTEXT_INFO_H_ |