bool UiRuntime::OnCreate() {
LOG(INFO) << "OnCreate()";
- auto appdata = common::ApplicationDataManager::GetCurrentAppData();
- auto browser = atom::Browser::Get();
- browser->Initialize();
- if (appdata->splash_screen_info()) {
- browser->SetSplashScreen();
- }
-
+ atom::Browser::Get()->Initialize();
return true;
}
void UiRuntime::OnPause() {
LOG(INFO) << "OnPause()";
- atom::Browser::Get()->Hide();
+ atom::Browser::Get()->Suspend();
}
void UiRuntime::OnResume() {
LOG(INFO) << "OnResume()";
- atom::Browser::Get()->Show();
+ atom::Browser::Get()->Resume();
}
void UiRuntime::OnAppControl(app_control_h app_control) {
bool WatchRuntime::OnCreate() {
LOG(INFO) << "OnCreate()";
- auto appdata = common::ApplicationDataManager::GetCurrentAppData();
- auto browser = atom::Browser::Get();
- if (appdata->splash_screen_info()) {
- browser->SetSplashScreen();
- }
+ atom::Browser::Get()->Initialize();
return true;
}
void WatchRuntime::OnPause() {
LOG(INFO) << "OnPause()";
- atom::Browser::Get()->Hide();
+ atom::Browser::Get()->Suspend();
}
void WatchRuntime::OnResume() {
LOG(INFO) << "OnResume()";
- atom::Browser::Get()->Show();
+ atom::Browser::Get()->Resume();
}
void WatchRuntime::OnAppControl(app_control_h app_control) {
#endif
#if defined(OS_TIZEN)
- void OnSuspend();
- void OnResume();
+ void OnSuspend() override;
+ void OnResume() override;
void OnAppControl();
#endif
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/run_loop.h"
-#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/brightray_paths.h"
-#include "content/public/browser/render_frame_host.h"
-#include "content/public/browser/render_view_host.h"
#if defined(OS_TIZEN)
-#include "tizen/common/application_data.h"
-#include "tizen/src/browser/native_web_runtime.h"
#include <Elementary.h>
-#include "wgt_manifest_handlers/launch_screen_handler.h"
#endif // defined(OS_TIZEN)
#include "tizen/common/env_variables.h"
Browser::Browser()
: is_quiting_(false),
-#if defined(OS_TIZEN)
- launched_(false),
-#endif
is_exiting_(false),
is_ready_(false),
is_shutdown_(false) {
WindowList::RemoveObserver(this);
}
-#if defined(OS_TIZEN)
-const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main";
-const char* kAppControlEventScript =
- "(function(){"
- "var __event = document.createEvent(\"CustomEvent\");\n"
- "__event.initCustomEvent(\"appcontrol\", true, true, null);\n"
- "document.dispatchEvent(__event);\n"
- "\n"
- "for(var i=0; i < window.frames.length; i++)\n"
- "{ window.frames[i].document.dispatchEvent(__event); }"
- "})()";
-const char* kDefaultCSPRule =
- "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
-#endif
-
// static
Browser* Browser::Get() {
if (AtomBrowserMainParts::Get())
#endif
}
-#if defined(OS_TIZEN)
-// Function is same as suspend. This will be called from app lifecycle suspend
-void Browser::Hide() {
- // If application is having background catagory enabled then do not suspend the app
- auto appdata = common::ApplicationDataManager::GetCurrentAppData();
- if (appdata->setting_info() != NULL && appdata->setting_info()->background_support_enabled()) {
- return;
- }
-
- NativeWindow *last_window = WindowList::GetLastWindow();
- if (!last_window)
- return;
-
- last_window->NotifySuspend();
- auto rvh = last_window->web_contents()->GetRenderViewHost();
- atom::Browser::Get()->Suspend(rvh);
-}
-
-// Function is same as resume. This will be called from app lifecycle resume
-void Browser::Show() {
- // If application is having background catagory enabled then do not resume the app
- // as its has not suspend
- auto appdata = common::ApplicationDataManager::GetCurrentAppData();
- if (appdata->setting_info() != NULL && appdata->setting_info()->background_support_enabled()) {
- return;
- }
- NativeWindow *last_window = WindowList::GetLastWindow();
- if (!last_window)
- return;
-
- last_window->NotifyResume();
- auto rvh = last_window->web_contents()->GetRenderViewHost();
- atom::Browser::Get()->Resume(rvh);
-}
-
-void Browser::AppControl(std::unique_ptr<common::AppControl> appcontrol) {
- std::unique_ptr<common::ResourceManager::Resource> res =
- resource_manager_->GetStartResource(appcontrol.get());
- bool do_reset = res->should_reset();
- NativeWindow *last_window = WindowList::GetLastWindow();
- std::string localized_page = res->uri();
- if (!do_reset) {
- std::string current_page = last_window->web_contents()->GetURL().spec();
- if (current_page != localized_page)
- do_reset = true;
- else
- SendAppControlEvent();
- }
- if (do_reset && (appcontrol->operation() == kAppControlMain)) {
- do_reset = false;
- SendAppControlEvent();
- }
- if (do_reset) {
- //To do :Implementation of ClearViewStack(), SetupWebWindow(),SetupWebWindowCompatibilitySettings() function
- }
-}
-
-void Browser::SendAppControlEvent() {
- NativeWindow *last_window = WindowList::GetLastWindow();
-
- if (last_window != NULL) {
- content::RenderFrameHost* rfh = last_window->web_contents()->GetMainFrame();
- if (rfh) {
- rfh->ExecuteJavaScriptWithUserGestureForTests(
- base::UTF8ToUTF16(kAppControlEventScript));
- }
- }
-}
-
-void Browser::Launch(std::unique_ptr<common::AppControl> appcontrol) {
- launched_ = true;
-//To do:Implementation of relaunching of app
- std::unique_ptr<common::ResourceManager::Resource> res =
- resource_manager_->GetStartResource(appcontrol.get());
- if (res)
- start_url_ = res->uri();
-
- tizen::NativeWebRuntime::GetInstance().StartApplication();
-}
-
-void Browser::SetSplashScreen() {
- auto appdata = common::ApplicationDataManager::GetCurrentAppData();
- Evas_Object* window_ = elm_win_util_standard_add("", "");
-
- splash_screen_.reset(
- new SplashScreen(
- window_, appdata->splash_screen_info(), appdata->application_path()));
-}
-
-void Browser::HideSplashScreen(int reason) {
- auto appdata = common::ApplicationDataManager::GetCurrentAppData();
- if (!appdata->splash_screen_info()) {
- return;
- }
-
- splash_screen_->HideSplashScreen(reason);
-}
-#endif // defined(OS_TIZEN)
-
} // namespace atom
#include "base/values.h"
#include "native_mate/arguments.h"
#if defined(OS_TIZEN)
-#include "atom/browser/splash_screen.h"
#include "tizen/browser/tizen_browser_parts.h"
-#include "tizen/common/app_control.h"
-#include "tizen/common/application_data.h"
-#include "tizen/common/resource_manager.h"
-#include "tizen/common/locale_manager.h"
#endif // defined(OS_TIZEN)
class LoginHandler;
// This class is used for control application-wide operations.
-class Browser : public WindowListObserver,
- public tizen::TizenBrowserParts {
+class Browser : public WindowListObserver
+#if defined(OS_TIZEN)
+ , public tizen::TizenBrowserParts
+#endif
+ {
public:
Browser();
~Browser();
void SetLoginItemSettings(LoginItemSettings settings);
LoginItemSettings GetLoginItemSettings(const LoginItemSettings& options);
-#if defined(OS_TIZEN)
- void Hide();
- void Show();
- void AppControl(std::unique_ptr<common::AppControl> appcontrol) override;
- void Launch(std::unique_ptr<common::AppControl> appcontrol) override;
- void SendAppControlEvent();
- void SetSplashScreen();
- void HideSplashScreen(int reason);
- bool launched() const { return launched_; }
- std::string StartURL() const { return start_url_;}
-#endif // defined(OS_TIZEN)
-
#if defined(OS_MACOSX)
// Hide the application.
void Hide();
// Observers of the browser.
base::ObserverList<BrowserObserver> observers_;
-#if defined(OS_TIZEN)
- std::unique_ptr<SplashScreen> splash_screen_;
- std::string start_url_;
- bool launched_;
-#endif
-
// Whether `app.exit()` has been called
bool is_exiting_;
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "atom/browser/splash_screen.h"
-
-#include <algorithm>
-#include <map>
-#include <string>
-
-#include <Evas_Legacy.h>
-
-#include "tizen/common/logger.h"
-
-//using ScreenOrientation = runtime::NativeWindow::ScreenOrientation;
-
-namespace {
-
-enum class BorderOption { REPEAT = 1, STRETCH, ROUND };
-
-// To do : The orientation will be implemented later.
-
-/*wgt::parse::ScreenOrientation ChooseOrientation(
- const std::map<wgt::parse::ScreenOrientation,
- wgt::parse::LaunchScreenData>& splash_map,
- ScreenOrientation screen_orientation) {
- auto orientation_pair = splash_map.end();
-
- if (screen_orientation ==
- runtime::NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY ||
- screen_orientation ==
- runtime::NativeWindow::ScreenOrientation::PORTRAIT_SECONDARY) {
- orientation_pair =
- splash_map.find(wgt::parse::ScreenOrientation::PORTRAIT);
- } else {
- orientation_pair =
- splash_map.find(wgt::parse::ScreenOrientation::LANDSCAPE);
- }
- if (orientation_pair == splash_map.end())
- orientation_pair = splash_map.find(wgt::parse::ScreenOrientation::AUTO);
-
- if (orientation_pair != splash_map.end()) return orientation_pair->first;
- return wgt::parse::ScreenOrientation::NONE;
-}*/
-
-bool ParseImageBorder(const std::vector<std::string>& borders,
- std::vector<int>* border_values,
- std::vector<BorderOption>* border_options) {
- std::map<std::string, BorderOption> scaling_string;
- scaling_string["repeat"] = BorderOption::REPEAT;
- scaling_string["stretch"] = BorderOption::STRETCH;
- scaling_string["round"] = BorderOption::ROUND;
-
- for (const auto& border : borders) {
- std::string::size_type px_index = border.find("px");
- if (px_index != std::string::npos) {
- std::string border_value(border.begin(), border.begin() + px_index);
- border_values->push_back(std::atoi(border_value.c_str()));
- }
- for (const auto& border_string_val : scaling_string) {
- std::string::size_type index = border.find(border_string_val.first);
- if (index != std::string::npos) {
- border_options->push_back(border_string_val.second);
- }
- }
- }
-
- LOGGER(DEBUG) << "Image border values:";
- for (const auto& border_value : *border_values) {
- LOGGER(DEBUG) << border_value;
- }
- LOGGER(DEBUG) << "Image border scaling values:";
- for (const auto& border_option : *border_options) {
- LOGGER(DEBUG) << static_cast<int>(border_option);
- }
-
- return !border_values->empty() && !border_options->empty();
-}
-
-} // namespace
-
-namespace atom {
-
-SplashScreen::SplashScreen(
- Evas_Object* window,
- //runtime::NativeWindow* window,
- std::shared_ptr<const wgt::parse::LaunchScreenInfo> ss_info,
- const std::string& app_path)
- : ss_info_(ss_info),
- window_(window),
- image_(nullptr),
- background_(nullptr),
- background_image_(nullptr),
- is_active_(false) {
- if (ss_info == nullptr) return;
-
- auto splash_map = ss_info->launch_screen_data();
- /*auto used_orientation =
- ChooseOrientation(splash_map, window->orientation());
- if (used_orientation == wgt::parse::ScreenOrientation::NONE) return; */
-
- auto dimensions = GetDimensions(window);
-
- // To do : The orientation will be implemented later.
- SetBackground(splash_map[wgt::parse::ScreenOrientation::AUTO], window,
- dimensions, app_path);
- SetImage(splash_map[wgt::parse::ScreenOrientation::AUTO], window,
- dimensions, app_path);
- is_active_ = true;
-}
-
-void SplashScreen::HideSplashScreen(int reason) {
-
- if (!is_active_) return;
- if (reason == HideReason::RENDERED &&
- ss_info_->ready_when() != wgt::parse::ReadyWhen::FIRSTPAINT) {
- return;
- }
- if (reason == HideReason::LOADFINISHED &&
- ss_info_->ready_when() != wgt::parse::ReadyWhen::COMPLETE) {
- return;
- }
- if (reason == HideReason::CUSTOM &&
- ss_info_->ready_when() != wgt::parse::ReadyWhen::CUSTOM) {
- return;
- }
-
- evas_object_hide(background_);
- evas_object_hide(image_);
- evas_object_hide(window_);
- evas_object_del(background_);
- evas_object_del(image_);
- evas_object_hide(window_);
- background_ = nullptr;
- image_ = nullptr;
- window_ = nullptr;
- is_active_ = false;
-}
-
-std::pair<int, int> SplashScreen::GetDimensions(Evas_Object* window) {
- int w, h;
- elm_win_screen_size_get(window, NULL, NULL, &w, &h);
- evas_object_resize(background_, w, h);
- return std::make_pair(w, h);
-}
-
-void SplashScreen::SetBackground(
- const wgt::parse::LaunchScreenData& splash_data, Evas_Object* parent,
- const SplashScreenBound& bound, const std::string& app_path) {
- background_ = elm_bg_add(parent);
- if (!background_) return;
- evas_object_resize(background_, bound.first, bound.second);
-
- if (splash_data.background_color != nullptr) {
- elm_bg_color_set(background_,
- splash_data.background_color->red,
- splash_data.background_color->green,
- splash_data.background_color->blue);
- }
-
- std::vector<int> border_values;
- std::vector<BorderOption> border_options;
-
- if (!splash_data.background_images.empty() &&
- ParseImageBorder(
- splash_data.image_border, &border_values, &border_options)) {
- const std::string& background_image_path =
- splash_data.background_images.front().first;
-
- background_image_ = elm_image_add(background_);
- evas_object_image_file_set(background_image_,
- (app_path + background_image_path).c_str(),
- NULL);
- elm_image_aspect_fixed_set(background_image_, 0);
- evas_object_image_border_center_fill_set(background_image_,
- EVAS_BORDER_FILL_DEFAULT);
-
- evas_object_resize(background_image_, bound.first, bound.second);
-
- int border_l, border_r, border_t, border_b;
- switch (border_values.size()) {
- case 1:
- border_l = border_r = border_t = border_b = -border_values[0];
- break;
- case 2:
- border_t = border_b = border_values[0];
- border_l = border_r = border_values[1];
- break;
- case 4:
- border_t = border_values[0];
- border_r = border_values[1];
- border_b = border_values[2];
- border_l = border_values[3];
- break;
- default:
- border_l = border_r = border_t = border_b = 0;
- }
- evas_object_image_border_set(background_image_,
- border_l,
- border_r,
- border_t,
- border_b);
- // TODO(a.szulakiewi): add scaling of horizontal and vertical borders
- }
-
- evas_object_show(background_);
- evas_object_show(background_image_);
- evas_object_show(parent);
-}
-
-void SplashScreen::SetImage(
- const wgt::parse::LaunchScreenData& splash_data, Evas_Object* parent,
- const SplashScreenBound& bound, const std::string& app_path) {
- if (!background_) return;
- image_ = elm_image_add(background_);
- if (!image_) return;
-
- if (splash_data.images.empty()) return;
-
- const std::string& image_path = splash_data.images.front().first;
- elm_image_file_set(image_, (app_path + image_path).c_str(), NULL);
- evas_object_resize(image_, bound.first, bound.second);
- evas_object_show(image_);
- evas_object_show(parent);
-}
-} // namespace atom
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef XWALK_RUNTIME_BROWSER_SPLASH_SCREEN_H_
-#define XWALK_RUNTIME_BROWSER_SPLASH_SCREEN_H_
-
-#include <map>
-#include <memory>
-#include <utility>
-#include <string>
-#include <vector>
-
-#include <Elementary.h>
-#include "wgt_manifest_handlers/launch_screen_handler.h"
-
-enum HideReason { RENDERED, LOADFINISHED, CUSTOM };
-
-namespace atom {
-
-enum class ScreenOrientation {
- PORTRAIT_PRIMARY = 0,
- PORTRAIT_SECONDARY = 1,
- LANDSCAPE_PRIMARY = 2,
- LANDSCAPE_SECONDARY = 3,
- NATURAL = 4,
- ANY = 5
-};
-
-class SplashScreen {
- public:
- typedef std::pair<int, int> SplashScreenBound;
-
- SplashScreen(Evas_Object* window,
- std::shared_ptr<const wgt::parse::LaunchScreenInfo> ss_info,
- const std::string& app_path);
- void HideSplashScreen(int reason);
-
- private:
- std::pair<int, int> GetDimensions(Evas_Object* window);
- void SetBackground(const wgt::parse::LaunchScreenData& splash_data,
- Evas_Object* parent, const SplashScreenBound& bound,
- const std::string& app_path);
-
- void SetImage(const wgt::parse::LaunchScreenData& splash_data,
- Evas_Object* parent, const SplashScreenBound& bound,
- const std::string& app_path);
-
- std::shared_ptr<const wgt::parse::LaunchScreenInfo> ss_info_;
- Evas_Object* window_;
- Evas_Object* image_;
- Evas_Object* background_;
- Evas_Object* background_image_;
- bool is_active_;
-};
-} // namespace atom
-#endif // XWALK_RUNTIME_BROWSER_SPLASH_SCREEN_H_
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <algorithm>
+#include <map>
+#include <string>
+
+// #include <Evas_Legacy.h> // TODO: Why was it added in the first place?
+
+#include "tizen/browser/splash_screen.h"
+#include "tizen/common/logger.h"
+
+//using ScreenOrientation = runtime::NativeWindow::ScreenOrientation;
+
+namespace {
+
+enum class BorderOption { REPEAT = 1, STRETCH, ROUND };
+
+// TODO: The orientation will be implemented later.
+
+/*wgt::parse::ScreenOrientation ChooseOrientation(
+ const std::map<wgt::parse::ScreenOrientation,
+ wgt::parse::LaunchScreenData>& splash_map,
+ ScreenOrientation screen_orientation) {
+ auto orientation_pair = splash_map.end();
+
+ if (screen_orientation ==
+ runtime::NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY ||
+ screen_orientation ==
+ runtime::NativeWindow::ScreenOrientation::PORTRAIT_SECONDARY) {
+ orientation_pair =
+ splash_map.find(wgt::parse::ScreenOrientation::PORTRAIT);
+ } else {
+ orientation_pair =
+ splash_map.find(wgt::parse::ScreenOrientation::LANDSCAPE);
+ }
+ if (orientation_pair == splash_map.end())
+ orientation_pair = splash_map.find(wgt::parse::ScreenOrientation::AUTO);
+
+ if (orientation_pair != splash_map.end()) return orientation_pair->first;
+ return wgt::parse::ScreenOrientation::NONE;
+}*/
+
+bool ParseImageBorder(const std::vector<std::string>& borders,
+ std::vector<int>* border_values,
+ std::vector<BorderOption>* border_options) {
+ std::map<std::string, BorderOption> scaling_string;
+ scaling_string["repeat"] = BorderOption::REPEAT;
+ scaling_string["stretch"] = BorderOption::STRETCH;
+ scaling_string["round"] = BorderOption::ROUND;
+
+ for (const auto& border : borders) {
+ std::string::size_type px_index = border.find("px");
+ if (px_index != std::string::npos) {
+ std::string border_value(border.begin(), border.begin() + px_index);
+ border_values->push_back(std::atoi(border_value.c_str()));
+ }
+ for (const auto& border_string_val : scaling_string) {
+ std::string::size_type index = border.find(border_string_val.first);
+ if (index != std::string::npos) {
+ border_options->push_back(border_string_val.second);
+ }
+ }
+ }
+
+ LOGGER(DEBUG) << "Image border values:";
+ for (const auto& border_value : *border_values) {
+ LOGGER(DEBUG) << border_value;
+ }
+ LOGGER(DEBUG) << "Image border scaling values:";
+ for (const auto& border_option : *border_options) {
+ LOGGER(DEBUG) << static_cast<int>(border_option);
+ }
+
+ return !border_values->empty() && !border_options->empty();
+}
+
+} // namespace
+
+namespace tizen {
+
+SplashScreen::SplashScreen(
+ Evas_Object* window,
+ //runtime::NativeWindow* window,
+ std::shared_ptr<const wgt::parse::LaunchScreenInfo> ss_info,
+ const std::string& app_path)
+ : ss_info_(ss_info),
+ window_(window),
+ image_(nullptr),
+ background_(nullptr),
+ background_image_(nullptr),
+ is_active_(false) {
+ if (ss_info == nullptr) return;
+
+ auto splash_map = ss_info->launch_screen_data();
+ /*auto used_orientation =
+ ChooseOrientation(splash_map, window->orientation());
+ if (used_orientation == wgt::parse::ScreenOrientation::NONE) return; */
+
+ auto dimensions = GetDimensions(window);
+
+ // TODO: The orientation will be implemented later.
+ SetBackground(splash_map[wgt::parse::ScreenOrientation::AUTO], window,
+ dimensions, app_path);
+ SetImage(splash_map[wgt::parse::ScreenOrientation::AUTO], window,
+ dimensions, app_path);
+ is_active_ = true;
+}
+
+void SplashScreen::HideSplashScreen(int reason) {
+
+ if (!is_active_) return;
+ if (reason == HideReason::RENDERED &&
+ ss_info_->ready_when() != wgt::parse::ReadyWhen::FIRSTPAINT) {
+ return;
+ }
+ if (reason == HideReason::LOADFINISHED &&
+ ss_info_->ready_when() != wgt::parse::ReadyWhen::COMPLETE) {
+ return;
+ }
+ if (reason == HideReason::CUSTOM &&
+ ss_info_->ready_when() != wgt::parse::ReadyWhen::CUSTOM) {
+ return;
+ }
+
+ evas_object_hide(background_);
+ evas_object_hide(image_);
+ evas_object_hide(window_);
+ evas_object_del(background_);
+ evas_object_del(image_);
+ evas_object_hide(window_);
+ background_ = nullptr;
+ image_ = nullptr;
+ window_ = nullptr;
+ is_active_ = false;
+}
+
+std::pair<int, int> SplashScreen::GetDimensions(Evas_Object* window) {
+ int w, h;
+ elm_win_screen_size_get(window, NULL, NULL, &w, &h);
+ evas_object_resize(background_, w, h);
+ return std::make_pair(w, h);
+}
+
+void SplashScreen::SetBackground(
+ const wgt::parse::LaunchScreenData& splash_data, Evas_Object* parent,
+ const SplashScreenBound& bound, const std::string& app_path) {
+ background_ = elm_bg_add(parent);
+ if (!background_) return;
+ evas_object_resize(background_, bound.first, bound.second);
+
+ if (splash_data.background_color != nullptr) {
+ elm_bg_color_set(background_,
+ splash_data.background_color->red,
+ splash_data.background_color->green,
+ splash_data.background_color->blue);
+ }
+
+ std::vector<int> border_values;
+ std::vector<BorderOption> border_options;
+
+ if (!splash_data.background_images.empty() &&
+ ParseImageBorder(
+ splash_data.image_border, &border_values, &border_options)) {
+ const std::string& background_image_path =
+ splash_data.background_images.front().first;
+
+ background_image_ = elm_image_add(background_);
+ evas_object_image_file_set(background_image_,
+ (app_path + background_image_path).c_str(),
+ NULL);
+ elm_image_aspect_fixed_set(background_image_, 0);
+ evas_object_image_border_center_fill_set(background_image_,
+ EVAS_BORDER_FILL_DEFAULT);
+
+ evas_object_resize(background_image_, bound.first, bound.second);
+
+ int border_l, border_r, border_t, border_b;
+ switch (border_values.size()) {
+ case 1:
+ border_l = border_r = border_t = border_b = -border_values[0];
+ break;
+ case 2:
+ border_t = border_b = border_values[0];
+ border_l = border_r = border_values[1];
+ break;
+ case 4:
+ border_t = border_values[0];
+ border_r = border_values[1];
+ border_b = border_values[2];
+ border_l = border_values[3];
+ break;
+ default:
+ border_l = border_r = border_t = border_b = 0;
+ }
+ evas_object_image_border_set(background_image_,
+ border_l,
+ border_r,
+ border_t,
+ border_b);
+ // TODO(a.szulakiewi): add scaling of horizontal and vertical borders
+ }
+
+ evas_object_show(background_);
+ evas_object_show(background_image_);
+ evas_object_show(parent);
+}
+
+void SplashScreen::SetImage(
+ const wgt::parse::LaunchScreenData& splash_data, Evas_Object* parent,
+ const SplashScreenBound& bound, const std::string& app_path) {
+ if (!background_) return;
+ image_ = elm_image_add(background_);
+ if (!image_) return;
+
+ if (splash_data.images.empty()) return;
+
+ const std::string& image_path = splash_data.images.front().first;
+ elm_image_file_set(image_, (app_path + image_path).c_str(), NULL);
+ evas_object_resize(image_, bound.first, bound.second);
+ evas_object_show(image_);
+ evas_object_show(parent);
+}
+} // namespace tizen
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TIZEN_BROWSER_SPLASH_SCREEN_H_
+#define TIZEN_BROWSER_SPLASH_SCREEN_H_
+
+#include <map>
+#include <memory>
+#include <utility>
+#include <string>
+#include <vector>
+
+#include <Elementary.h>
+#include "wgt_manifest_handlers/launch_screen_handler.h"
+
+enum HideReason { RENDERED, LOADFINISHED, CUSTOM };
+
+namespace tizen {
+
+enum class ScreenOrientation {
+ PORTRAIT_PRIMARY = 0,
+ PORTRAIT_SECONDARY = 1,
+ LANDSCAPE_PRIMARY = 2,
+ LANDSCAPE_SECONDARY = 3,
+ NATURAL = 4,
+ ANY = 5
+};
+
+class SplashScreen {
+ public:
+ typedef std::pair<int, int> SplashScreenBound;
+
+ SplashScreen(Evas_Object* window,
+ std::shared_ptr<const wgt::parse::LaunchScreenInfo> ss_info,
+ const std::string& app_path);
+ void HideSplashScreen(int reason);
+
+ private:
+ std::pair<int, int> GetDimensions(Evas_Object* window);
+ void SetBackground(const wgt::parse::LaunchScreenData& splash_data,
+ Evas_Object* parent, const SplashScreenBound& bound,
+ const std::string& app_path);
+
+ void SetImage(const wgt::parse::LaunchScreenData& splash_data,
+ Evas_Object* parent, const SplashScreenBound& bound,
+ const std::string& app_path);
+
+ std::shared_ptr<const wgt::parse::LaunchScreenInfo> ss_info_;
+ Evas_Object* window_;
+ Evas_Object* image_;
+ Evas_Object* background_;
+ Evas_Object* background_image_;
+ bool is_active_;
+};
+} // namespace tizen
+#endif // TIZEN_BROWSER_SPLASH_SCREEN_H_
#include <watch_app_efl.h>
#endif
+#include "atom/browser/native_window_efl.h"
+#include "atom/browser/window_list.h"
#include "atom/common/api/api_messages.h"
+#include "base/strings/utf_string_conversions.h"
#include "common/string_utils.h"
+#include "content/public/browser/render_frame_host.h"
#include "tizen/browser/tizen_browser_parts.h"
#include "tizen/browser/vibration_manager.h"
+#include "tizen/src/browser/native_web_runtime.h"
#include "tizen_src/ewk/efl_integration/text_encoding_map_efl.h"
#if defined(TIZEN_VIDEO_HOLE)
-#include "atom/browser/native_window_efl.h"
-#include "atom/browser/window_list.h"
#include "media/base/tizen/media_player_efl.h"
#endif
const std::string kDefaultEncoding = "UTF-8";
+const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main";
+const char* kAppControlEventScript =
+ "(function(){"
+ "var __event = document.createEvent(\"CustomEvent\");\n"
+ "__event.initCustomEvent(\"appcontrol\", true, true, null);\n"
+ "document.dispatchEvent(__event);\n"
+ "\n"
+ "for(var i=0; i < window.frames.length; i++)\n"
+ "{ window.frames[i].document.dispatchEvent(__event); }"
+ "})()";
const char* kDefaultCSPRule =
- "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
+ "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
static bool ProcessWellKnownScheme(const std::string& url) {
if (common::utils::StartsWith(url, "file:") ||
TizenBrowserParts::TizenBrowserParts()
: locale_manager_(new common::LocaleManager()),
cookie_manager_(new CookieManager()),
- is_suspended_(false) {
+ is_suspended_(false),
+ launched_(false) {
}
TizenBrowserParts::~TizenBrowserParts() {
}
void TizenBrowserParts::InitializeWindow() {
- auto app_data = common::ApplicationDataManager::GetCurrentAppData();
#if !defined(OS_TIZEN_TV_PRODUCT)
- if (app_data->app_type() == common::ApplicationData::WATCH) {
+ if (app_data_->app_type() == common::ApplicationData::WATCH) {
elm_config_accel_preference_set("opengl");
watch_app_get_elm_win(&window_);
elm_win_alpha_set(window_, EINA_TRUE);
tizen::VibrationManager::CreateInstance();
InitializeWindow();
+ SetSplashScreen();
}
void TizenBrowserParts::ClearCookie() {
#endif
}
-void TizenBrowserParts::Suspend(content::RenderViewHost* rvh) {
+void TizenBrowserParts::SuspendRVH(content::RenderViewHost* rvh) {
if (is_suspended_ || !rvh)
return;
rvh->Send(new WrtViewMsg_SuspendScheduledTask(rvh->GetRoutingID()));
}
-void TizenBrowserParts::Resume(content::RenderViewHost* rvh) {
+void TizenBrowserParts::ResumeRVH(content::RenderViewHost* rvh) {
if (!is_suspended_ || !rvh)
return;
else return kDefaultEncoding;
}
+// Function is same as suspend. This will be called from app lifecycle suspend
+void TizenBrowserParts::Suspend() {
+ // If application is having background catagory enabled then do not suspend the app
+ if (app_data_->setting_info() != NULL && app_data_->setting_info()->background_support_enabled()) {
+ return;
+ }
+
+ atom::NativeWindow *last_window = atom::WindowList::GetLastWindow();
+ if (!last_window)
+ return;
+
+ last_window->NotifySuspend();
+ auto rvh = last_window->web_contents()->GetRenderViewHost();
+ SuspendRVH(rvh);
+}
+
+// Function is same as resume. This will be called from app lifecycle resume
+void TizenBrowserParts::Resume() {
+ // If application is having background catagory enabled then do not resume the app
+ // as its has not suspend
+ if (app_data_->setting_info() != NULL && app_data_->setting_info()->background_support_enabled()) {
+ return;
+ }
+ atom::NativeWindow *last_window = atom::WindowList::GetLastWindow();
+ if (!last_window)
+ return;
+
+ last_window->NotifyResume();
+ auto rvh = last_window->web_contents()->GetRenderViewHost();
+ ResumeRVH(rvh);
+}
+
+void TizenBrowserParts::SetSplashScreen() {
+ if (!app_data_->splash_screen_info()) {
+ return;
+ }
+
+ Evas_Object* window_ = elm_win_util_standard_add("", "");
+
+ splash_screen_.reset(
+ new SplashScreen(
+ window_, app_data_->splash_screen_info(), app_data_->application_path()));
+}
+
+void TizenBrowserParts::HideSplashScreen(int reason) {
+ if (!app_data_->splash_screen_info()) {
+ return;
+ }
+
+ splash_screen_->HideSplashScreen(reason);
+}
+
+void TizenBrowserParts::AppControl(std::unique_ptr<common::AppControl> appcontrol) {
+ std::unique_ptr<common::ResourceManager::Resource> res =
+ resource_manager_->GetStartResource(appcontrol.get());
+ bool do_reset = res->should_reset();
+ atom::NativeWindow *last_window = atom::WindowList::GetLastWindow();
+ std::string localized_page = res->uri();
+ if (!do_reset) {
+ std::string current_page = last_window->web_contents()->GetURL().spec();
+ if (current_page != localized_page)
+ do_reset = true;
+ else
+ SendAppControlEvent();
+ }
+ if (do_reset && (appcontrol->operation() == kAppControlMain)) {
+ do_reset = false;
+ SendAppControlEvent();
+ }
+ if (do_reset) {
+ //TODO: Implementation of ClearViewStack(), SetupWebWindow(),SetupWebWindowCompatibilitySettings() function
+ }
+}
+
+void TizenBrowserParts::SendAppControlEvent() {
+ atom::NativeWindow *last_window = atom::WindowList::GetLastWindow();
+
+ if (last_window != NULL) {
+ content::RenderFrameHost* rfh = last_window->web_contents()->GetMainFrame();
+ if (rfh) {
+ rfh->ExecuteJavaScriptWithUserGestureForTests(
+ base::UTF8ToUTF16(kAppControlEventScript));
+ }
+ }
+}
+
+void TizenBrowserParts::Launch(std::unique_ptr<common::AppControl> appcontrol) {
+ launched_ = true;
+// TODO: Implementation of relaunching of app
+ std::unique_ptr<common::ResourceManager::Resource> res =
+ resource_manager_->GetStartResource(appcontrol.get());
+ if (res)
+ start_url_ = res->uri();
+
+ tizen::NativeWebRuntime::GetInstance().StartApplication();
+}
+
+
} // namespace tizen
#include <Evas.h>
#include "content/public/browser/render_view_host.h"
+#include "tizen/browser/splash_screen.h"
#include "tizen/common/app_control.h"
#include "tizen/common/application_data.h"
#include "tizen/common/locale_manager.h"
class TizenBrowserParts {
public:
TizenBrowserParts();
- virtual void AppControl(std::unique_ptr<common::AppControl> appcontrol) = 0;
- virtual void Launch(std::unique_ptr<common::AppControl> appcontrol) = 0;
- virtual bool launched() const = 0;
void RenderViewCreated(content::RenderViewHost* render_view_host);
- void Suspend(content::RenderViewHost* rvh);
- void Resume(content::RenderViewHost* rvh);
+ void SuspendRVH(content::RenderViewHost* rvh);
+ void ResumeRVH(content::RenderViewHost* rvh);
void GetCSP(std::string& csp_rule, std::string& csp_report_rule);
std::string GetEncodingType();
bool ShouldAllowNavigation(const std::string &url);
void Initialize();
void GetWindowDimensions(int& width, int& height);
+ void Suspend();
+ void Resume();
+ void SetSplashScreen();
+ void HideSplashScreen(int reason);
+ void AppControl(std::unique_ptr<common::AppControl> appcontrol);
+ void Launch(std::unique_ptr<common::AppControl> appcontrol);
+ void SendAppControlEvent();
Evas_Object* window() { return window_; }
+ bool launched() const { return launched_; }
+ std::string StartURL() const { return start_url_;}
void ClearCookie();
CookieManager* GetCookieManager() { return cookie_manager_; }
void InitializeWindow();
void SetLongPollingTimeout(content::RenderViewHost* render_view_host);
+ std::unique_ptr<SplashScreen> splash_screen_;
+
Evas_Object* window_;
common::ApplicationData* app_data_;
CookieManager* cookie_manager_;
bool is_suspended_;
std::string csp_rule_;
std::string csp_report_rule_;
+ std::string start_url_;
+ bool launched_;
};
} // namespace tizen
}
void WebRuntime::HideSplashScreen(int reason) {
- atom::Browser* browser_model = atom::Browser::Get();
- browser_model->HideSplashScreen(reason);
+#if defined(OS_TIZEN)
+ atom::Browser::Get()->HideSplashScreen(reason);
+#endif
}
void WebRuntime::Log(const std::string& message) const {
'atom/browser/native_browser_view_efl.h',
'atom/browser/native_window_efl.cc',
'atom/browser/native_window_efl.h',
- 'atom/browser/splash_screen.h',
- 'atom/browser/splash_screen.cc',
'atom/browser/ui/accelerator_util_efl.cc',
'atom/browser/ui/drag_util_efl.cc',
'atom/browser/ui/file_dialog_efl.cc',
'tizen/src/browser/wrt_ipc.h',
'tizen/src/browser/wrt_service.cc',
'tizen/src/browser/wrt_service.h',
+ 'tizen/browser/splash_screen.h',
+ 'tizen/browser/splash_screen.cc',
'tizen/browser/tizen_browser_parts.cc',
'tizen/browser/tizen_browser_parts.h',
'tizen/browser/tizen_web_contents_view_delegate.cc',