+ if (__pWebViewer && __pWebViewer->CanGoBack())
+ {
+ __pWebViewer->GoBack();
+ }
+ else if(__pWindowInfo->isJavascriptInitiated == false)
+ {
+ UiApp* pApp = null;
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ RemoveOrientationEventListener(*this);
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetAddressbarEventListener(null);
+ }
+
+ if(__pWebViewer)
+ {
+ __pWebViewer->RemoveTouchEventListener(*this);
+ __pWebViewer->SetWebUiEventListenerF(null);
+ __pWebViewer->SetWebKeypadEventListener(null);
+ __pWebViewer->SetTextSearchListener(null);
+ __pWebViewer->SetLoadingListener(null);
+ }
+ r = pApp->Terminate();
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ UiApp* pApp = null;
+ WindowInfo* pWindowInfo = null;
+ int totalCount = 0;
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ if (pSceneManager == null)
+ {
+ return;
+ }
+ ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
+ if (pAllWindowList == NULL)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ RemoveOrientationEventListener(*this);
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetAddressbarEventListener(null);
+ }
+
+ if(__pWebViewer)
+ {
+ __pWebViewer->RemoveTouchEventListener(*this);
+ __pWebViewer->SetWebUiEventListenerF(null);
+ __pWebViewer->SetWebKeypadEventListener(null);
+ __pWebViewer->SetTextSearchListener(null);
+ __pWebViewer->SetLoadingListener(null);
+ }
+ r = pApp->Terminate();
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ if (pAllWindowList != null)
+ {
+ totalCount = pAllWindowList->GetCount();
+ }
+ for (int count = 0; count < totalCount; count++)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ RemoveOrientationEventListener(*this);
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetAddressbarEventListener(null);
+ }
+
+ if(__pWebViewer)
+ {
+ __pWebViewer->RemoveTouchEventListener(*this);
+ __pWebViewer->SetWebUiEventListenerF(null);
+ __pWebViewer->SetWebKeypadEventListener(null);
+ __pWebViewer->SetTextSearchListener(null);
+ __pWebViewer->SetLoadingListener(null);
+ }
+ r = pApp->Terminate();
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ }
+ else
+ {
+ if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
+ {
+ r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ r = pAllWindowList->RemoveAt(count, true);
+ __pWindowInfo = null;
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ if(count > 0)
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
+ }
+ else
+ {
+ pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
+ }
+ if (pWindowInfo == null)
+ {
+ pApp = UiApp::GetInstance();
+ if (pApp != null)
+ {
+ RemoveOrientationEventListener(*this);
+
+ if(__pAddressbar)
+ {
+ __pAddressbar->SetAddressbarEventListener(null);
+ }
+
+ if(__pWebViewer)
+ {
+ __pWebViewer->RemoveTouchEventListener(*this);
+ __pWebViewer->SetWebUiEventListenerF(null);
+ __pWebViewer->SetWebKeypadEventListener(null);
+ __pWebViewer->SetTextSearchListener(null);
+ __pWebViewer->SetLoadingListener(null);
+ }
+ r = pApp->Terminate();
+ return;
+ }
+ }
+ else
+ {
+ r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
+ if (IsFailed(r))
+ {
+ AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
+ return;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+void
+MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
+ const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
+{
+
+ AppLog("MainForm::OnSceneActivatedN called");