[email protected] | 70277f6 | 2010-04-15 01:39:26 | [diff] [blame^] | 1 | // 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 |
| 9 | static wchar_t* kBindContextInfo = L"_CHROMEFRAME_BIND_CONTEXT_INFO_"; |
| 10 | |
| 11 | // BindContextInfo member definitions. |
| 12 | BindContextInfo::BindContextInfo() |
| 13 | : no_cache_(false), |
| 14 | chrome_request_(false), |
| 15 | is_switching_(false) { |
| 16 | } |
| 17 | |
| 18 | BindContextInfo* 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 | |
| 38 | void BindContextInfo::SetToSwitch(IStream* cache) { |
| 39 | is_switching_ = true; |
| 40 | if (!no_cache_) { |
| 41 | cache_ = cache; |
| 42 | RewindStream(cache_); |
| 43 | } |
| 44 | } |
| 45 | |