blob: 3eb2554495ceddc56fa724cb9e9396b3c7699cc4 [file] [log] [blame]
[email protected]70277f62010-04-15 01:39:261// Copyright (c) 2010 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.
4
5#include "chrome_frame/bind_context_info.h"
6#include "chrome_frame/utils.h"
7
8// This is non const due to API expectations
9static wchar_t* kBindContextInfo = L"_CHROMEFRAME_BIND_CONTEXT_INFO_";
10
11// BindContextInfo member definitions.
12BindContextInfo::BindContextInfo()
13 : no_cache_(false),
14 chrome_request_(false),
15 is_switching_(false) {
16}
17
18BindContextInfo* BindContextInfo::FromBindContext(IBindCtx* bind_context) {
19 if (!bind_context) {
20 NOTREACHED();
21 return NULL;
22 }
23
24 ScopedComPtr<IUnknown> context;
25 bind_context->GetObjectParam(kBindContextInfo, context.Receive());
26 if (context) {
27 return static_cast<BindContextInfo*>(context.get());
28 }
29
30 CComObject<BindContextInfo>* bind_context_info = NULL;
31 CComObject<BindContextInfo>::CreateInstance(&bind_context_info);
32 DCHECK(bind_context_info != NULL);
33
34 bind_context->RegisterObjectParam(kBindContextInfo, bind_context_info);
35 return bind_context_info;
36}
37
38void BindContextInfo::SetToSwitch(IStream* cache) {
39 is_switching_ = true;
40 if (!no_cache_) {
41 cache_ = cache;
42 RewindStream(cache_);
43 }
44}
45