2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file plugin_iframe_support.cpp
22 #include "plugin_iframe_support.h"
25 #include <dpl/foreach.h>
27 void IframesSupport::registerDeclaration(
28 const JSObjectDeclarationPtr& declaration)
30 LogDebug("Registration iframes-supported plugins " <<
31 declaration->getName());
33 if(declaration->getParentName().find('.') != std::string::npos)
35 LogWarning("The object will not be loaded to iframes");
38 m_iframesObjects.push_back(declaration);
41 void IframesSupport::registerIframe(const JSObjectPtr& iframe){
42 LogDebug("LoadedIframes size: " << m_loadedIframes.size() );
44 m_loadedIframes.insert(iframe);
47 void IframesSupport::unregisterIframe(const JSObjectPtr& iframe){
48 LogDebug("LoadedIframes size: " << m_loadedIframes.size() );
50 auto it_loaded = std::find_if(m_loadedIframes.begin(),
51 m_loadedIframes.end(),
52 std::bind2nd(EqualToJSObjectPtr(), iframe));
53 //object not found, so thats the new iframe
54 if(it_loaded == m_loadedIframes.end()){
55 LogDebug("Nothing to unregister");
59 m_loadedIframes.erase(it_loaded);
62 bool IframesSupport::hasIframes() const
64 return !m_loadedIframes.empty();
67 IframesSupport::DeclarationsList IframesSupport::getIframeObjects() const
69 return m_iframesObjects;
72 void IframesSupport::clean()
74 m_iframesObjects.clear();
75 m_loadedIframes.clear();