Revert "Disable cached_window_->Initialize()"
[platform/framework/web/crosswalk-tizen.git] / runtime / browser / preload_manager.cc
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "runtime/browser/preload_manager.h"
18
19 #include <Elementary.h>
20 #include <EWebKit.h>
21 #include <EWebKit_internal.h>
22 #include <stdio.h>
23
24 #include "common/platform_info.h"
25 #include "common/logger.h"
26 #include "runtime/browser/native_app_window.h"
27 #include "extensions/common/xwalk_extension_server.h"
28
29 #ifndef INJECTED_BUNDLE_PATH
30 #error INJECTED_BUNDLE_PATH is not set.
31 #endif
32
33 namespace runtime {
34
35 PreloadManager* PreloadManager::GetInstance() {
36   static PreloadManager instance;
37   return &instance;
38 }
39
40 PreloadManager::PreloadManager() {
41 }
42
43 void PreloadManager::CreateCacheComponet() {
44   // Load extensions in the preload step
45   auto extension_server = extensions::XWalkExtensionServer::GetInstance();
46   extension_server->Preload();
47
48   // It was not used. just to fork zygote process
49   auto context =
50       ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH);
51   context = context;  // To prevent build warning
52   cached_window_.reset(new NativeAppWindow());
53   if (!TIZEN_FEATURE_display_resize_support)
54     cached_window_->Initialize();
55 }
56
57 NativeWindow* PreloadManager::GetCachedNativeWindow() {
58   return cached_window_ ? cached_window_.release() : nullptr;
59 }
60
61 void PreloadManager::ReleaseCachedNativeWindow() {
62   cached_window_.reset(nullptr);
63 }
64
65 }  //  namespace runtime