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) {
34 LogWarning("The object will not be loaded to iframes");
37 m_iframesObjects.push_back(declaration);
40 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)
49 LogDebug("LoadedIframes size: " << m_loadedIframes.size() );
51 auto it_loaded = std::find_if(m_loadedIframes.begin(),
52 m_loadedIframes.end(),
53 std::bind2nd(EqualToJSObjectPtr(), iframe));
54 //object not found, so thats the new iframe
55 if (it_loaded == m_loadedIframes.end()) {
56 LogDebug("Nothing to unregister");
60 m_loadedIframes.erase(it_loaded);
63 bool IframesSupport::hasIframes() const
65 return !m_loadedIframes.empty();
68 IframesSupport::DeclarationsList IframesSupport::getIframeObjects() const
70 return m_iframesObjects;
73 void IframesSupport::clean()
75 m_iframesObjects.clear();
76 m_loadedIframes.clear();