blob: 7c0e4210546ff50af08d1f5b07907ca516a4b882 [file] [log] [blame]
[email protected]8ee65ba2011-04-12 20:53:231// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]70277f62010-04-15 01:39:262// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]965722ff2010-10-20 15:50:305#ifndef CHROME_FRAME_BIND_CONTEXT_INFO_H_
6#define CHROME_FRAME_BIND_CONTEXT_INFO_H_
[email protected]70277f62010-04-15 01:39:267
8#include <atlbase.h>
9#include <atlcom.h>
10
[email protected]965722ff2010-10-20 15:50:3011#include "base/win/scoped_comptr.h"
[email protected]ce2b9f92010-06-09 16:54:1212#include "chrome_frame/protocol_sink_wrap.h"
[email protected]70277f62010-04-15 01:39:2613
[email protected]25299f22010-05-13 17:46:4314class __declspec(uuid("71CC3EC7-7E8A-457f-93BC-1090CF31CC18"))
15IBindContextInfoInternal : public IUnknown {
16 public:
17 STDMETHOD(GetCppObject)(void** me) = 0;
18};
19
[email protected]70277f62010-04-15 01:39:2620// This class maintains contextual information used by ChromeFrame.
21// This information is maintained in the bind context.
[email protected]77d7aee2010-05-14 20:31:5522// Association with GUID_NULL is for convenience.
23class __declspec(uuid("00000000-0000-0000-0000-000000000000")) BindContextInfo
24 : public CComObjectRootEx<CComMultiThreadModel>,
25 public IBindContextInfoInternal {
[email protected]70277f62010-04-15 01:39:2626 public:
27 BindContextInfo();
[email protected]25299f22010-05-13 17:46:4328 ~BindContextInfo();
[email protected]70277f62010-04-15 01:39:2629
30 BEGIN_COM_MAP(BindContextInfo)
[email protected]25299f22010-05-13 17:46:4331 COM_INTERFACE_ENTRY(IBindContextInfoInternal)
32 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, ftm_)
[email protected]70277f62010-04-15 01:39:2633 END_COM_MAP()
34
35 // Returns the BindContextInfo instance associated with the bind
36 // context. Creates it if needed.
[email protected]77d7aee2010-05-14 20:31:5537 // The returned info object will be AddRef-ed on return, so use
[email protected]8ee65ba2011-04-12 20:53:2338 // base::win::ScopedComPtr<>::Receive() to receive this pointer.
[email protected]77d7aee2010-05-14 20:31:5539 static HRESULT FromBindContext(IBindCtx* bind_context,
40 BindContextInfo** info);
[email protected]70277f62010-04-15 01:39:2641
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]ce2b9f92010-06-09 16:54:1268 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]5aef0fa2010-08-02 17:10:5776 bool has_prot_data() const {
77 return prot_data_.get() != NULL;
78 }
79
[email protected]98c26e132010-10-25 20:04:2780 void set_protocol(IInternetProtocol* protocol) {
81 protocol_ = protocol;
82 }
83
84 IInternetProtocol* protocol() {
85 return protocol_.get();
86 }
87
[email protected]4f45d4582011-02-22 23:27:2788 // 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]25299f22010-05-13 17:46:4392 protected:
93 STDMETHOD(GetCppObject)(void** me) {
94 DCHECK(me);
[email protected]77d7aee2010-05-14 20:31:5595 AddRef();
[email protected]25299f22010-05-13 17:46:4396 *me = static_cast<BindContextInfo*>(this);
97 return S_OK;
98 }
99
100 HRESULT Initialize(IBindCtx* bind_ctx);
101
[email protected]70277f62010-04-15 01:39:26102 private:
[email protected]965722ff2010-10-20 15:50:30103 base::win::ScopedComPtr<IStream> cache_;
[email protected]70277f62010-04-15 01:39:26104 bool no_cache_;
105 bool chrome_request_;
106 bool is_switching_;
[email protected]965722ff2010-10-20 15:50:30107 base::win::ScopedComPtr<IUnknown> ftm_;
[email protected]ce2b9f92010-06-09 16:54:12108 scoped_refptr<ProtData> prot_data_;
[email protected]8ee65ba2011-04-12 20:53:23109 base::win::ScopedComPtr<IInternetProtocol> protocol_;
[email protected]70277f62010-04-15 01:39:26110
111 DISALLOW_COPY_AND_ASSIGN(BindContextInfo);
112};
113
[email protected]965722ff2010-10-20 15:50:30114#endif // CHROME_FRAME_BIND_CONTEXT_INFO_H_