roll skia to 4057
[chromium-blink-merge.git] / chrome_frame / bind_context_info.h
blob7c0e4210546ff50af08d1f5b07907ca516a4b882
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_BIND_CONTEXT_INFO_H_
6 #define CHROME_FRAME_BIND_CONTEXT_INFO_H_
8 #include <atlbase.h>
9 #include <atlcom.h>
11 #include "base/win/scoped_comptr.h"
12 #include "chrome_frame/protocol_sink_wrap.h"
14 class __declspec(uuid("71CC3EC7-7E8A-457f-93BC-1090CF31CC18"))
15 IBindContextInfoInternal : public IUnknown {
16 public:
17 STDMETHOD(GetCppObject)(void** me) = 0;
20 // This class maintains contextual information used by ChromeFrame.
21 // This information is maintained in the bind context.
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 {
26 public:
27 BindContextInfo();
28 ~BindContextInfo();
30 BEGIN_COM_MAP(BindContextInfo)
31 COM_INTERFACE_ENTRY(IBindContextInfoInternal)
32 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, ftm_)
33 END_COM_MAP()
35 // Returns the BindContextInfo instance associated with the bind
36 // context. Creates it if needed.
37 // The returned info object will be AddRef-ed on return, so use
38 // base::win::ScopedComPtr<>::Receive() to receive this pointer.
39 static HRESULT FromBindContext(IBindCtx* bind_context,
40 BindContextInfo** info);
42 void set_chrome_request(bool chrome_request) {
43 chrome_request_ = chrome_request;
46 bool chrome_request() const {
47 return chrome_request_;
50 void set_no_cache(bool no_cache) {
51 no_cache_ = no_cache;
54 bool no_cache() const {
55 return no_cache_;
58 bool is_switching() const {
59 return is_switching_;
62 void SetToSwitch(IStream* cache);
64 IStream* cache() {
65 return cache_;
68 void set_prot_data(ProtData* data) {
69 prot_data_ = data;
72 scoped_refptr<ProtData> get_prot_data() {
73 return prot_data_;
76 bool has_prot_data() const {
77 return prot_data_.get() != NULL;
80 void set_protocol(IInternetProtocol* protocol) {
81 protocol_ = protocol;
84 IInternetProtocol* protocol() {
85 return protocol_.get();
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();
92 protected:
93 STDMETHOD(GetCppObject)(void** me) {
94 DCHECK(me);
95 AddRef();
96 *me = static_cast<BindContextInfo*>(this);
97 return S_OK;
100 HRESULT Initialize(IBindCtx* bind_ctx);
102 private:
103 base::win::ScopedComPtr<IStream> cache_;
104 bool no_cache_;
105 bool chrome_request_;
106 bool is_switching_;
107 base::win::ScopedComPtr<IUnknown> ftm_;
108 scoped_refptr<ProtData> prot_data_;
109 base::win::ScopedComPtr<IInternetProtocol> protocol_;
111 DISALLOW_COPY_AND_ASSIGN(BindContextInfo);
114 #endif // CHROME_FRAME_BIND_CONTEXT_INFO_H_