Change the chromium header from ewk_chromium.h to EWebKit.h/Ewebkit_internal.h
[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/logger.h"
25 #include "runtime/browser/native_app_window.h"
26 #include "extensions/common/xwalk_extension_server.h"
27
28 #ifndef INJECTED_BUNDLE_PATH
29 #error INJECTED_BUNDLE_PATH is not set.
30 #endif
31
32 namespace runtime {
33
34 PreloadManager* PreloadManager::GetInstance() {
35   static PreloadManager instance;
36   return &instance;
37 }
38
39 PreloadManager::PreloadManager() {
40 }
41
42 void PreloadManager::CreateCacheComponet() {
43   // Load extensions in the preload step
44   auto extension_server = extensions::XWalkExtensionServer::GetInstance();
45   extension_server->Preload();
46
47   // It was not used. just to fork zygote process
48   auto context =
49       ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH);
50   context = context;  // To prevent build warning
51   cached_window_.reset(new NativeAppWindow());
52   cached_window_->Initialize();
53 }
54
55 NativeWindow* PreloadManager::GetCachedNativeWindow() {
56   return cached_window_ ? cached_window_.release() : nullptr;
57 }
58
59 void PreloadManager::ReleaseCachedNativeWindow() {
60   cached_window_.reset(nullptr);
61 }
62
63 }  //  namespace runtime